博客系统后台控制层接口编写

BlogColumnCon

@CrossOrigin
@RequestMapping("/back/blogColumn")
@RestController
public class BlogColumnCon {

    @Autowired
    private BlogColumnService blogColumnService;

    /**
     * 新增
     *
     * @param blogColumn
     * @return
     */
    @PostMapping("/add")
    public BaseResult add(BlogColumn blogColumn) {
        blogColumnService.add(blogColumn);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param blogColumn
     * @return
     */
    @PostMapping("/update")
    public BaseResult update(BlogColumn blogColumn) {
        blogColumnService.update(blogColumn);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param blogColumnId
     * @return
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer blogColumnId) {
        blogColumnService.delete(blogColumnId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param blogColumnId
     * @return
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer blogColumnId) {
        BlogColumn blogColumn = blogColumnService.findById(blogColumnId);
        return BaseResult.ok(blogColumn);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List all = blogColumnService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page brandPage = blogColumnService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }

    /**
     * 根据用户id分页查询
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/searchByUserId")
    public BaseResult search(Integer userId, int page, int size) {
        Page brandPage = blogColumnService.searchByUserId(userId, page, size);
        return BaseResult.ok(brandPage);
    }
}

BlogCommentCon

@CrossOrigin
@RequestMapping("/back/blogComment")
@RestController
public class BlogCommentCon {

    @Autowired
    private BlogCommentService blogCommentService;

    /**
     * 新增
     *
     * @param blogComment
     * @return
     */
    @PostMapping("/add")
    public BaseResult add(BlogComment blogComment) {
        blogCommentService.add(blogComment);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param blogComment
     * @return
     */
    @PostMapping("/update")
    public BaseResult update(BlogComment blogComment) {
        blogCommentService.update(blogComment);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param blogCommentId
     * @return
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer blogCommentId) {
        blogCommentService.delete(blogCommentId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param blogCommentId
     * @return
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer blogCommentId) {
        BlogComment blogComment = blogCommentService.findById(blogCommentId);
        return BaseResult.ok(blogComment);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List all = blogCommentService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page brandPage = blogCommentService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }

    /**
     * 根据博客id分页查询
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/searchByBlogId")
    public BaseResult searchByBlogId(Integer blogId, int page, int size) {
        Page brandPage = blogCommentService.searchByBlogId(blogId, page, size);
        return BaseResult.ok(brandPage);
    }
}

BlogCon

package jkw.controller.back;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.Blog;
import jkw.pojo.BlogColumn;
import jkw.pojo.BlogTag;
import jkw.service.BlogService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RequestMapping("/back/blog")
@RestController
public class BlogCon {
    @Autowired
    private BlogService blogService;

    /**
     * 新增
     *
     * @param blog
     * @return
     */
    @PostMapping("/add")
    public BaseResult add(Blog blog) {
        blogService.add(blog);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param blog
     * @return
     */
    @PostMapping("/update")
    public BaseResult update(Blog blog) {
        blogService.update(blog);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param blogId
     * @return
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer blogId) {
        blogService.delete(blogId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param blogId
     * @return
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer blogId) {
        Blog blog = blogService.findById(blogId);
        return BaseResult.ok(blog);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List all = blogService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page brandPage = blogService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }

    /**
     * 根据用户名分页查找博客文章
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/searchByUserId")
    public BaseResult search(Integer userId, int page, int size) {
        Page brandPage = blogService.searchByUserId(userId, page, size);
        return BaseResult.ok(brandPage);
    }


    /**
     * 更新博客状态
     *
     * @param blogId
     * @return
     */
    @PostMapping("/updateStatus")
    public BaseResult update(Integer blogId) {
        blogService.updateStatus(blogId);
        return BaseResult.ok();
    }

    /**
     * 添加博客_专栏中间表的数据
     *
     * @param blogId       博客id
     * @param blogColumnId 专栏id
     * @return
     */
    @PostMapping("/addColumn")
    public BaseResult addColumn(Integer blogId, Integer blogColumnId) {
        blogService.addBlog_column(blogId, blogColumnId);
        return BaseResult.ok();
    }

    /**
     * 删除博客_专栏中间表的数据
     *
     * @param blogId       博客id
     * @param blogColumnId 专栏id
     * @return
     */
    @DeleteMapping("/deleteColumn")
    public BaseResult deleteColumn(Integer blogId, Integer blogColumnId) {
        blogService.deleteBlog_column(blogId, blogColumnId);
        return BaseResult.ok();
    }

    /**
     * 根据博客id查询博客_专栏中间表的专栏数据
     *
     * @param blogId
     * @return
     */
    @GetMapping("/findColumnByBlogId")
    public BaseResult findColumnByBlogId(Integer blogId) {
        List blogColumnList = blogService.findColumnByBlogId(blogId);
        return BaseResult.ok(blogColumnList);
    }

    /**
     * 添加博客_标签中间表的数据
     *
     * @param blogId    博客id
     * @param blogTagId 标签id
     * @return
     */
    @PostMapping("/addTag")
    public BaseResult addTag(Integer blogId, Integer blogTagId) {
        blogService.addBlog_tag(blogId, blogTagId);
        return BaseResult.ok();
    }

    /**
     * 删除博客_标签中间表的数据
     *
     * @param blogId    博客id
     * @param blogTagId 标签id
     * @return
     */
    @DeleteMapping("/deleteTag")
    public BaseResult deleteTag(Integer blogId, Integer blogTagId) {
        blogService.deleteBlog_tag(blogId, blogTagId);
        return BaseResult.ok();
    }

    /**
     * 根据博客id查询博客_标签中间表的标签数据
     *
     * @param blogId
     * @return
     */
    @GetMapping("/findTagByBlogId")
    public BaseResult findTagByBlogId(Integer blogId) {
        List blogTagList = blogService.findTagByBlogId(blogId);
        return BaseResult.ok(blogTagList);
    }

}

BlogTagCon

@CrossOrigin
@RequestMapping("/back/blogTag")
@RestController
public class BlogTagCon {

    @Autowired
    private BlogTagService blogTagService;

    /**
     * 新增
     *
     * @param blogTag
     * @return
     */
    @PostMapping("/add")
    public BaseResult add(BlogTag blogTag) {
        blogTagService.add(blogTag);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param blogTag
     * @return
     */
    @PostMapping("/update")
    public BaseResult update(BlogTag blogTag) {
        blogTagService.update(blogTag);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param blogTagId
     * @return
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer blogTagId) {
        blogTagService.delete(blogTagId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param blogTagId
     * @return
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer blogTagId) {
        BlogTag blogTag = blogTagService.findById(blogTagId);
        return BaseResult.ok(blogTag);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List all = blogTagService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page brandPage = blogTagService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }
}

BlogTypeCon

@CrossOrigin
@RequestMapping("/back/blogType")
@RestController
public class BlogTypeCon {

    @Autowired
    private BlogTypeService blogTypeService;

    /**
     * 新增
     *
     * @param blogType
     * @return
     */
    @PostMapping("/add")
    public BaseResult add(BlogType blogType) {
        blogTypeService.add(blogType);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param blogType
     * @return
     */
    @PostMapping("/update")
    public BaseResult update(BlogType blogType) {
        blogTypeService.update(blogType);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param blogTypeId
     * @return
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer blogTypeId) {
        blogTypeService.delete(blogTypeId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param blogTypeId
     * @return
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer blogTypeId) {
        BlogType blogType = blogTypeService.findById(blogTypeId);
        return BaseResult.ok(blogType);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List all = blogTypeService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */

    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page brandPage = blogTypeService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }
}

BlogVisibilityCon

@CrossOrigin
@RequestMapping("/back/blogVisibility")
@RestController
public class BlogVisibilityCon {

    @Autowired
    private BlogVisibilityService blogVisibilityService;

    /**
     * 新增
     *
     * @param blogVisibility
     * @return
     */
    @PostMapping("/add")
    public BaseResult add(BlogVisibility blogVisibility) {
        blogVisibilityService.add(blogVisibility);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param blogVisibility
     * @return
     */
    @PostMapping("/update")
    public BaseResult update(BlogVisibility blogVisibility) {
        blogVisibilityService.update(blogVisibility);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param blogVisibilityId
     * @return
     */
    @DeleteMapping("/delete")
    public BaseResult delete(Integer blogVisibilityId) {
        blogVisibilityService.delete(blogVisibilityId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param blogVisibilityId
     * @return
     */
    @GetMapping("/findById")
    public BaseResult findById(Integer blogVisibilityId) {
        BlogVisibility blogVisibility = blogVisibilityService.findById(blogVisibilityId);
        return BaseResult.ok(blogVisibility);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    public BaseResult findAll() {
        List all = blogVisibilityService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/search")
    public BaseResult search(String search, int page, int size) {
        Page blogVisibilityPage = blogVisibilityService.search(search, page, size);
        return BaseResult.ok(blogVisibilityPage);
    }
}







你可能感兴趣的:(博客系统,java)