From cd290a76620e36afaebf06cf99e001bb1a538585 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 13 Aug 2024 18:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E8=AE=AF=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/controller/cms/CmsCategoryController.java | 1 + .../backend/controller/cms/CmsEssayController.java | 9 +++++++++ .../backend/model/entity/cms/CmsCategory.java | 3 +++ .../backend/service/cms/ICmsEssayService.java | 2 ++ .../service/impl/cms/CmsCategoryServiceImpl.java | 11 ++++++++--- .../backend/service/impl/cms/CmsEssayServiceImpl.java | 7 +++++++ 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/teaching/backend/controller/cms/CmsCategoryController.java b/src/main/java/com/teaching/backend/controller/cms/CmsCategoryController.java index 8477b2a..d87ddb6 100644 --- a/src/main/java/com/teaching/backend/controller/cms/CmsCategoryController.java +++ b/src/main/java/com/teaching/backend/controller/cms/CmsCategoryController.java @@ -61,4 +61,5 @@ public class CmsCategoryController { return cmsCategoryService.queryCategory(); } + } diff --git a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java index b89fa48..cc45502 100644 --- a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java +++ b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java @@ -67,4 +67,13 @@ public class CmsEssayController { return cmsEssayService.queryEssay(category_id); } + /** + * 取消发布 + * @param cmsEssay + * @return + */ + @PutMapping("/edit/status") + public BaseResponse editStatus(CmsEssay cmsEssay){ + return cmsEssayService.editStatus(cmsEssay); + } } diff --git a/src/main/java/com/teaching/backend/model/entity/cms/CmsCategory.java b/src/main/java/com/teaching/backend/model/entity/cms/CmsCategory.java index c4b91e7..1005dba 100644 --- a/src/main/java/com/teaching/backend/model/entity/cms/CmsCategory.java +++ b/src/main/java/com/teaching/backend/model/entity/cms/CmsCategory.java @@ -44,6 +44,9 @@ public class CmsCategory implements Serializable { @ApiModelProperty(value = "栏目父id(若为一级栏目则父id等于栏目id)") private Integer categoryPid; + @ApiModelProperty(value = "排序") + private Integer sort; + @ApiModelProperty(value = "创建时间") @TableField(fill = FieldFill.INSERT) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") diff --git a/src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java b/src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java index f122edb..56e2bb1 100644 --- a/src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java +++ b/src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java @@ -24,4 +24,6 @@ public interface ICmsEssayService extends IService { BaseResponse editEssay(CmsEssay cmsEssay); BaseResponse> queryEssay(Integer category_id); + + BaseResponse editStatus(CmsEssay cmsEssay); } diff --git a/src/main/java/com/teaching/backend/service/impl/cms/CmsCategoryServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/cms/CmsCategoryServiceImpl.java index e5f7e3a..8caac74 100644 --- a/src/main/java/com/teaching/backend/service/impl/cms/CmsCategoryServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/cms/CmsCategoryServiceImpl.java @@ -61,10 +61,15 @@ public class CmsCategoryServiceImpl extends ServiceImpl> queryCategory() { - List categoryPid = query().eq("category_pid", 0).list(); + //先查父栏目并排序 + List categoryPid = query() + .eq("category_pid", 0) + .orderByAsc("sort").list(); for (int i = 0; i < categoryPid.size(); i++) { - //查孩子 - categoryPid.get(i).setChildrenNode(query().eq("category_pid", categoryPid.get(i).getId()).list()); + //查孩子并排序 + categoryPid.get(i).setChildrenNode(query() + .eq("category_pid", categoryPid.get(i).getId()) + .orderByAsc("sort").list()); } return ResultUtils.success(categoryPid); } diff --git a/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java index 633b553..5e091fc 100644 --- a/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java @@ -45,4 +45,11 @@ public class CmsEssayServiceImpl extends ServiceImpl i List list = query().eq("category_id", category_id).list(); return ResultUtils.success(list); } + + @Override + public BaseResponse editStatus(CmsEssay cmsEssay) { + cmsEssay.setStatus(cmsEssay.getStatus() & 1); + updateById(cmsEssay); + return ResultUtils.success("修改成功"); + } }