<?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.smyq.app.mapper.DictMapper">
  <!--数据字典-->
  <resultMap id="dict_result" type="com.fkzy.warn.model.vo.DictVO">
    <result column="id" property="id" jdbcType="INTEGER"/>
    <result column="dict_name" property="dictName" jdbcType="VARCHAR"/>
    <result column="dict_code" property="dictCode" jdbcType="VARCHAR"/>
    <result column="dict_rank" property="dictRank" jdbcType="INTEGER"/>
    <result column="dict_desc" property="dictDesc" jdbcType="VARCHAR"/>
 
  </resultMap>

  <select id="queryPage" resultMap="dict_result">

    SELECT
    *
    FROM
    t_sys_dict
    WHERE
    is_del = 0
    
    <if test="null !=map.dictCode">
      AND dict_code LIKE '%${map.dictCode}%'
    </if>
    <if test=" null !=map.dictName">
      AND dict_name LIKE '%${map.dictName}%'
    </if>

    UNION
    SELECT
    *
    FROM
    t_sys_dict
    WHERE
    is_del = 0

    AND id IN ( SELECT dict_id as id FROM t_sys_dict_item WHERE is_del = 0
    <if test="null !=map.dictCode">
      AND dict_item_code LIKE '%${map.dictCode}%'
    </if>
    <if test=" null !=map.dictName">
      AND dict_item_name LIKE '%${map.dictName}%'
    </if>
    )


  </select>




  <update id="updateBatch">
    <foreach collection="idList" index="index" item="id" open="" separator=";" close="">
      update t_sys_dict
      <set>
        is_del =1
      </set>
      WHERE id=#{id}
    </foreach>
  </update>


</mapper>