DictionaryDataMapper.xml 5.79 KB
<?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.glsx.manager.mapper.DictionaryDataMapper">
  <resultMap id="baseResultMap" type="com.glsx.manager.pojo.dictionary.DictionaryData">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="dict_type" jdbcType="VARCHAR" property="dictType" />
    <result column="data_value" jdbcType="VARCHAR" property="dataValue" />
	<result column="data_key" jdbcType="VARCHAR" property="dataKey" />
	<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
	<result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  
  <sql id="base_Column">
    id, dict_type, data_value, data_key, data_status, sort, remark, create_by, create_time, update_by, update_time
  </sql>
  
  <select id="get" parameterType="java.lang.Integer" resultMap="baseResultMap">
    select 
    <include refid="base_Column" />
    from sys_dict_data
    <where>
    	<if test="id != null">
	    	id = #{id,jdbcType=INTEGER}
    	</if>
    	<if test="dataKey !=null and dataKey != ''">
    		and data_key = #{dataKey}
    	</if>
    	<if test="dictType != null and dictType != ''">
    		and dict_type = #{dictType}
    	</if>
    </where>
  </select>
  
  <select id="list" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData" resultMap="baseResultMap">
  	<if test="dataValue != null and dataValue != ''">
	  	<bind name="pattern" value="'%' + dataValue + '%'" />
  	</if>
    select
    	sdd.id, sdd.dict_type, sdd.data_value, sdd.data_key, sdd.data_status, 
    	sdd.sort, sdd.remark, sdd.create_by, sdd.create_time, sdd.update_by, 
    	sdd.update_time
    from sys_dict_data sdd
    	left join sys_dict_type sdt on sdd.dict_type = sdt.dict_type
    <where>
      sdd.data_status != 3
      <if test="name != null">
        and sdt.name = #{name}
      </if>
      <if test="dictType != null">
        and sdd.dict_type = #{dictType}
      </if>
      <if test="dataValue != null and dataValue != ''">
        and sdd.data_value like #{pattern}
      </if>
      <if test="dataStatus != null">
        and sdd.data_status = #{dataStatus} 
      </if>
      <if test="beginDate != null and beginDate!= ''">
        and DATE_FORMAT(sdd.create_time, '%Y-%m-%d') &gt;= #{beginDate}
      </if>
      <if test="endDate != null and endDate != ''">
        and DATE_FORMAT(sdd.create_time, '%Y-%m-%d') &lt;= #{endDate}
      </if>
      order by sdd.sort asc, sdd.create_time asc
    </where>
  </select>
  
  <insert id="save" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData" useGeneratedKeys="true">
    insert into sys_dict_data
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="dictType != null">
        dict_type,
      </if>
      <if test="dataValue != null and dataValue != ''">
        data_value,
      </if>
      <if test="dataKey != null and dataKey != ''">
        data_key,
      </if>
      <if test="dataStatus != null">
        data_status,
      </if>
      <if test="sort != null">
        sort,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
     <if test="dictType != null and dictType != ''">
        #{dictType},
      </if>
      <if test="dataValue != null and dataValue!= ''">
        #{dataValue},
      </if>
      <if test="dataKey != null and dataKey != ''">
        #{dataKey},
      </if>
      <if test="dataStatus != null">
        #{dataStatus},
      </if>
      <if test="sort != null">
        #{sort},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  
  <update id="update" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
    update sys_dict_data
    set 
      data_key = #{dataKey},
      data_value = #{dataValue,jdbcType=VARCHAR},
      data_status = #{dataStatus,jdbcType=TINYINT},
      sort = #{sort},
      remark = #{remark,jdbcType=VARCHAR},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
   <delete id="delete" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
    update sys_dict_data 
    set data_status = 3,
    update_by = #{updateBy},
    update_time = #{updateTime}
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByDictType" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
    update sys_dict_data 
    set data_status = 3,
    update_by = #{updateBy},
    update_time = #{updateTime}
    where dict_type = #{dictType}
  </delete>
</mapper>