feat: init commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package xin.merlin.myblog_server.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xin.merlin.myblog_server.entity.Comment;
|
||||
import xin.merlin.myblog_server.entity.News;
|
||||
import xin.merlin.myblog_server.entity.Project;
|
||||
import xin.merlin.myblog_server.service.impl.*;
|
||||
import xin.merlin.myblog_server.utils.JwtUtil;
|
||||
import xin.merlin.myblog_server.utils.RequestBack;
|
||||
import xin.merlin.myblog_server.utils.enums.ResultCode;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/blog")
|
||||
public class BasicController {
|
||||
|
||||
@Resource
|
||||
private NewsServiceImpl newsService;
|
||||
|
||||
@Autowired
|
||||
private ArticleServiceImpl articleService;
|
||||
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
|
||||
@Autowired
|
||||
private ProjectServiceImpl projectService;
|
||||
|
||||
@Autowired
|
||||
private CommentServiceImpl commentService;
|
||||
|
||||
@Autowired
|
||||
private JwtUtil jwtUtil;
|
||||
|
||||
// 获取用户个人信息
|
||||
@GetMapping("/get/userinfo")
|
||||
public RequestBack getUserinfo(@RequestHeader("Authorization") String token) {
|
||||
token = token.substring(7);
|
||||
return RequestBack.success(ResultCode.SUCCESS,userService.getById(jwtUtil.getUId(token)));
|
||||
}
|
||||
|
||||
// 获取新闻
|
||||
@GetMapping("/get/news")
|
||||
public RequestBack getNews(@RequestParam Integer current,@RequestParam Integer size) {
|
||||
Page<News> page = new Page<>(current,size);
|
||||
return RequestBack.success(ResultCode.SUCCESS,newsService.page(page));
|
||||
}
|
||||
// 获取文章
|
||||
@GetMapping("/get/article/{a_id}")
|
||||
public RequestBack getArticle(@PathVariable Integer a_id) {
|
||||
return RequestBack.success(ResultCode.SUCCESS,articleService.getById(a_id));
|
||||
}
|
||||
// 获取项目
|
||||
@GetMapping("/get/projects")
|
||||
public RequestBack getProjects(@RequestParam Integer current,@RequestParam Integer size) {
|
||||
Page<Project> page = new Page<>(current,size);
|
||||
return RequestBack.success(ResultCode.SUCCESS,projectService.page(page));
|
||||
}
|
||||
// 参与项目
|
||||
// 发表评论
|
||||
@PostMapping("/publish/comment")
|
||||
public RequestBack publishComment(@RequestBody Comment comment) {
|
||||
commentService.save(comment);
|
||||
return RequestBack.success(ResultCode.SUCCESS);
|
||||
}
|
||||
// 联系管理员
|
||||
}
|
||||
Reference in New Issue
Block a user