<?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.voluntary.mapper.BusiScoreLockMapper">

    <resultMap type="BusiScoreLock" id="BusiScoreLockResult">
        <result property="id"    column="id"    />
        <result property="provinceName"    column="province_name"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="isValid"    column="is_valid"    />
        <result property="isMock"    column="is_mock"    />
    </resultMap>

    <sql id="selectBusiScoreLockVo">
        select id, province_name, start_date, end_date, is_valid, is_mock from b_busi_score_lock
    </sql>

    <select id="selectBusiScoreLockList" parameterType="BusiScoreLock" resultMap="BusiScoreLockResult">
        <include refid="selectBusiScoreLockVo"/>
        <where>
            <if test="provinceName != null  and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
            <if test="startDate != null  and startDate != ''"> and start_date = #{startDate}</if>
            <if test="endDate != null  and endDate != ''"> and end_date = #{endDate}</if>
            <if test="isValid != null "> and is_valid = #{isValid}</if>
            <if test="isMock != null "> and is_mock = #{isMock}</if>
        </where>
    </select>

    <select id="selectBusiScoreLockById" parameterType="Long" resultMap="BusiScoreLockResult">
        <include refid="selectBusiScoreLockVo"/>
        where id = #{id}
    </select>

    <select id="selectBusiScoreLockByProvinceName" parameterType="String" resultMap="BusiScoreLockResult">
        <include refid="selectBusiScoreLockVo"/>
        where province_name = #{provinceName}
    </select>

    <insert id="insertBusiScoreLock" parameterType="BusiScoreLock" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_score_lock
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="provinceName != null">province_name,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="isValid != null">is_valid,</if>
            <if test="isMock != null">is_mock,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="provinceName != null">#{provinceName},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="isValid != null">#{isValid},</if>
            <if test="isMock != null">#{isMock},</if>
        </trim>
    </insert>

    <update id="updateBusiScoreLock" parameterType="BusiScoreLock">
        update b_busi_score_lock
        <trim prefix="SET" suffixOverrides=",">
            <if test="provinceName != null">province_name = #{provinceName},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="isValid != null">is_valid = #{isValid},</if>
            <if test="isMock != null">is_mock = #{isMock},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiScoreLockById" parameterType="Long">
        delete from b_busi_score_lock where id = #{id}
    </delete>

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