<?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>
|