<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.base.dao.WarningPusherDAO">
    <resultMap id="WarningPusherMap" type="com.jpsoft.shinestar.modules.base.entity.WarningPusher">
        <id property="id" column="id_"/>
        <result property="companyId" column="company_id"/>
        <result property="companyName" column="company_name"/>
        <result property="times" column="times_"/>
        <result property="temperature" column="temperature_"/>
        <result property="name" column="name_"/>
        <result property="phone" column="phone_"/>
        <result property="openId" column="open_id"/>
        <result property="remark" column="remark_"/>
        <result property="delFlag" column="del_flag"/>
        <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="missingNoticeEnabled" column="missing_notice_enabled"/>
    </resultMap>
    <insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.WarningPusher">
        <!--
        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
            select sys_guid() from dual
        </selectKey>
        -->
        <![CDATA[
		insert into base_warning_pusher
	    (id_,company_id,times_,temperature_,name_,phone_,open_id,remark_,del_flag,
	    create_by,create_time,update_by,update_time,missing_notice_enabled)
		values
		(
            #{id,jdbcType=VARCHAR}
            ,#{companyId,jdbcType=VARCHAR}
            ,#{times,jdbcType= NUMERIC }
            ,#{temperature,jdbcType= NUMERIC }
            ,#{name,jdbcType=VARCHAR}
            ,#{phone,jdbcType=VARCHAR}
            ,#{openId,jdbcType=VARCHAR}
            ,#{remark,jdbcType=VARCHAR}
            ,#{delFlag,jdbcType= NUMERIC }
            ,#{createBy,jdbcType=VARCHAR}
            ,#{createTime,jdbcType= TIMESTAMP }
            ,#{updateBy,jdbcType=VARCHAR}
            ,#{updateTime,jdbcType= TIMESTAMP }
            ,#{missingNoticeEnabled,jdbcType= NUMERIC}
		)
	]]>
    </insert>
    <delete id="delete" parameterType="string">
        delete from base_warning_pusher where id_=#{id,jdbcType=VARCHAR}
    </delete>
    <update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.WarningPusher">
        update base_warning_pusher
        <set>
            <if test="companyId!=null">
                company_id=#{companyId,jdbcType=VARCHAR},
            </if>
            <if test="times!=null">
                times_=#{times,jdbcType= NUMERIC },
            </if>
            <if test="temperature!=null">
                temperature_=#{temperature,jdbcType= NUMERIC },
            </if>
            <if test="name!=null">
                name_=#{name,jdbcType=VARCHAR},
            </if>
            <if test="phone!=null">
                phone_=#{phone,jdbcType=VARCHAR},
            </if>
            <if test="openId!=null">
                open_id=#{openId,jdbcType=VARCHAR},
            </if>
            <if test="remark!=null">
                remark_=#{remark,jdbcType=VARCHAR},
            </if>
            <if test="delFlag!=null">
                del_flag=#{delFlag,jdbcType= NUMERIC },
            </if>
            <if test="createBy!=null">
                create_by=#{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime!=null">
                create_time=#{createTime,jdbcType= TIMESTAMP },
            </if>
            <if test="updateBy!=null">
                update_by=#{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime!=null">
                update_time=#{updateTime,jdbcType= TIMESTAMP },
            </if>
            <if test="missingNoticeEnabled!=null">
                missing_notice_enabled=#{missingNoticeEnabled,jdbcType= TIMESTAMP },
            </if>
        </set>
        where id_=#{id}
    </update>
    <select id="get" parameterType="string" resultMap="WarningPusherMap">
        select * from base_warning_pusher where id_=#{0}
        and del_flag = 0
    </select>
    <select id="exist" parameterType="string" resultType="int">
        select count(*) from base_warning_pusher where id_=#{0} and del_flag = 0
    </select>
    <select id="list" resultMap="WarningPusherMap">
        select * from base_warning_pusher where del_flag = 0
    </select>
    <select id="search" parameterType="hashmap" resultMap="WarningPusherMap">
        <![CDATA[
			select a.*,b.name_ as company_name
			from base_warning_pusher a left join base_company_info b
			on a.company_id = b.id_
		]]>
        <where>
            a.del_flag = 0
            <if test="searchParams.id != null">
                and a.ID_ like #{searchParams.id}
            </if>
            <if test="searchParams.name != null">
                and a.name_ like #{searchParams.name}
            </if>
            <if test="searchParams.phone != null">
                and a.phone_ like #{searchParams.phone}
            </if>
            <if test="searchParams.companyId != null">
                and a.company_id = #{searchParams.companyId}
            </if>
        </where>
        <foreach item="sort" collection="sortList" open="order by" separator=",">
            ${sort.name} ${sort.order}
        </foreach>
    </select>
    <select id="findByCompanyId" resultMap="WarningPusherMap">
        select * from base_warning_pusher where company_id=#{companyId} and del_flag = 0
    </select>
    <select id="findByCompanyIdList" resultMap="WarningPusherMap">
        select * from base_warning_pusher where company_id in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item}
        </foreach>
        and del_flag = 0
    </select>

</mapper>