<?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.xinelu.manage.mapper.systemsettingsinfo.SystemSettingsInfoMapper">

    <resultMap type="SystemSettingsInfo" id="SystemSettingsInfoResult">
        <result property="id" column="id"/>
        <result property="settingsName" column="settings_name"/>
        <result property="settingsCode" column="settings_code"/>
        <result property="settingsContent" column="settings_content"/>
        <result property="settingsType" column="settings_type"/>
        <result property="totalSignInDays" column="total_sign_in_days"/>
        <result property="integralCount" column="integral_count"/>
        <result property="creditAmount" column="credit_amount"/>
        <result property="integralExpirationDate" column="integral_expiration_date"/>
        <result property="sort" column="sort"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectSystemSettingsInfoVo">
        select id,
               settings_name,
               settings_code,
               settings_content,
               settings_type,
               total_sign_in_days,
               integral_count,
               credit_amount,
               integral_expiration_date,
               sort,
               create_by,
               create_time,
               update_by,
               update_time
        from system_settings_info
    </sql>

    <select id="selectSystemSettingsInfoList" parameterType="SystemSettingsInfo" resultMap="SystemSettingsInfoResult">
        <include refid="selectSystemSettingsInfoVo"/>
        <where>
            <if test="settingsName != null  and settingsName != ''">
                and settings_name like concat('%', #{settingsName}, '%')
            </if>
            <if test="settingsCode != null  and settingsCode != ''">
                and settings_code = #{settingsCode}
            </if>
            <if test="settingsContent != null  and settingsContent != ''">
                and settings_content = #{settingsContent}
            </if>
            <if test="settingsType != null  and settingsType != ''">
                and settings_type = #{settingsType}
            </if>
            <if test="totalSignInDays != null ">
                and total_sign_in_days = #{totalSignInDays}
            </if>
            <if test="integralCount != null ">
                and integral_count = #{integralCount}
            </if>
            <if test="creditAmount != null ">
                and credit_amount = #{creditAmount}
            </if>
            <if test="sort != null ">
                and sort = #{sort}
            </if>
        </where>
    </select>

    <select id="selectSystemSettingsInfoById" parameterType="Long"
            resultMap="SystemSettingsInfoResult">
        <include refid="selectSystemSettingsInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertSystemSettingsInfo" parameterType="SystemSettingsInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into system_settings_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="settingsName != null">settings_name,
            </if>
            <if test="settingsCode != null">settings_code,
            </if>
            <if test="settingsContent != null">settings_content,
            </if>
            <if test="settingsType != null">settings_type,
            </if>
            <if test="totalSignInDays != null">total_sign_in_days,
            </if>
            <if test="integralCount != null">integral_count,
            </if>
            <if test="creditAmount != null">credit_amount,
            </if>
            <if test="integralExpirationDate != null">integral_expiration_date,
            </if>
            <if test="sort != null">sort,
            </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="settingsName != null">#{settingsName},
            </if>
            <if test="settingsCode != null">#{settingsCode},
            </if>
            <if test="settingsContent != null">#{settingsContent},
            </if>
            <if test="settingsType != null">#{settingsType},
            </if>
            <if test="totalSignInDays != null">#{totalSignInDays},
            </if>
            <if test="integralCount != null">#{integralCount},
            </if>
            <if test="creditAmount != null">#{creditAmount},
            </if>
            <if test="integralExpirationDate != null">#{integralExpirationDate},
            </if>
            <if test="sort != null">#{sort},
            </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>
        </trim>
    </insert>

    <update id="updateSystemSettingsInfo" parameterType="SystemSettingsInfo">
        update system_settings_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="settingsName != null">settings_name =
                #{settingsName},
            </if>
            <if test="settingsCode != null">settings_code =
                #{settingsCode},
            </if>
            settings_content = #{settingsContent},
            <if test="settingsType != null">settings_type =
                #{settingsType},
            </if>
            <if test="totalSignInDays != null">total_sign_in_days =
                #{totalSignInDays},
            </if>
            <if test="integralCount != null">integral_count =
                #{integralCount},
            </if>
            <if test="creditAmount != null">credit_amount =
                #{creditAmount},
            </if>
            <if test="integralExpirationDate != null">integral_expiration_date =
                #{integralExpirationDate},
            </if>
            <if test="sort != null">sort =
                #{sort},
            </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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSystemSettingsInfoById" parameterType="Long">
        delete
        from system_settings_info
        where id = #{id}
    </delete>

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

    <select id="selectSystemSettingsInfoByCount" resultType="int">
        select COUNT(1) from system_settings_info
        <where>
            <if test="settingsType != null  and settingsType != ''">
                and settings_type = #{settingsType}
            </if>
        </where>
    </select>

    <select id="getSystemSettingsInfoByType" parameterType="string"
            resultMap="SystemSettingsInfoResult">
        <include refid="selectSystemSettingsInfoVo"/>
        where settings_type = #{settingType}
    </select>
</mapper>
