<?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.SendSmsMapper">
    
    <resultMap type="com.ruoyi.system.domain.projectV2.common.SendSms" id="SendSmsResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="phone"    column="phone"    />
        <result property="status"    column="status"    />
        <result property="content"    column="content"    />
        <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="selectSendSmsVo">
        select id, name, phone, status, content, modify_date, create_by, create_time, update_by, update_time, is_del from send_sms
    </sql>

    <select id="selectSendSmsList" parameterType="com.ruoyi.system.domain.projectV2.common.SendSms" resultMap="SendSmsResult">
        <include refid="selectSendSmsVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
    </select>
    
    <select id="selectSendSmsById" parameterType="Long" resultMap="SendSmsResult">
        <include refid="selectSendSmsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSendSms" parameterType="com.ruoyi.system.domain.projectV2.common.SendSms" useGeneratedKeys="true" keyProperty="id">
        insert into send_sms
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="phone != null">phone,</if>
            <if test="status != null">status,</if>
            <if test="content != null">content,</if>
            <if test="modifyDate != null">modify_date,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null and isDel != ''">is_del,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="phone != null">#{phone},</if>
            <if test="status != null">#{status},</if>
            <if test="content != null">#{content},</if>
            <if test="modifyDate != null">#{modifyDate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null and isDel != ''">#{isDel},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateSendSms" parameterType="com.ruoyi.system.domain.projectV2.common.SendSms">
        update send_sms
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="status != null">status = #{status},</if>
            <if test="content != null">content = #{content},</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="deleteSendSmsById" parameterType="Long">
        delete from send_sms where id = #{id}
    </delete>

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