cloudroam
2025-05-26 25f83d7e36573da46bade5f54315797aa9c9e6cb
add:增加影视作品分类
已添加2个文件
110 ■■■■■ 文件已修改
src/main/java/com/mzl/flower/dto/response/film/FilmCategoryDTO.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/film/FilmCategoryMapper.xml 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/dto/response/film/FilmCategoryDTO.java
对比新文件
@@ -0,0 +1,40 @@
package com.mzl.flower.dto.response.film;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class FilmCategoryDTO {
    @ApiModelProperty(value = "分类ID")
    private Long id;
    @ApiModelProperty(value = "分类名称")
    private String name;
    @ApiModelProperty(value = "父分类ID")
    private Long parentId;
    @ApiModelProperty(value = "父分类名称")
    private String parentName;
    @ApiModelProperty(value = "分类类型")
    private String type;
    @ApiModelProperty(value = "分类编码")
    private String code;
    @ApiModelProperty(value = "排序")
    private Integer sortBy;
    @ApiModelProperty(value = "分类图标")
    private String imageUrl;
    @ApiModelProperty(value = "是否显示")
    private Boolean shown;
    @ApiModelProperty(value = "级别限制")
    private String levelLimit;
    @ApiModelProperty(value = "子分类数量")
    private Integer childrenCount;
}
src/main/resources/mapper/film/FilmCategoryMapper.xml
对比新文件
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mzl.flower.mapper.film.FilmCategoryMapper">
    <resultMap id="BaseResultMap" type="com.mzl.flower.entity.film.FilmCategory">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="parent_id" property="parentId"/>
        <result column="parent_name" property="parentName"/>
        <result column="image_url" property="imageUrl"/>
        <result column="sort_by" property="sortBy"/>
        <result column="shown" property="shown"/>
        <result column="level_limit" property="levelLimit"/>
        <result column="create_by" property="createdBy"/>
        <result column="create_time" property="createdTime"/>
        <result column="update_by" property="updatedBy"/>
        <result column="update_time" property="updatedTime"/>
        <result column="deleted" property="deleted"/>
    </resultMap>
    <sql id="Base_Column_List">
        c.id, c.name, c.parent_id, c.parent_name, c.image_url, c.sort_by, c.shown, c.level_limit,
        c.create_by, c.create_time, c.update_by, c.update_time, c.deleted
    </sql>
    <select id="selectCategoryList" resultType="com.mzl.flower.dto.response.film.FilmCategoryTreeDTO">
        SELECT
            <include refid="Base_Column_List"/>,
            (SELECT COUNT(1) FROM t_film_category f WHERE f.parent_id = c.id AND f.deleted = 0) childrenCount
        FROM t_film_category c
        WHERE c.deleted = 0
        <if test="name != null and name != ''">
            AND (
                c.name LIKE CONCAT('%', #{name}, '%')
                OR EXISTS (
                    SELECT 1 FROM t_film_category sc
                    WHERE sc.parent_id = c.id
                    AND sc.name LIKE CONCAT('%', #{name}, '%')
                    AND sc.deleted = 0
                )
            )
        </if>
        <if test="parentId != null">
            AND c.parent_id = #{parentId}
        </if>
        <if test="shown != null">
            AND c.shown = #{shown}
        </if>
        ORDER BY c.sort_by ASC, c.create_time DESC
    </select>
    <select id="selectTreeList" resultType="com.mzl.flower.dto.response.film.FilmCategoryTreeDTO">
        SELECT
            <include refid="Base_Column_List"/>,
            (SELECT COUNT(1) FROM t_film_category f WHERE f.parent_id = c.id AND f.deleted = 0) childrenCount
        FROM t_film_category c
        WHERE c.deleted = 0
        <if test="name != null and name != ''">
            AND c.name LIKE CONCAT('%', #{name}, '%')
        </if>
        <if test="parentId != null">
            AND c.parent_id = #{parentId}
        </if>
        <if test="shown != null">
            AND c.shown = #{shown}
        </if>
        ORDER BY c.sort_by ASC, c.create_time DESC
    </select>
</mapper>