<?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.ssm.mapper.system.SysDictionaryMapper" >
  <resultMap id="BaseResultMap" type="com.ssm.model.system.SysDictionary" >
    <id column="DictID" property="dictid" jdbcType="INTEGER" />
    <result column="IsActive" property="isactive" jdbcType="BIT" />
    <result column="CreatedUserID" property="createduserid" jdbcType="INTEGER" />
    <result column="CreatedDatetime" property="createddatetime" jdbcType="TIMESTAMP" />
    <result column="LastUpdateUserID" property="lastupdateuserid" jdbcType="INTEGER" />
    <result column="LastUpdateDatetime" property="lastupdatedatetime" jdbcType="TIMESTAMP" />
    <result column="Subitems" property="subitems" jdbcType="INTEGER" />
    <result column="DictValue" property="dictvalue" jdbcType="CLOB" />
    <result column="DictName" property="dictname" jdbcType="CLOB" />
    <result column="DictNameEN" property="dictnameen" jdbcType="CLOB" />
    <result column="DictMemo" property="dictmemo" jdbcType="CLOB" />
    <result column="NameSpace" property="namespace" jdbcType="CLOB" />
  </resultMap>
  <sql id="Base_Column_List" >
    DictID, IsActive, CreatedUserID, CreatedDatetime, LastUpdateUserID, LastUpdateDatetime, 
    Subitems
  </sql>
  <sql id="Blob_Column_List" >
    DictValue, DictName, DictNameEN, DictMemo, NameSpace
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from SysDictionary
    where DictID = #{dictid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from SysDictionary
    where DictID = #{dictid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.ssm.model.system.SysDictionary" >
    insert into SysDictionary (DictID, IsActive, CreatedUserID, 
      CreatedDatetime, LastUpdateUserID, LastUpdateDatetime, 
      Subitems, DictValue, DictName, 
      DictNameEN, DictMemo, NameSpace
      )
    values (#{dictid,jdbcType=INTEGER}, #{isactive,jdbcType=BIT}, #{createduserid,jdbcType=INTEGER}, 
      #{createddatetime,jdbcType=TIMESTAMP}, #{lastupdateuserid,jdbcType=INTEGER}, #{lastupdatedatetime,jdbcType=TIMESTAMP}, 
      #{subitems,jdbcType=INTEGER}, #{dictvalue,jdbcType=CLOB}, #{dictname,jdbcType=CLOB}, 
      #{dictnameen,jdbcType=CLOB}, #{dictmemo,jdbcType=CLOB}, #{namespace,jdbcType=CLOB}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.ssm.model.system.SysDictionary" >
    insert into SysDictionary
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="dictid != null" >
        DictID,
      </if>
      <if test="isactive != null" >
        IsActive,
      </if>
      <if test="createduserid != null" >
        CreatedUserID,
      </if>
      <if test="createddatetime != null" >
        CreatedDatetime,
      </if>
      <if test="lastupdateuserid != null" >
        LastUpdateUserID,
      </if>
      <if test="lastupdatedatetime != null" >
        LastUpdateDatetime,
      </if>
      <if test="subitems != null" >
        Subitems,
      </if>
      <if test="dictvalue != null" >
        DictValue,
      </if>
      <if test="dictname != null" >
        DictName,
      </if>
      <if test="dictnameen != null" >
        DictNameEN,
      </if>
      <if test="dictmemo != null" >
        DictMemo,
      </if>
      <if test="namespace != null" >
        NameSpace,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="dictid != null" >
        #{dictid,jdbcType=INTEGER},
      </if>
      <if test="isactive != null" >
        #{isactive,jdbcType=BIT},
      </if>
      <if test="createduserid != null" >
        #{createduserid,jdbcType=INTEGER},
      </if>
      <if test="createddatetime != null" >
        #{createddatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastupdateuserid != null" >
        #{lastupdateuserid,jdbcType=INTEGER},
      </if>
      <if test="lastupdatedatetime != null" >
        #{lastupdatedatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="subitems != null" >
        #{subitems,jdbcType=INTEGER},
      </if>
      <if test="dictvalue != null" >
        #{dictvalue,jdbcType=CLOB},
      </if>
      <if test="dictname != null" >
        #{dictname,jdbcType=CLOB},
      </if>
      <if test="dictnameen != null" >
        #{dictnameen,jdbcType=CLOB},
      </if>
      <if test="dictmemo != null" >
        #{dictmemo,jdbcType=CLOB},
      </if>
      <if test="namespace != null" >
        #{namespace,jdbcType=CLOB},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.ssm.model.system.SysDictionary" >
    update SysDictionary
    <set >
      <if test="isactive != null" >
        IsActive = #{isactive,jdbcType=BIT},
      </if>
      <if test="createduserid != null" >
        CreatedUserID = #{createduserid,jdbcType=INTEGER},
      </if>
      <if test="createddatetime != null" >
        CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastupdateuserid != null" >
        LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
      </if>
      <if test="lastupdatedatetime != null" >
        LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="subitems != null" >
        Subitems = #{subitems,jdbcType=INTEGER},
      </if>
      <if test="dictvalue != null" >
        DictValue = #{dictvalue,jdbcType=CLOB},
      </if>
      <if test="dictname != null" >
        DictName = #{dictname,jdbcType=CLOB},
      </if>
      <if test="dictnameen != null" >
        DictNameEN = #{dictnameen,jdbcType=CLOB},
      </if>
      <if test="dictmemo != null" >
        DictMemo = #{dictmemo,jdbcType=CLOB},
      </if>
      <if test="namespace != null" >
        NameSpace = #{namespace,jdbcType=CLOB},
      </if>
    </set>
    where DictID = #{dictid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ssm.model.system.SysDictionary" >
    update SysDictionary
    set IsActive = #{isactive,jdbcType=BIT},
      CreatedUserID = #{createduserid,jdbcType=INTEGER},
      CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
      LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
      LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
      Subitems = #{subitems,jdbcType=INTEGER},
      DictValue = #{dictvalue,jdbcType=CLOB},
      DictName = #{dictname,jdbcType=CLOB},
      DictNameEN = #{dictnameen,jdbcType=CLOB},
      DictMemo = #{dictmemo,jdbcType=CLOB},
      NameSpace = #{namespace,jdbcType=CLOB}
    where DictID = #{dictid,jdbcType=INTEGER}
  </update>
  <select id="selectByNamespace" resultMap="BaseResultMap" parameterType="java.lang.String" >
  	SELECT * from SysDictionary s where s.NameSpace=#{namespace}
  </select>
  <select id="selectByEnabledNamespace" resultMap="BaseResultMap" parameterType="java.lang.String" >
  	SELECT * from SysDictionary s where s.NameSpace=#{namespace} and s.isactive = 1
  </select>
  <select id="selectConstCategory" resultMap="BaseResultMap" >
  	SELECT * from SysDictionary s where s.NameSpace='const_category' 
	ORDER BY s.DictID
  </select>
  <select id="selectByCondition" parameterType="com.ssm.model.system.SysDictionary"  resultMap="BaseResultMap">
  	SELECT * from SysDictionary where 1= 1
  	<if test="namespace != null" >
     and   NameSpace = #{namespace,jdbcType=CLOB}
    </if>
    <if test="dictname != null" >
      and  DictName LIKE  CONCAT('%',#{dictname,jdbcType=CLOB},'%')
     
    </if>
    <if test="dictvalue != null" >
     and   DictValue LIKE CONCAT('%',#{dictvalue,jdbcType=CLOB},'%')
     
     
    </if>
    order by dictid asc
  </select>
  <select id="selectByCondition2" parameterType="com.ssm.model.system.SysDictionary"  resultMap="BaseResultMap">
  	SELECT * from SysDictionary where 1= 1 and   NameSpace != 'CONST_CATEGORY'
  	<if test="namespace != null" >
     and   NameSpace = #{namespace,jdbcType=CLOB}
    </if>
    <if test="dictname != null" >
      and  DictName LIKE  CONCAT('%',#{dictname,jdbcType=CLOB},'%')
      
    </if>
    order by dictid asc
  </select>
  <select id="selectByNamespaceAndValue" resultMap="BaseResultMap" parameterType="java.lang.String">
  		SELECT * from SysDictionary s where s.NameSpace=#{namespace}  AND s.DictValue=#{value}
  </select>
</mapper>