From a401b05ad85cfbb31ee1ad9f57ba5a9cfb62dc5b Mon Sep 17 00:00:00 2001 From: wangzhiwei Date: Thu, 29 Jan 2026 18:30:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(content):=20=E6=B7=BB=E5=8A=A0=E7=88=B6?= =?UTF-8?q?=E5=88=86=E7=B1=BBID=E5=AD=97=E6=AE=B5=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在CmsContent实体类中新增parentCategoryId字段 - 在CmsContentDto数据传输对象中添加parentCategoryId属性 - 更新数据库映射文件中的查询语句以包含parent_category_id字段 - 添加针对parentCategoryId的条件查询逻辑 - 在插入和更新操作中支持parentCategoryId字段 - 为官方内容添加isOfficial过滤条件支持 --- .../com/kexue/skills/entity/CmsContent.java | 3 +++ .../skills/entity/dto/CmsContentDto.java | 2 ++ .../resources/mapper/CmsContentMapper.xml | 26 +++++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/kexue/skills/entity/CmsContent.java b/src/main/java/com/kexue/skills/entity/CmsContent.java index f2d4013..47f72ef 100644 --- a/src/main/java/com/kexue/skills/entity/CmsContent.java +++ b/src/main/java/com/kexue/skills/entity/CmsContent.java @@ -129,6 +129,9 @@ public class CmsContent extends BaseEntity implements Serializable { @Schema(description ="副标题") private String subtitle; + @Schema(description ="父分类ID") + private Long parentCategoryId; + // 用于接收前端发送的分类ID数组 @JsonProperty("categoryIds") public void setCategoryIdsFromArray(List categoryIdList) { diff --git a/src/main/java/com/kexue/skills/entity/dto/CmsContentDto.java b/src/main/java/com/kexue/skills/entity/dto/CmsContentDto.java index c6bf18b..2589883 100644 --- a/src/main/java/com/kexue/skills/entity/dto/CmsContentDto.java +++ b/src/main/java/com/kexue/skills/entity/dto/CmsContentDto.java @@ -42,4 +42,6 @@ public class CmsContentDto extends BaseQueryDto { private Integer deleteFlag; + private Long parentCategoryId; + } diff --git a/src/main/resources/mapper/CmsContentMapper.xml b/src/main/resources/mapper/CmsContentMapper.xml index b9bef66..625c176 100644 --- a/src/main/resources/mapper/CmsContentMapper.xml +++ b/src/main/resources/mapper/CmsContentMapper.xml @@ -6,6 +6,7 @@ + @@ -42,7 +43,7 @@ select - content_id, title, subtitle, content_type, category_ids, summary, content, cover_image, author_id, author_name, + content_id, title, subtitle, parent_category_id, content_type, category_ids, summary, content, cover_image, author_id, author_name, reviewer_id, reviewer_name, audit_status, audit_comment, publish_status, publish_time, view_count, like_count, comment_count, sort, is_paid, price, required_points, support_points_pay, is_official, share_count, file_url, icon, background, create_time, update_time, create_by, update_by, delete_flag from cms_content @@ -97,6 +98,12 @@ and delete_flag = #{deleteFlag} + + and is_official = #{isOfficial} + + + and parent_category_id = #{parentCategoryId} + order by ${sortBy} ${sortDesc ? 'desc' : 'asc'} @@ -109,7 +116,7 @@ - insert into cms_content(title, subtitle, content_type, category_ids, summary, content, cover_image, author_id, author_name, + insert into cms_content(title, subtitle, parent_category_id, content_type, category_ids, summary, content, cover_image, author_id, author_name, reviewer_id, reviewer_name, audit_status, audit_comment, publish_status, publish_time, view_count, like_count, comment_count, sort, is_paid, price, required_points, support_points_pay, is_official, share_count, file_url, icon, background, create_time, update_time, create_by, update_by, delete_flag) - values (#{title}, #{subtitle}, #{contentType}, #{categoryIds}, #{summary}, #{content}, #{coverImage}, #{authorId}, #{authorName}, + values (#{title}, #{subtitle}, #{parentCategoryId}, #{contentType}, #{categoryIds}, #{summary}, #{content}, #{coverImage}, #{authorId}, #{authorName}, #{reviewerId}, #{reviewerName}, #{auditStatus}, #{auditComment}, #{publishStatus}, #{publishTime}, #{viewCount}, #{likeCount}, #{commentCount}, #{sort}, #{isPaid}, #{price}, #{requiredPoints}, #{supportPointsPay}, #{isOfficial}, #{shareCount}, #{fileUrl}, #{icon}, #{background}, #{createTime}, #{updateTime}, #{createBy}, #{updateBy}, #{deleteFlag}) @@ -172,6 +185,9 @@ subtitle = #{subtitle}, + + parent_category_id = #{parentCategoryId}, + content_type = #{contentType},