From 90d03a05a2806d35044216a3065f285db3258782 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Tue, 18 May 2021 08:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=97=E9=93=BA=E5=85=A5?= =?UTF-8?q?=E9=A9=BB=E6=96=87=E7=AB=A0=E7=B1=BB=E5=9E=8B=E3=80=82=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BF=AE=E6=94=B9=E6=96=87=E7=AB=A0=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/entity/enums/ArticleEnum.java | 4 ++++ .../modules/page/service/ArticleService.java | 8 +++++++ .../page/serviceimpl/ArticleServiceImpl.java | 8 +++++++ .../other/ArticleManagerController.java | 21 +++++++++++++++---- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/page/entity/enums/ArticleEnum.java b/framework/src/main/java/cn/lili/modules/page/entity/enums/ArticleEnum.java index 6a92d460..d2c93723 100644 --- a/framework/src/main/java/cn/lili/modules/page/entity/enums/ArticleEnum.java +++ b/framework/src/main/java/cn/lili/modules/page/entity/enums/ArticleEnum.java @@ -24,6 +24,10 @@ public enum ArticleEnum { * 证照信息 */ LICENSE_INFORMATION, + /** + * 店铺入驻 + */ + STORE_REGISTER, /** * 其他文章 */ diff --git a/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java b/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java index b397e94c..abe3a5a4 100644 --- a/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java +++ b/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java @@ -69,4 +69,12 @@ public interface ArticleService extends IService
{ */ @Cacheable(key = "#type") Article customGetByType(String type); + + /** + * 修改文章状态 + * @param id 文章ID + * @param status 显示状态 + */ + @CacheEvict(key = "#id") + Boolean updateArticleStatus(String id,boolean status); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java index 0a1f9f71..ca194358 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java @@ -3,6 +3,7 @@ package cn.lili.modules.page.serviceimpl; import cn.hutool.core.util.StrUtil; import cn.lili.common.enums.ResultCode; +import cn.lili.common.enums.SwitchEnum; import cn.lili.common.exception.ServiceException; import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.PageUtil; @@ -82,4 +83,11 @@ public class ArticleServiceImpl extends ServiceImpl impl } 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); + } } \ No newline at end of file diff --git a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java index 446146f0..6399897e 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java @@ -13,7 +13,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -46,8 +45,8 @@ public class ArticleManagerController { @ApiOperation(value = "分页获取") @ApiImplicitParams({ - @ApiImplicitParam(name = "categoryId", value = "文章分类ID", dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "title", value = "标题", dataType = "String", paramType = "query") + @ApiImplicitParam(name = "categoryId", value = "文章分类ID", paramType = "query"), + @ApiImplicitParam(name = "title", value = "标题", paramType = "query") }) @GetMapping(value = "/getByPage") public ResultMessage> getByPage(ArticleSearchParams articleSearchParams) { @@ -63,13 +62,27 @@ public class ArticleManagerController { } @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}") public ResultMessage
update(@Valid Article article, @PathVariable("id") String id) { article.setId(id); 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
updateStatus(@PathVariable("id") String id,boolean status) { + if(articleService.updateArticleStatus(id,status)){ + return ResultUtil.success(ResultCode.SUCCESS); + } + return ResultUtil.error(ResultCode.ERROR); + } + + @ApiOperation(value = "批量删除") @ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") @DeleteMapping(value = "/delByIds/{id}")