<?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.ssm.manage.mapper.SmsFixMapper">

    <resultMap type="com.ssm.manage.entity.SmsFix" id="baseMap">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="storeId" column="store_id" jdbcType="BIGINT"/>
        <result property="inputId" column="input_id" jdbcType="BIGINT"/>
        <result property="inputDate" column="input_date" jdbcType="TIMESTAMP"/>
        <result property="updateId" column="update_id" jdbcType="BIGINT"/>
        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
        <result property="inputName" column="input_name" jdbcType="VARCHAR"/>
        <result property="updateName" column="update_name" jdbcType="VARCHAR"/>
        <result property="auitId" column="auit_id" jdbcType="BIGINT"/>
        <result property="auitName" column="auit_name" jdbcType="VARCHAR"/>
        <result property="auitDate" column="auit_date" jdbcType="TIMESTAMP"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="smsBody" column="sms_body" jdbcType="LONGVARCHAR"/>

    </resultMap>
    <delete id="deleteById">
        delete from sms_fix where id = #{id}
    </delete>

    <select id="selectBystoreId" resultMap="baseMap">
        select * from sms_fix where <if test="storeId!=null"> store_id = #{storeId}</if>
    </select>

    <select id="pageByPingTai" resultMap="baseMap">
        select * from sms_fix where state in (1,2,3)  <if test="storeId!=null"> and store_id = #{storeId}</if>
    </select>

    <select id="selectByTypeAndStoreId" resultMap="baseMap">
        select * from sms_fix where store_id = #{storeId} and state = 2 and type in <foreach collection="types" item="item" separator="," open="(" close=")">
        #{item}
    </foreach>

    </select>

    <update id="updateUnAudit">
        update sms_fix set auit_id = null ,auit_name = null ,auit_date = null , state = 3 where id = #{id}
    </update>
    <update id="unAudit" parameterType="com.ssm.manage.entity.SmsFix">
        update sms_fix set auit_id = null ,auit_name = null ,auit_date = null , state = 3 where type = #{type} and state = 2 and store_id = #{storeId}
    </update>
    <update id="updateBySmsFix" parameterType="com.ssm.manage.entity.SmsFix">
        update sms_fix set
        <if test="storeId != null">store_id = #{storeId}, </if>
        <if test="inputId != null">input_id = #{inputId}, </if>
        <if test="inputDate != null">input_date = #{inputDate}, </if>
        <if test="inputName != null">input_name = #{inputName}, </if>
        <if test="updateId != null">update_id = #{updateId}, </if>
        <if test="updateName != null">update_name = #{updateName}, </if>
        <if test="updateDate != null">update_date = #{updateDate}, </if>
        <if test="auitId != null" >auit_id = #{auitId}, </if>
        <if test="auitName != null">auit_name = #{auitName}, </if>
        <if test="auitDate != null">auit_date = #{auitDate}, </if>
        <if test="type != null"> type = #{type}, </if>
        <if test="smsBody != null">sms_body = #{smsBody}, </if>
        <if test="state != null">state = #{state}</if>
    where  1=1
        <if test="storeId != null">and store_id = #{storeId}  </if>
        <if test="id != null">and id = #{id}</if>

    </update>

</mapper>

