<?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.artfess.sysConfig.persistence.dao.SysDictionaryDao">

    <update id="updateDictionariesStatus">
        update portal_sys_dictionary
        set  flag_=
        <if test="status != null">
            #{status}
        </if>
        where id_ in
        <foreach collection="ids" index="index" item="valueList"
                 separator="," open="(" close=")">
            #{valueList}
        </foreach>
    </update>

    <update id="moveDictionaries">
        update portal_sys_dictionary
        set  TREE_ID_=
        <if test="treeId != null">
            #{treeId}
        </if>
        where id_ in
        <foreach collection="ids" index="index" item="valueList"
                 separator="," open="(" close=")">
            #{valueList}
        </foreach>
    </update>

    <!-- 通过字典code获取字典数据 -->
    <select id="queryDictTextByKey" parameterType="String"  resultType="String">
        select s.NAME from sys_dictionary_detail s
            where s.DICTIONARY_ID = (
		        select id from sys_dictionary where del_flag =1 and flag=1 and code = #{code}
                <if test="companyId != null and companyId != '' ">
                    and company_id = #{companyId}
                </if>
                <if test="companyId == null or companyId == '' ">
                    and KIND_ID = 1
                </if>
		   )
		   and s.flag =1 and s.value = #{key}
	</select>

    <!-- 根据字典值的id级联查询下级字典 -->
    <select id="queryLowerDictionary" parameterType="String"  resultType="com.artfess.sysConfig.persistence.model.SysDictionary">
        select de.* from portal_sys_dictionary de
            where de.flag_=1
                and id_ in(
                    select c.LOWER_DIC_ID_ from portal_sys_dictionary_cascade c where c.DETAIL_ID_ = #{detailId}
                )
    </select>




</mapper>
