<?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.ruoyi.bussiness.mapper.TSecondPeriodConfigMapper">
    
    <resultMap type="TSecondPeriodConfig" id="TSecondPeriodConfigResult">
        <result property="id"    column="id"    />
        <result property="secondId"    column="second_id"    />
        <result property="period"    column="period"    />
        <result property="odds"    column="odds"    />
        <result property="maxAmount"    column="max_amount"    />
        <result property="minAmount"    column="min_amount"    />
        <result property="status"    column="status"    />
        <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="remark"    column="remark"    />
        <result property="flag"    column="flag"    />
        <result property="searchValue"    column="search_value"    />
    </resultMap>

    <sql id="selectTSecondPeriodConfigVo">
        select id, second_id, period, odds, max_amount, min_amount, status, create_by, create_time, update_by, update_time, remark, search_value ,flag from t_second_period_config
    </sql>

    <select id="selectTSecondPeriodConfigList" parameterType="TSecondPeriodConfig" resultMap="TSecondPeriodConfigResult">
        <include refid="selectTSecondPeriodConfigVo"/>
        <where>  
            <if test="secondId != null "> and second_id = #{secondId}</if>
            <if test="period != null "> and period = #{period}</if>
            <if test="odds != null "> and odds = #{odds}</if>
            <if test="maxAmount != null "> and max_amount = #{maxAmount}</if>
            <if test="minAmount != null "> and min_amount = #{minAmount}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="flag != null "> and flag = #{flag}</if>
            <if test="searchValue != null  and searchValue != ''"> and search_value = #{searchValue}</if>
        </where>
    </select>
    
    <select id="selectTSecondPeriodConfigById" parameterType="Long" resultMap="TSecondPeriodConfigResult">
        <include refid="selectTSecondPeriodConfigVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSecondPeriodConfig" parameterType="TSecondPeriodConfig">
        insert into t_second_period_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="secondId != null">second_id,</if>
            <if test="period != null">period,</if>
            <if test="odds != null">odds,</if>
            <if test="maxAmount != null">max_amount,</if>
            <if test="minAmount != null">min_amount,</if>
            <if test="status != null">status,</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="remark != null">remark,</if>
            <if test="searchValue != null">search_value,</if>
            <if test="flag != null">flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="secondId != null">#{secondId},</if>
            <if test="period != null">#{period},</if>
            <if test="odds != null">#{odds},</if>
            <if test="maxAmount != null">#{maxAmount},</if>
            <if test="minAmount != null">#{minAmount},</if>
            <if test="status != null">#{status},</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="remark != null">#{remark},</if>
            <if test="searchValue != null">#{searchValue},</if>
            <if test="flag != null">#{flag},</if>
         </trim>
    </insert>

    <update id="updateTSecondPeriodConfig" parameterType="TSecondPeriodConfig">
        update t_second_period_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="secondId != null">second_id = #{secondId},</if>
            <if test="period != null">period = #{period},</if>
            <if test="odds != null">odds = #{odds},</if>
            <if test="maxAmount != null">max_amount = #{maxAmount},</if>
            <if test="minAmount != null">min_amount = #{minAmount},</if>
            <if test="status != null">status = #{status},</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="remark != null">remark = #{remark},</if>
            <if test="searchValue != null">search_value = #{searchValue},</if>
            <if test="flag != null">flag = #{flag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTSecondPeriodConfigById" parameterType="Long">
        delete from t_second_period_config where id = #{id}
    </delete>

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