<?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.DictItemMapper">

  <!--数据字典项-->
  <resultMap id="dictItem_result" type="com.fkzy.warn.model.vo.DictItemVO">
    <result column="id" property="id" jdbcType="INTEGER"/>
    <result column="dict_id" property="dictId" jdbcType="VARCHAR"/>
    <result column="dict_item_name" property="dictItemName" jdbcType="VARCHAR"/>
    <result column="dict_item_code" property="dictItemCode" jdbcType="VARCHAR"/>
    <result column="dict_item_desc" property="dictItemDesc" jdbcType="VARCHAR"/>
    <result column="dict_item_rank" property="dictItemRank" jdbcType="INTEGER"/>

    
  </resultMap>

  <update id="updateByDictId">
    <foreach collection="dictIdList" index="index" item="id" open="" separator=";" close="">
      update t_sys_dict_item
      <set>
        is_del=1
      </set>
      WHERE dict_id=#{id}
    </foreach>
  </update>

  <select id="getDictItem" resultMap="dictItem_result">
    SELECT
    dt.id,
    dt.dict_id,
    dt.dict_item_name,
    dt.dict_item_code,
    dt.dict_item_desc,
    dt.dict_item_rank,
    dt.is_del,
    dt.create_time
    FROM
    t_sys_dict_item dt,
    t_sys_dict d
    WHERE
    d.id = dt.dict_id

    <if test="dictCode !=null">
      AND d.dict_code = #{dictCode}
    </if>
    ORDER BY
    dt.dict_item_rank ASC;
  </select>

  <select id="findByDictCode" resultMap="dictItem_result">
    SELECT
    dt.id,
    dt.dict_id,
    dt.dict_item_name,
    dt.dict_item_code,
    dt.dict_item_desc,
    dt.dict_item_rank,
    dt.is_del,
    dt.create_time
    FROM
    t_sys_dict_item dt,
    t_sys_dict d
    WHERE
    d.id = dt.dict_id
    AND d.dict_code= #{dictCode}
    AND dt.dict_item_code = #{dictItemCode}

    ORDER BY
    dt.dict_item_rank ASC
  </select>

  <select id="findByDictName" resultMap="dictItem_result">
    SELECT
    dt.id,
    dt.dict_id,
    dt.dict_item_name,
    dt.dict_item_code,
    dt.dict_item_desc,
    dt.dict_item_rank,
    dt.is_del,
    dt.create_time
    FROM
    t_sys_dict_item dt,
    t_sys_dict d
    WHERE
    d.id = dt.dict_id
    AND d.dict_code= #{dictCode}
    AND dt.dict_item_name = #{dictItemName}

    ORDER BY
    dt.dict_item_rank ASC
  </select>

  <select id="queryPage" resultMap="dictItem_result">
   select
     id,
     dict_id ,
     dict_item_name ,
     dict_item_code ,
     dict_item_desc ,
     dict_item_rank ,
     is_del ,
     create_time
    FROM
    t_sys_dict_item as a
    WHERE is_del=0
      AND dict_id =#{map.id}

  </select>
    <select id="findByDictId" resultType="java.lang.String">
      select dict_item_name from t_sys_dict_item where dict_id = #{dictId}
    </select>
  <select id="findDictCodeByProductName" resultType="java.lang.String">
    select dict_item_code from t_sys_dict_item where dict_item_name = #{productName}
  </select>


</mapper>