<?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.zehong.system.mapper.system.SysSettingMapper">
    
    <resultMap type="SysSetting" id="SysSettingResult">
        <result property="systemId"    column="system_id"    />
        <result property="systemName"    column="system_name"    />
        <result property="systemKey"    column="system_key"    />
        <result property="systemValue"    column="system_value"    />
        <result property="systemType"    column="system_type"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectSysSettingVo">
        select system_id, system_name, system_key, system_value, system_type, create_by, create_time, update_by, update_time, is_del from sys_setting
    </sql>

    <select id="selectSysSettingList" parameterType="SysSetting" resultMap="SysSettingResult">
        <include refid="selectSysSettingVo"/>
        <where>  
            <if test="systemName != null  and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
            <if test="systemKey != null  and systemKey != ''"> and system_key = #{systemKey}</if>
            <if test="systemValue != null  and systemValue != ''"> and system_value = #{systemValue}</if>
            <if test="systemType != null  and systemType != ''"> and system_type = #{systemType}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectSysSettingById" parameterType="Integer" resultMap="SysSettingResult">
        <include refid="selectSysSettingVo"/>
        where system_id = #{systemId}
    </select>
        
    <insert id="insertSysSetting" parameterType="SysSetting" useGeneratedKeys="true" keyProperty="systemId">
        insert into sys_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="systemName != null">system_name,</if>
            <if test="systemKey != null">system_key,</if>
            <if test="systemValue != null">system_value,</if>
            <if test="systemType != null">system_type,</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>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="systemName != null">#{systemName},</if>
            <if test="systemKey != null">#{systemKey},</if>
            <if test="systemValue != null">#{systemValue},</if>
            <if test="systemType != null">#{systemType},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateSysSetting" parameterType="SysSetting">
        update sys_setting
        <trim prefix="SET" suffixOverrides=",">
            <if test="systemName != null">system_name = #{systemName},</if>
            <if test="systemKey != null">system_key = #{systemKey},</if>
            <if test="systemValue != null">system_value = #{systemValue},</if>
            <if test="systemType != null">system_type = #{systemType},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where system_id = #{systemId}
    </update>

    <delete id="deleteSysSettingById" parameterType="Integer">
        delete from sys_setting where system_id = #{systemId}
    </delete>

    <delete id="deleteSysSettingByIds" parameterType="String">
        delete from sys_setting where system_id in 
        <foreach item="systemId" collection="array" open="(" separator="," close=")">
            #{systemId}
        </foreach>
    </delete>
</mapper>