资讯管理

master
wenyu441069198 3 months ago
parent 3c979067cb
commit cd290a7662
  1. 1
      src/main/java/com/teaching/backend/controller/cms/CmsCategoryController.java
  2. 9
      src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java
  3. 3
      src/main/java/com/teaching/backend/model/entity/cms/CmsCategory.java
  4. 2
      src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java
  5. 11
      src/main/java/com/teaching/backend/service/impl/cms/CmsCategoryServiceImpl.java
  6. 7
      src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java

@ -61,4 +61,5 @@ public class CmsCategoryController {
return cmsCategoryService.queryCategory();
}
}

@ -67,4 +67,13 @@ public class CmsEssayController {
return cmsEssayService.queryEssay(category_id);
}
/**
* 取消发布
* @param cmsEssay
* @return
*/
@PutMapping("/edit/status")
public BaseResponse<String> editStatus(CmsEssay cmsEssay){
return cmsEssayService.editStatus(cmsEssay);
}
}

@ -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")

@ -24,4 +24,6 @@ public interface ICmsEssayService extends IService<CmsEssay> {
BaseResponse<String> editEssay(CmsEssay cmsEssay);
BaseResponse<List<?>> queryEssay(Integer category_id);
BaseResponse<String> editStatus(CmsEssay cmsEssay);
}

@ -61,10 +61,15 @@ public class CmsCategoryServiceImpl extends ServiceImpl<CmsCategoryMapper, CmsCa
*/
@Override
public BaseResponse<List<?>> queryCategory() {
List<CmsCategory> categoryPid = query().eq("category_pid", 0).list();
//先查父栏目并排序
List<CmsCategory> 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);
}

@ -45,4 +45,11 @@ public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> i
List<CmsEssay> list = query().eq("category_id", category_id).list();
return ResultUtils.success(list);
}
@Override
public BaseResponse<String> editStatus(CmsEssay cmsEssay) {
cmsEssay.setStatus(cmsEssay.getStatus() & 1);
updateById(cmsEssay);
return ResultUtils.success("修改成功");
}
}

Loading…
Cancel
Save