<?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.dgtly.system.mapper.SysThemeInfoMapper">
    
    <resultMap type="SysThemeInfo" id="SysThemeInfoResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="userId"    />
        <result property="bgColorIndex"    column="bgColorIndex"    />
        <result property="bgImgIndex"    column="bgImgIndex"    />
        <result property="hideImg"    column="hideImg"    />
    </resultMap>

    <sql id="selectSysThemeInfoVo">
        select id, userId, bgColorIndex, bgImgIndex,hideImg from sys_theme_info
    </sql>

    <select id="selectSysThemeInfoList" parameterType="SysThemeInfo" resultMap="SysThemeInfoResult">
        <include refid="selectSysThemeInfoVo"/>
        <where>  
            <if test="userId != null  and userId != ''"> and userId = #{userId}</if>
            <if test="bgColorIndex != null  and bgColorIndex != ''"> and bgColorIndex = #{bgColorIndex}</if>
            <if test="bgImgIndex != null  and bgImgIndex != ''"> and bgImgIndex = #{bgImgIndex}</if>
            <if test="hideImg != null  and hideImg != ''"> and hideImg = #{hideImg}</if>
        </where>
    </select>
    
    <select id="selectSysThemeInfoById" parameterType="Long" resultMap="SysThemeInfoResult">
        <include refid="selectSysThemeInfoVo"/>
        where id = #{id}
    </select>
    <select id="selectSysThemeInfoByUserId" parameterType="Long" resultMap="SysThemeInfoResult">
        <include refid="selectSysThemeInfoVo"/>
        where userId = #{userId}
    </select>
        
    <insert id="insertSysThemeInfo" parameterType="SysThemeInfo" useGeneratedKeys="true" keyProperty="id">
        insert into sys_theme_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null  and userId != ''">userId,</if>
            <if test="bgColorIndex != null  and bgColorIndex != ''">bgColorIndex,</if>
            <if test="bgImgIndex != null  and bgImgIndex != ''">bgImgIndex,</if>
            <if test="hideImg != null  and hideImg != ''">hideImg,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null  and userId != ''">#{userId},</if>
            <if test="bgColorIndex != null  and bgColorIndex != ''">#{bgColorIndex},</if>
            <if test="bgImgIndex != null  and bgImgIndex != ''">#{bgImgIndex},</if>
            <if test="hideImg != null  and hideImg != ''">#{hideImg},</if>
         </trim>
    </insert>

    <update id="updateSysThemeInfo" parameterType="SysThemeInfo">
        update sys_theme_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null  and userId != ''">userId = #{userId},</if>
            <if test="bgColorIndex != null  and bgColorIndex != ''">bgColorIndex = #{bgColorIndex},</if>
            <if test="bgImgIndex != null  and bgImgIndex != ''">bgImgIndex = #{bgImgIndex},</if>
            <if test="hideImg != null  and hideImg != ''">hideImg = #{hideImg},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysThemeInfoById" parameterType="Long">
        delete from sys_theme_info where id = #{id}
    </delete>

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