<?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.xhpc.general.mapper.XhpcSmsMapper">

    <resultMap id="BaseResultMap" type="com.xhpc.general.domain.XhpcSms">
        <result property="smsId" column="sms_id"/>
        <result property="phone" column="phone"/>
        <result property="code" column="code"/>
        <result property="templateId" column="template_id"/>
        <result property="accessKey" column="access_key"/>
        <result property="secretKey" column="secret_key"/>
        <result property="regionId" column="region_id"/>
        <result property="content" column="content"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="remark" column="remark"/>
    </resultMap>
    <!-- 通用查询映射结果 -->


    <insert id="addXhpcSms" parameterType="com.xhpc.general.domain.XhpcSms"
            useGeneratedKeys="true" keyProperty="smsId">
        insert into xhpc_sms
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="null != phone ">
                phone,
            </if>
            <if test="null != code ">
                code,
            </if>
            <if test="null != content ">
                content,
            </if>
            <if test="null != status ">
                status,
            </if>
            <if test="null != delFlag ">
                del_flag,
            </if>
            <if test="null != createTime ">
                create_time,
            </if>
            <if test="null != createBy and '' != createBy">
                create_by,
            </if>
            <if test="null != updateTime ">
                update_time,
            </if>
            <if test="null != updateBy and '' != updateBy">
                update_by,
            </if>
            <if test="null != remark and '' != remark">
                remark
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="null != phone ">
                #{phone},
            </if>
            <if test="null != code ">
                #{code},
            </if>
            <if test="null != content ">
                #{content},
            </if>
            <if test="null != status ">
                #{status},
            </if>
            <if test="null != delFlag ">
                #{delFlag},
            </if>
            <if test="null != createTime ">
                #{createTime},
            </if>
            <if test="null != createBy and '' != createBy">
                #{createBy},
            </if>
            <if test="null != updateTime ">
                #{updateTime},
            </if>
            <if test="null != updateBy and '' != updateBy">
                #{updateBy},
            </if>
            <if test="null != remark and '' != remark">
                #{remark}
            </if>
        </trim>
    </insert>

    <select id="getList" resultType="map">
        select
           phone,
           content,
           status,
           create_time as createTime
        from xhpc_sms
        where del_flag=0
        <if test="null!=status">
            and status=#{status}
        </if>
        <if test="null!=phone and ''!=phone">
            and phone like concat('%',#{phone},'%')
        </if>
    </select>
</mapper>
