<?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.gic.haoban.manage.service.dao.mapper.DictMapper" >
  <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanDict" >
    <id column="dict_id" property="dictId" jdbcType="VARCHAR" />
    <result column="dict_name" property="dictName" jdbcType="VARCHAR" />
    <result column="dict_key" property="dictKey" jdbcType="VARCHAR" />
    <result column="dict_title" property="dictTitle" jdbcType="VARCHAR" />
    <result column="dict_desc" property="dictDesc" jdbcType="VARCHAR" />
    <result column="dict_content" property="dictContent" jdbcType="VARCHAR"/>
    <result column="opt_user_name" property="optUserName" jdbcType="VARCHAR"/>
    <result column="opt_user_id" property="optUserId" jdbcType="VARCHAR"/>
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List" >
    dict_id, dict_name, dict_key, dict_title, dict_desc, dict_content,opt_user_name,opt_user_id,create_time,update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_dict
    where dict_id = #{dictId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from tab_haoban_dict
    where dict_id = #{dictId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDict" >
    insert into tab_haoban_dict (dict_id, dict_name, dict_key,
    dict_title, dict_desc, dict_content,opt_user_id,opt_user_name,create_time,update_time
      )
    values (#{dictId,jdbcType=VARCHAR}, #{dictName,jdbcType=VARCHAR}, #{dictKey,jdbcType=VARCHAR}, 
      #{dictTitle,jdbcType=VARCHAR}, #{dictDesc,jdbcType=VARCHAR}, #{dictContent,jdbcType=VARCHAR}
    ,#{optUserId,jdbcType=VARCHAR}, #{optUserName,jdbcType=VARCHAR},now(),now()
      )
  </insert>
  <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDict" >
    insert into tab_haoban_dict
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="dictId != null" >
        dict_id,
      </if>
      <if test="dictName != null" >
        dict_name,
      </if>
      <if test="dictKey != null" >
        dict_key,
      </if>
      <if test="dictTitle != null" >
        dict_title,
      </if>
      <if test="dictDesc != null" >
        dict_desc,
      </if>
      <if test="dictContent != null" >
        dict_content,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="dictId != null" >
        #{dictId,jdbcType=VARCHAR},
      </if>
      <if test="dictName != null" >
        #{dictName,jdbcType=VARCHAR},
      </if>
      <if test="dictKey != null" >
        #{dictKey,jdbcType=VARCHAR},
      </if>
      <if test="dictTitle != null" >
        #{dictTitle,jdbcType=VARCHAR},
      </if>
      <if test="dictDesc != null" >
        #{dictDesc,jdbcType=VARCHAR},
      </if>
      <if test="dictContent != null" >
        #{dictContent,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDict" >
    update tab_haoban_dict
    <set >
      <if test="dictName != null" >
        dict_name = #{dictName,jdbcType=VARCHAR},
      </if>
      <if test="dictKey != null" >
        dict_key = #{dictKey,jdbcType=VARCHAR},
      </if>
      <if test="dictTitle != null" >
        dict_title = #{dictTitle,jdbcType=VARCHAR},
      </if>
      <if test="dictDesc != null" >
        dict_desc = #{dictDesc,jdbcType=VARCHAR},
      </if>
      <if test="dictContent != null" >
        dict_content = #{dictContent,jdbcType=VARCHAR},
      </if>
      <if test="optUserId != null">
        opt_user_id = #{optUserId,jdbcType=VARCHAR},
      </if>
      <if test="optUserName != null">
        opt_user_name = #{optUserName,jdbcType=VARCHAR},
      </if>
      update_time = now()
    </set>
    where dict_id = #{dictId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDict" >
    update tab_haoban_dict
    set dict_name = #{dictName,jdbcType=VARCHAR},
      dict_key = #{dictKey,jdbcType=VARCHAR},
      dict_title = #{dictTitle,jdbcType=VARCHAR},
      dict_desc = #{dictDesc,jdbcType=VARCHAR},
      dict_content = #{dictContent,jdbcType=VARCHAR}
    where dict_id = #{dictId,jdbcType=VARCHAR}
  </update>
  
  <select id="pageList" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_dict
    order by update_time desc
  </select>

  <select id="queryList" resultMap="BaseResultMap" parameterType="java.lang.String">
    select
    <include refid="Base_Column_List"/>
    from tab_haoban_dict
    WHERE
    status_flag = 1
    AND dict_key in
    <foreach collection="keys" separator="," open="(" close=")" item="item">
      #{item}
    </foreach>
  </select>
    
  <select id="selectByDictKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_dict
    where dict_key = #{dictKey,jdbcType=VARCHAR}
    and status_flag = 1 limit 1
  </select>
  <select id="selectByDictName" resultMap="BaseResultMap" parameterType="java.lang.String">
    select
    <include refid="Base_Column_List"/>
    from tab_haoban_dict
    where dict_name = #{dictName,jdbcType=VARCHAR}
    and status_flag = 1 limit 1
  </select>
</mapper>