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("修改成功"); + } }