<?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.TSEntBaseMapper">
    <resultMap type="com.chinaweal.aiccs.aiccs.claim.entity.TSEntBase" id="tsentbase">
        <result property="pripid" column="pripid"/>
        <result property="regno" column="regno"/>
        <result property="uscc" column="uscc"/>
        <result property="entname" column="entname"/>
        <result property="enttype" column="enttype"/>
        <result property="subenttype" column="subenttype"/>
        <result property="industryphy" column="industryphy"/>
        <result property="industryco" column="industryco"/>
        <result property="lerepname" column="lerepname"/>
        <result property="regcap" column="regcap"/>
        <result property="founddate" column="founddate"/>
        <result property="regaicid" column="regorg"/>
        <result property="insobjtype" column="insobjtype"/>
        <result property="insobjtypename" column="insobjtypename"/>
        <result property="entstate" column="entstate"/>
        <result property="status" column="status"/>
        <result property="leveltype" column="leveltype"/>
        <result property="lauptime" column="lauptime"/>
    </resultMap>


    <select id="findTsentbaseList" resultMap="tsentbase" parameterType="com.chinaweal.aiccs.aiccs.claim.entity.TSEntBase">
        select
        *
        from V_tsEntBase
        <where>
            <if test="pripid != null and pripid != ''">
                AND pripid = #{pripid}
            </if>
            <if test="regno != null and regno != ''">
                AND regno = #{regno}
            </if>
            <if test="uscc != null and uscc != ''">
                AND uscc = #{uscc}
            </if>
            <if test="entname != null">
                AND entname = #{entname}
            </if>
            <if test="enttype != null">
                AND enttype = #{enttype}
            </if>
            <if test="subenttype != null">
                AND subenttype = #{subenttype}
            </if>
            <if test="industryphy != null">
                AND industryphy = #{industryphy}
            </if>
            <if test="industryco != null">
                AND industryco = #{industryco}
            </if>
            <if test="founddate != null">
                AND founddate = #{founddate,jdbcType=TIMESTAMP}
            </if>
            <if test="regaicid != null">
                AND regaicid = #{regaicid}
            </if>
            <if test="status != null">
                AND status = #{status}
            </if>
            <if test="entstate != null">
                AND entstate = #{entstate}
            </if>
            <if test="lerepname != null">
                AND lerepname = #{lerepname}
            </if>
            <if test="leveltype != null">
                AND leveltype = #{leveltype}
            </if>
        </where>
    </select>

    <select id="findTsentbaseListByPage" resultMap="tsentbase" parameterType="com.chinaweal.aiccs.aiccs.claim.entity.TSEntBase">
        select
        *
        from V_tsEntBase
        <where>
            <if test="tsentbaseModel.pripid != null and tsentbaseModel.pripid != ''">
                AND pripid = #{tsentbaseModel.pripid}
            </if>
            <if test="tsentbaseModel.regno != null and tsentbaseModel.regno != ''">
                <choose>
                    <when test="tsentbaseModel.regno.length() == 18 ">
                        AND uscc = #{tsentbaseModel.regno}
                    </when>
                    <otherwise>
                        AND regno = #{tsentbaseModel.regno}
                    </otherwise>
                </choose>
            </if>
            <if test="tsentbaseModel.uscc != null and tsentbaseModel.uscc != ''">
                AND uscc = #{tsentbaseModel.uscc}
            </if>
            <if test="tsentbaseModel.entname != null and tsentbaseModel.entname != ''">
                AND entname like '%'||#{tsentbaseModel.entname}||'%'
            </if>
        </where>
    </select>

    <select id="findTsentbaseByID" resultMap="tsentbase" parameterType="java.lang.String">
		select * from V_tsEntBase where pripid = #{pripid}
	</select>


</mapper>
