ConfigMapper.xml 3.9 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="cn.com.glsx.dj.system.mapper.ConfigMapper" >
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.system.model.Config" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="conf_name" property="confName" jdbcType="VARCHAR" />
    <result column="conf_key" property="confKey" jdbcType="VARCHAR" />
    <result column="conf_value" property="confValue" jdbcType="VARCHAR" />
    <result column="conf_group" property="confGroup" jdbcType="VARCHAR" />
    <result column="conf_default" property="confDefault" jdbcType="CHAR" />
    <result column="conf_description" property="confDescription"/>
    <result column="conf_order" property="confOrder" jdbcType="SMALLINT" />
    <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
    <result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
    <result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
    <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
    <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, conf_name, conf_key, conf_value, conf_group, conf_default,conf_description, conf_order, created_by,
    created_date, updated_by, updated_date, deleted_flag
  </sql>
  
  <select id="list" parameterType="cn.com.glsx.dj.system.dto.ConfigDTO" resultMap="BaseResultMap">
  	select <include refid="Base_Column_List"/> from dj_system_configure
  	<where>
  		deleted_flag='N'
  		<if test="confName != null and confName !=''">
  			and conf_name = #{confName}
  		</if>
  		<if test="confKey != null and confKey !=''">
  			and conf_key = #{confKey}
  		</if>
  		<if test="confValue != null and confValue !=''">
  			and conf_value = #{confValue}
  		</if>
  		<if test="confGroup != null and confGroup !=''">
  			and conf_group = #{confGroup}
  		</if>
  		<if test="confDefault != null and confDefault !=''">
  			and conf_default = #{confDefault}
  		</if>
  		<if test="confGroupList != null and confGroupList.size() > 0">
  			and conf_group in 
  			<foreach collection="confGroupList" index="index" item="item" open="(" separator="," close=")">
                #{item}       
        	</foreach>  
  		</if>
  		<if test="confKeyList != null and confKeyList.size() > 0">
  			and conf_key in 
  			<foreach collection="confKeyList" index="index" item="item" open="(" separator="," close=")">
                #{item}       
        	</foreach>  
  		</if>
  	</where>
  	order by conf_order desc
  </select>

    <update id="updateConfig" parameterType="cn.com.glsx.dj.system.model.Config">
        UPDATE dj_system_configure
        <set>
        <if test="confValue != null and confValue !=''">
            conf_value = #{confValue},
        </if>
        <if test="confName != null and confName !=''">
             conf_name = #{confName},
        </if>
        <if test="confGroup != null and confGroup !=''">
             conf_group = #{confGroup},
        </if>
        <if test="confDefault != null and confDefault !=''">
             conf_default = #{confDefault},
        </if>
        <if test="updatedDate != null">
             updated_date = #{updatedDate},
        </if>
        </set>
        where conf_key = #{confKey}
    </update>
    
    <update id="deleteByGroupAndNotInKeys" parameterType="cn.com.glsx.dj.system.dto.ConfigDTO">
    	update dj_system_configure set deleted_flag='D',updated_date=#{updatedDate},updated_by=#{updatedBy}
    	where deleted_flag='N' and conf_group=#{confGroup} 
    	<if test="confKeyList != null and confKeyList.size() > 0">
    		and conf_key not in 
    		<foreach collection="confKeyList" index="index" item="item" open="(" separator="," close=")">
         		#{item}       
        	</foreach>  
    	</if>
    </update>
</mapper>