<?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.system.mapper.projectV2.common.SendSmsConfigMapper">
    
    <resultMap type="com.ruoyi.system.domain.projectV2.common.SendSmsConfig" id="SendSmsConfigResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="name"    column="name"    />
        <result property="phone"    column="phone"    />
        <result property="progress"    column="progress"    />
        <result property="modifyDate"    column="modify_date"    />
        <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="selectSendSmsConfigVo">
        select id, user_id,dept_id, name, phone, progress, modify_date, create_by, create_time, update_by, update_time, is_del from send_sms_config
    </sql>

    <select id="selectSendSmsConfigList" parameterType="SendSmsConfig" resultMap="SendSmsConfigResult">
        <include refid="selectSendSmsConfigVo"/>
        <where>
            is_del = 'N'
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="progress != null  and progress != ''"> and progress = #{progress}</if>
            <if test="modifyDate != null  and modifyDate != ''"> and modify_date = #{modifyDate}</if>
        </where>
    </select>
    
    <select id="selectSendSmsConfigById" parameterType="Long" resultMap="SendSmsConfigResult">
        <include refid="selectSendSmsConfigVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSendSmsConfig" parameterType="SendSmsConfig" useGeneratedKeys="true" keyProperty="id">
        insert into send_sms_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="progress != null and progress != ''">progress,</if>
            <if test="modifyDate != null">modify_date,</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 and isDel != ''">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="progress != null and progress != ''">#{progress},</if>
            <if test="modifyDate != null">#{modifyDate},</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 and isDel != ''">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateSendSmsConfig" parameterType="SendSmsConfig">
        update send_sms_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="progress != null and progress != ''">progress = #{progress},</if>
            <if test="modifyDate != null">modify_date = #{modifyDate},</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 and isDel != ''">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSendSmsConfigById" parameterType="Long">
        delete from send_sms_config where id = #{id}
    </delete>

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