138 lines
5.7 KiB
XML
138 lines
5.7 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.AsArticleClassifyMapper">
|
||
|
|
|
||
|
|
<resultMap type="AsArticleClassify" id="AsArticleClassifyResult">
|
||
|
|
<id property="classifyId" column="classify_id" />
|
||
|
|
<result property="parentId" column="parent_id" />
|
||
|
|
<result property="ancestors" column="ancestors" />
|
||
|
|
<result property="classifyName" column="classify_name" />
|
||
|
|
<result property="orderNum" column="order_num" />
|
||
|
|
<result property="status" column="status" />
|
||
|
|
<result property="delFlag" column="del_flag" />
|
||
|
|
<result property="parentName" column="parent_name" />
|
||
|
|
<result property="createBy" column="create_by" />
|
||
|
|
<result property="createTime" column="create_time" />
|
||
|
|
<result property="updateBy" column="update_by" />
|
||
|
|
<result property="updateTime" column="update_time" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<sql id="selectClassifyVo">
|
||
|
|
select d.classify_id, d.parent_id, d.ancestors, d.classify_name, d.order_num, d.status, d.del_flag, d.create_by, d.create_time
|
||
|
|
from et_article_classify d
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<select id="selectClassifyList" parameterType="AsArticleClassify" resultMap="AsArticleClassifyResult">
|
||
|
|
<include refid="selectClassifyVo"/>
|
||
|
|
where d.del_flag = '0'
|
||
|
|
<if test="classifyId != null and classifyId != 0">
|
||
|
|
AND classify_id = #{classifyId}
|
||
|
|
</if>
|
||
|
|
<if test="parentId != null and parentId != 0">
|
||
|
|
AND parent_id = #{parentId}
|
||
|
|
</if>
|
||
|
|
<if test="classifyName != null and classifyName != ''">
|
||
|
|
AND classify_name like concat('%', #{classifyName}, '%')
|
||
|
|
</if>
|
||
|
|
<if test="status != null and status != ''">
|
||
|
|
AND status = #{status}
|
||
|
|
</if>
|
||
|
|
<!-- 数据范围过滤 -->
|
||
|
|
${params.dataScope}
|
||
|
|
order by d.parent_id, d.order_num
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectClassifyById" parameterType="Long" resultMap="AsArticleClassifyResult">
|
||
|
|
select d.classify_id, d.parent_id, d.ancestors, d.classify_name, d.order_num, d.status,
|
||
|
|
(select classify_name from et_article_classify where classify_id = d.parent_id) parent_name
|
||
|
|
from et_article_classify d
|
||
|
|
where d.classify_id = #{classifyId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="checkClassifyExistArticle" parameterType="Long" resultType="int">
|
||
|
|
select count(1) from et_article where classify_id = #{classifyId} and del_flag = '0'
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="hasChildByClassifyId" parameterType="Long" resultType="int">
|
||
|
|
select count(1) from et_article_classify
|
||
|
|
where del_flag = '0' and parent_id = #{classifyId} limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectChildrenClassifyById" parameterType="Long" resultMap="AsArticleClassifyResult">
|
||
|
|
select * from et_article_classify where find_in_set(#{classifyId}, ancestors)
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectNormalChildrenClassifyById" parameterType="Long" resultType="int">
|
||
|
|
select count(*) from et_article_classify where status = 0 and del_flag = '0' and find_in_set(#{classifyId}, ancestors)
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="checkClassifyNameUnique" resultMap="AsArticleClassifyResult">
|
||
|
|
<include refid="selectClassifyVo"/>
|
||
|
|
where classify_name=#{classifyName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertClassify" parameterType="SysDept">
|
||
|
|
insert into et_article_classify(
|
||
|
|
<if test="classifyId != null and classifyId != 0">classify_id,</if>
|
||
|
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||
|
|
<if test="classifyName != null and classifyName != ''">classify_name,</if>
|
||
|
|
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
||
|
|
<if test="orderNum != null">order_num,</if>
|
||
|
|
<if test="status != null">status,</if>
|
||
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||
|
|
create_time
|
||
|
|
)values(
|
||
|
|
<if test="classifyId != null and classifyId != 0">#{classifyId},</if>
|
||
|
|
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
||
|
|
<if test="classifyName != null and classifyName != ''">#{classifyName},</if>
|
||
|
|
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
||
|
|
<if test="orderNum != null">#{orderNum},</if>
|
||
|
|
<if test="status != null">#{status},</if>
|
||
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||
|
|
sysdate()
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateClassify" parameterType="SysDept">
|
||
|
|
update et_article_classify
|
||
|
|
<set>
|
||
|
|
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
||
|
|
<if test="classifyName != null and classifyName != ''">classify_name = #{classifyName},</if>
|
||
|
|
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
||
|
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
||
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||
|
|
update_time = sysdate()
|
||
|
|
</set>
|
||
|
|
where classify_id = #{classifyId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="updateClassifyChildren" parameterType="java.util.List">
|
||
|
|
update et_article_classify set ancestors =
|
||
|
|
<foreach collection="classifyIds" item="item" index="index"
|
||
|
|
separator=" " open="case classify_id" close="end">
|
||
|
|
when #{item.classifyId} then #{item.ancestors}
|
||
|
|
</foreach>
|
||
|
|
where classify_id in
|
||
|
|
<foreach collection="classifyIds" item="item" index="index"
|
||
|
|
separator="," open="(" close=")">
|
||
|
|
#{item.classifyId}
|
||
|
|
</foreach>
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="updateClassifyStatusNormal" parameterType="Long">
|
||
|
|
update et_article_classify set status = '0' where classify_id in
|
||
|
|
<foreach collection="array" item="classifyId" open="(" separator="," close=")">
|
||
|
|
#{classifyId}
|
||
|
|
</foreach>
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<delete id="deleteClassifyById" parameterType="Long">
|
||
|
|
update et_article_classify set del_flag = '2' where classify_id = #{classifyId}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
</mapper>
|