ConfigMapper.xml 5.26 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.huaheng.pc.system.config.mapper.ConfigMapper">

    <resultMap type="com.huaheng.pc.system.config.domain.Config" id="ConfigResult">
        <id property="id" column="id"/>
        <result property="configName" column="configName"/>
        <result property="configKey" column="configKey"/>
        <result property="configValue" column="configValue"/>
        <result property="configType" column="configType"/>
        <result property="createBy" column="createBy"/>
        <result property="createTime" column="createTime"/>
        <result property="updateBy" column="updateBy"/>
        <result property="updateTime" column="updateTime"/>
    </resultMap>

    <sql id="selectConfigVo">
        select id,
               configName,
               configKey,
               configValue,
               configType,
               createBy,
               createTime,
               updateBy,
               updateTime,
               remark
        from sys_config
    </sql>

    <!-- 查询条件 -->
    <sql id="sqlwhereSearch">
        <where>
            <if test="id !=null">
                and id = #{id}
            </if>
            <if test="configKey !=null and configKey != ''">
                and configKey = #{configKey}
            </if>
        </where>
    </sql>

    <select id="selectConfig" parameterType="com.huaheng.pc.system.config.domain.Config" resultMap="ConfigResult">
        <include refid="selectConfigVo"/>
        <include refid="sqlwhereSearch"/>
    </select>

    <select id="selectConfigList" parameterType="com.huaheng.pc.system.config.domain.Config" resultMap="ConfigResult">
        <include refid="selectConfigVo"/>
        <where>
            <if test="configName != null and configName != ''">
                AND configName like concat('%', #{configName}, '%')
            </if>
            <if test="configType != null and configType != ''">
                AND configType = #{configType}
            </if>
            <if test="configKey != null and configKey != ''">
                AND configKey like concat('%', #{configKey}, '%')
            </if>
            <if test="params != null and params.beginTime != null"><!-- 开始时间检索 -->
                and date_format(createTime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params != null and params.endTime != null"><!-- 结束时间检索 -->
                and date_format(createTime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
    </select>

    <select id="checkConfigKeyUnique" parameterType="String" resultMap="ConfigResult">
        <include refid="selectConfigVo"/>
        where configKey = #{configKey}
    </select>

    <insert id="insertConfig" parameterType="com.huaheng.pc.system.config.domain.Config">
        insert into sys_config (
        <if test="configName != null and configName != '' ">configName,</if>
        <if test="configKey != null and configKey != '' ">configKey,</if>
        <if test="configValue != null and configValue != '' ">configValue,</if>
        <if test="configType != null and configType != '' ">configType,</if>
        <if test="createBy != null and createBy != ''">createBy,</if>
        <if test="remark != null and remark != ''">remark,</if>
        createTime
        )values(
        <if test="configName != null and configName != ''">#{configName},</if>
        <if test="configKey != null and configKey != ''">#{configKey},</if>
        <if test="configValue != null and configValue != ''">#{configValue},</if>
        <if test="configType != null and configType != ''">#{configType},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        sysdate()
        )
    </insert>

    <update id="updateConfig" parameterType="com.huaheng.pc.system.config.domain.Config">
        update sys_config
        <set>
            <if test="configName != null and configName != ''">configName = #{configName},</if>
            <if test="configKey != null and configKey != ''">configKey = #{configKey},</if>
            <if test="configValue != null and configValue != ''">configValue = #{configValue},</if>
            <if test="configType != null and configType != ''">configType = #{configType},</if>
            <if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
            updateTime = sysdate()
        </set>
        where id = #{id}
    </update>

    <update id="updateConfigByKey" parameterType="com.huaheng.pc.system.config.domain.Config">
        update sys_config
        <set>
            <if test="configValue != null and configValue != ''">configValue = #{configValue},</if>
            updateTime = sysdate()
        </set>
        where configKey = #{configKey}
    </update>

    <delete id="deleteConfigByIds" parameterType="String">
        delete from sys_config where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>