123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package com.caimei.controller.admin.data;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.vo.ArticleFormVo;
- import com.caimei.model.vo.ArticleListVo;
- import com.caimei.service.auth.ArticleService;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- /**
- * 资料库文章API
- *
- * @author : Aslee
- * @date : 2021/7/8
- */
- @Api(tags = "资料库文章API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/data/article")
- public class ArticleApi {
- private final ArticleService articleService;
- @ApiOperation("文章列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1文章列表,2文章审核列表"),
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
- @ApiImplicitParam(name = "articleTitle", required = false, value = "文章标题"),
- @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
- @ApiImplicitParam(name = "status", required = false, value = "文章状态:0已下线,1已上线,2待上线"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return articleService.getArticleList(listType, authUserId, articleTitle, auditStatus, status, pageNum, pageSize);
- }
- @ApiOperation("添加/编辑文章")
- @ApiImplicitParam(name = "params", value = "articleId:文章id;authUserId:供应商用户id;articleTitle:文章标题;articleImage:文章图片;articleContent:文章内容", required = true)
- @PostMapping("/save")
- public ResponseJson saveArticle(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer articleId = paramsMap.getInteger("articleId");
- Integer authUserId = paramsMap.getInteger("authUserId");
- String articleTitle = paramsMap.getString("articleTitle");
- String articleImage = paramsMap.getString("articleImage");
- String articleContent = paramsMap.getString("articleContent");
- return articleService.saveArticle(articleId, authUserId, articleTitle, articleImage, articleContent);
- }
- @ApiOperation("文章回显数据")
- @ApiImplicitParam(name = "articleId", value = "文章id", required = true)
- @GetMapping("/form/data")
- public ResponseJson<ArticleFormVo> getArticleFormData(Integer articleId) {
- return articleService.getArticleFormData(articleId);
- }
- @ApiOperation("更新文章状态")
- @ApiImplicitParam(name = "params", value = "articleId:文章id;status:文章状态:0停用 1启用;", required = true)
- @PostMapping("/update/status")
- public ResponseJson updateArticleStatus(@RequestBody Map<String,Integer> params) {
- Integer articleId = params.get("articleId");
- Integer status = params.get("status");
- return articleService.updateArticleStatus(articleId, status);
- }
- @ApiOperation("删除文章")
- @ApiImplicitParam(name = "params", value = "articleId:文章id", required = true)
- @PostMapping("/delete")
- public ResponseJson deleteArticle(@RequestBody Map<String,Integer> params) {
- Integer articleId = params.get("articleId");
- return articleService.deleteArticle(articleId);
- }
- @ApiOperation("审核文章")
- @ApiImplicitParam(name = "params", value = "articleId:文章id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
- @PostMapping("/audit")
- public ResponseJson auditArticle(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer articleId = paramsMap.getInteger("articleId");
- Integer auditStatus = paramsMap.getInteger("auditStatus");
- String invalidReason = paramsMap.getString("invalidReason");
- Integer auditBy = paramsMap.getInteger("auditBy");
- return articleService.auditArticle(articleId, auditStatus, invalidReason, auditBy);
- }
- @ApiOperation("更改查看标记")
- @ApiImplicitParam(name = "articleId", required = true, value = "文章id")
- @PostMapping("/check")
- public ResponseJson checkArticle(Integer articleId) {
- return articleService.checkArticle(articleId);
- }
- }
|