增加店铺入驻文章类型。添加修改文章状态方法

This commit is contained in:
lifenlong 2021-05-18 08:57:43 +08:00
parent a1924b609c
commit 90d03a05a2
4 changed files with 37 additions and 4 deletions

View File

@ -24,6 +24,10 @@ public enum ArticleEnum {
* 证照信息 * 证照信息
*/ */
LICENSE_INFORMATION, LICENSE_INFORMATION,
/**
* 店铺入驻
*/
STORE_REGISTER,
/** /**
* 其他文章 * 其他文章
*/ */

View File

@ -69,4 +69,12 @@ public interface ArticleService extends IService<Article> {
*/ */
@Cacheable(key = "#type") @Cacheable(key = "#type")
Article customGetByType(String type); Article customGetByType(String type);
/**
* 修改文章状态
* @param id 文章ID
* @param status 显示状态
*/
@CacheEvict(key = "#id")
Boolean updateArticleStatus(String id,boolean status);
} }

View File

@ -3,6 +3,7 @@ package cn.lili.modules.page.serviceimpl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.SwitchEnum;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
@ -82,4 +83,11 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
} }
return null; return null;
} }
@Override
public Boolean updateArticleStatus(String id, boolean status) {
Article article=this.getById(id);
article.setOpenStatus(status? SwitchEnum.OPEN.name():SwitchEnum.CLOSE.name());
return this.updateById(article);
}
} }

View File

@ -13,7 +13,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -46,8 +45,8 @@ public class ArticleManagerController {
@ApiOperation(value = "分页获取") @ApiOperation(value = "分页获取")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "categoryId", value = "文章分类ID", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "categoryId", value = "文章分类ID", paramType = "query"),
@ApiImplicitParam(name = "title", value = "标题", dataType = "String", paramType = "query") @ApiImplicitParam(name = "title", value = "标题", paramType = "query")
}) })
@GetMapping(value = "/getByPage") @GetMapping(value = "/getByPage")
public ResultMessage<IPage<ArticleVO>> getByPage(ArticleSearchParams articleSearchParams) { public ResultMessage<IPage<ArticleVO>> getByPage(ArticleSearchParams articleSearchParams) {
@ -63,13 +62,27 @@ public class ArticleManagerController {
} }
@ApiOperation(value = "修改文章") @ApiOperation(value = "修改文章")
@ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") @ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path")
@PutMapping("update/{id}") @PutMapping("update/{id}")
public ResultMessage<Article> update(@Valid Article article, @PathVariable("id") String id) { public ResultMessage<Article> update(@Valid Article article, @PathVariable("id") String id) {
article.setId(id); article.setId(id);
return ResultUtil.data(articleService.updateArticle(article)); return ResultUtil.data(articleService.updateArticle(article));
} }
@ApiOperation(value = "修改文章状态")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path"),
@ApiImplicitParam(name = "status", value = "操作状态", required = true, paramType = "query")
})
@PutMapping("update/status/{id}")
public ResultMessage<Article> updateStatus(@PathVariable("id") String id,boolean status) {
if(articleService.updateArticleStatus(id,status)){
return ResultUtil.success(ResultCode.SUCCESS);
}
return ResultUtil.error(ResultCode.ERROR);
}
@ApiOperation(value = "批量删除") @ApiOperation(value = "批量删除")
@ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") @ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path")
@DeleteMapping(value = "/delByIds/{id}") @DeleteMapping(value = "/delByIds/{id}")