115 lines
6.0 KiB
XML
115 lines
6.0 KiB
XML
<?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.ruoyi.system.mapper.CmsCategoryMapper">
|
|
|
|
<resultMap type="CmsCategory" id="CmsCategoryResult">
|
|
<result property="categoryId" column="category_id" />
|
|
<result property="categoryName" column="category_name" />
|
|
<result property="parentId" column="parent_id" />
|
|
<result property="ancestors" column="ancestors" />
|
|
<result property="sort" column="sort" />
|
|
<result property="description" column="description" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="status" column="status" />
|
|
<result property="delFlag" column="del_flag" />
|
|
<result property="parentName" column="parent_name" />
|
|
<result property="categoryTags" column="category_tags" />
|
|
</resultMap>
|
|
|
|
<sql id="selectCmsCategoryVo">
|
|
select category_id, category_name, parent_id, ancestors, sort, description, create_time, update_time, create_by, update_by, status, del_flag, category_tags from cms_category
|
|
</sql>
|
|
|
|
<select id="selectCmsCategoryList" parameterType="CmsCategory" resultMap="CmsCategoryResult">
|
|
<include refid="selectCmsCategoryVo"/>
|
|
<where>
|
|
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
|
|
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
|
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
|
|
<if test="sort != null "> and sort = #{sort}</if>
|
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
|
<if test="status != null "> and status = #{status}</if>
|
|
<if test="categoryTags != null and categoryTags != ''"> and category_tags = #{categoryTags}</if>
|
|
</where>
|
|
order by sort
|
|
</select>
|
|
|
|
<!-- <select id="selectCmsCategoryByCategoryId" parameterType="Long" resultMap="CmsCategoryResult">-->
|
|
<!-- <include refid="selectCmsCategoryVo"/>-->
|
|
<!-- where category_id = #{categoryId}-->
|
|
<!-- </select>-->
|
|
<select id="selectCmsCategoryByCategoryId" resultMap="CmsCategoryResult">
|
|
select t.category_id, t.category_name, t.parent_id, t.ancestors, t.sort, t.description, t.create_time, t.update_time, t.create_by, t.update_by, t.status, t.del_flag, p.category_name as parent_name
|
|
from cms_category t
|
|
left join cms_category p on p.category_id = t.parent_id
|
|
where t.category_id = #{categoryId}
|
|
</select>
|
|
|
|
<insert id="insertCmsCategory" parameterType="CmsCategory" useGeneratedKeys="true" keyProperty="categoryId">
|
|
insert into cms_category
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="categoryName != null">category_name,</if>
|
|
<if test="parentId != null">parent_id,</if>
|
|
<if test="ancestors != null">ancestors,</if>
|
|
<if test="sort != null">sort,</if>
|
|
<if test="description != null">description,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
<if test="categoryTags != null">category_tags,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="categoryName != null">#{categoryName},</if>
|
|
<if test="parentId != null">#{parentId},</if>
|
|
<if test="ancestors != null">#{ancestors},</if>
|
|
<if test="sort != null">#{sort},</if>
|
|
<if test="description != null">#{description},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
<if test="categoryTags != null">#{categoryTags},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateCmsCategory" parameterType="CmsCategory">
|
|
update cms_category
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="categoryName != null">category_name = #{categoryName},</if>
|
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
|
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
|
<if test="sort != null">sort = #{sort},</if>
|
|
<if test="description != null">description = #{description},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
<if test="categoryTags != null">category_tags = #{categoryTags},</if>
|
|
</trim>
|
|
where category_id = #{categoryId}
|
|
</update>
|
|
|
|
<delete id="deleteCmsCategoryByCategoryId" parameterType="Long">
|
|
delete from cms_category where category_id = #{categoryId}
|
|
</delete>
|
|
|
|
<delete id="deleteCmsCategoryByCategoryIds" parameterType="String">
|
|
delete from cms_category where category_id in
|
|
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
|
|
#{categoryId}
|
|
</foreach>
|
|
</delete>
|
|
</mapper>
|