<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >

<!-- Always ensure to use the correct XML header as above! -->
<mapper namespace="com.chinaweal.aiccs.aiccs.claim.mapper.TSEntBaseAddrMapper">
    <resultMap type="com.chinaweal.aiccs.aiccs.claim.entity.TSEntBaseAddr" id="TSEntBaseAddr">

        <result property="entbaseaddrid" column="entbaseaddrid"/>
        <result property="pripid" column="pripid"/>
        <result property="areaid" column="areaid"/>
        <result property="address" column="address"/>
        <result property="addrtype" column="addrtype"/>
        <result property="areaname" column="areaname"/>
        <result property="marketid" column="marketid"/>
        <result property="marketname" column="marketname"/>
        <result property="localadm" column="localadm"/>
        <result property="lastinspectdate" column="lastinspectdate"/>
        <result property="insstartdate" column="insstartdate"/>
        <result property="insenddate" column="insenddate"/>
        <result property="foundprob" column="foundprob"/>
        <result property="isvalid" column="pripid"/>
        <result property="lauptime" column="lauptime"/>
    </resultMap>


    <select id="findTSEntBaseAddrList" resultMap="TSEntBaseAddr" parameterType="com.chinaweal.aiccs.aiccs.claim.entity.TSEntBaseAddr">
       select * from V_tsEntBaseAddr
       <where>
          <if test="tsentbaseaddrModel.entbaseaddrid!=null and tsentbaseaddrModel.entbaseaddrid!=''">
              and entbaseaddrid = #{tsentbaseaddrModel.entbaseaddrid}
          </if>
          <if test="tsentbaseaddrModel.pripid!=null and tsentbaseaddrModel.pripid!=''">
               and pripid = #{tsentbaseaddrModel.pripid}
          </if>
           <if test="tsentbaseaddrModel.addrtype!=null and tsentbaseaddrModel.addrtype!=''">
               and addrtype = #{tsentbaseaddrModel.addrtype}
           </if>
           <if test="tsentbaseaddrModel.localadm!=null and tsentbaseaddrModel.localadm!=''">
               and localadm = #{tsentbaseaddrModel.localadm}
           </if>
          <if test="tsentbaseaddrModel.address!=null and tsentbaseaddrModel.address!=''">
               and address  like '%'||#{tsentbaseaddrModel.address}|| '%'
          </if>
       </where>
    </select>

    <select id="findTsentbaseaddrByID" resultMap="TSEntBaseAddr" parameterType="java.lang.String">
		select * from V_tsEntBaseAddr where entbaseaddrid = #{entbaseaddrid}
	</select>

    <select id="findTsentBaseAddrBypripid" resultMap="TSEntBaseAddr" parameterType="java.lang.String">
        select * from V_tsEntBaseAddr where pripid = #{pripid} and addrtype = '2'
    </select>

</mapper>
