content: package com.ld.poetry.controller;
  
  import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  import com.ld.poetry.aop.LoginCheck;
  import com.ld.poetry.config.PoetryResult;
  import com.ld.poetry.entity.*;
  import com.ld.poetry.service.ArticleService;
  import com.ld.poetry.utils.PoetryUtil;
  import com.ld.poetry.vo.ArticleVO;
  import com.ld.poetry.vo.BaseRequestVO;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  
  /**
   * <p>
   * 后台文章 前端控制器
   * </p>
   *
   * @author sara
   * @since 2021-08-13
   */
  @RestController
  @RequestMapping("/admin")
  public class AdminArticleController {
  
      @Autowired
      private ArticleService articleService;
  
      /**
       * 用户查询文章
       */
      @PostMapping("/article/user/list")
      @LoginCheck(1)
      public PoetryResult<Page> listUserArticle(@RequestBody BaseRequestVO baseRequestVO) {
          return articleService.listAdminArticle(baseRequestVO, false);
      }
  
      /**
       * Boss查询文章
       */
      @PostMapping("/article/boss/list")
      @LoginCheck(0)
      public PoetryResult<Page> listBossArticle(@RequestBody BaseRequestVO baseRequestVO) {
          return articleService.listAdminArticle(baseRequestVO, true);
      }
  
      /**
       * 修改文章状态
       */
      @GetMapping("/article/changeArticleStatus")
      @LoginCheck(1)
      public PoetryResult changeArticleStatus(@RequestParam("articleId") Integer articleId,
                                              @RequestParam(value = "viewStatus", required = false) Boolean viewStatus,
                                              @RequestParam(value = "commentStatus", required = false) Boolean commentStatus,
                                              @RequestParam(value = "recommendStatus", required = false) Boolean recommendStatus) {
          LambdaUpdateChainWrapper<Article> updateChainWrapper = articleService.lambdaUpdate()
                  .eq(Article::getId, articleId)
                  .eq(Article::getUserId, PoetryUtil.getUserId());
          if (viewStatus != null) {
              updateChainWrapper.set(Article::getViewStatus, viewStatus);
          }
          if (commentStatus != null) {
              updateChainWrapper.set(Article::getCommentStatus, commentStatus);
          }
          if (recommendStatus != null) {
              updateChainWrapper.set(Article::getRecommendStatus, recommendStatus);
          }
          updateChainWrapper.update();
          return PoetryResult.success();
      }
  
      /**
       * 查询文章
       */
      @GetMapping("/article/getArticleById")
      @LoginCheck(1)
      public PoetryResult<ArticleVO> getArticleByIdForUser(@RequestParam("id") Integer id) {
          return articleService.getArticleByIdForUser(id);
      }
  }
  