<?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.chinaweal.aiccs.crgs.punish.mapper.TbIlcPunInfoQueryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.crgs.punish.entity.TbIlcPunInfoQuery">
        <id column="ID" property="id" />
        <result column="ZCH" property="zch" />
        <result column="UNISCID" property="uniscid" />
        <result column="SDSJ" property="sdsj" />
        <result column="DSRMC" property="dsrmc" />
        <result column="WFXW" property="wfxw" />
        <result column="CFYJ" property="cfyj" />
        <result column="SPUNCONTENT" property="spuncontent" />
        <result column="CZSJ" property="czsj" />
        <result column="S_SIGN_DATA" property="sSignData" />
        <result column="S_SIGN_CERT" property="sSignCert" />
        <result column="CFDJJG" property="cfdjjg" />
        <result column="CFJDSJ" property="cfjdsj" />
        <result column="XZCFLXFS" property="xzcflxfs" />
        <result column="XZCFLXSJ" property="xzcflxsj" />
        <result column="GSQX" property="gsqx" />
        <result column="PENAM" property="penam" />
        <result column="FORFAM" property="forfam" />
        <result column="DTUPDATE" property="dtupdate" />
        <result column="SCASECODE" property="scasecode" />
        <result column="SREALCASECODE" property="srealcasecode" />
        <result column="SBOOKCODE" property="sbookcode" />
        <result column="SFLAG" property="sflag" />
        <result column="UPDATETIME" property="updatetime" />
        <result column="SSTATE" property="sstate" />
        <result column="SGISTTYPECODE" property="sgisttypecode" />
        <result column="SGISTTYPENAME" property="sgisttypename" />
        <result column="SPUNTYPECODE" property="spuntypecode" />
        <result column="SPUNTYPENAME" property="spuntypename" />
        <result column="DSRTYPE" property="dsrtype" />
        <result column="SYSTYPE" property="systype" />
        <result column="DTCASEDATE" property="dtcasedate" />
        <result column="SCHECKTYPE" property="schecktype" />
        <result column="SCHECKTYPENAME" property="schecktypename" />
        <result column="SPRINCIPAL" property="sprincipal" />
        <result column="SPRINCIPALNO" property="sprincipalno" />
    </resultMap>

    <!--使用视图查询，改用表查询-->

<!--    &lt;!&ndash; 通用查询结果列 &ndash;&gt;-->
<!--    <sql id="Base_Column_List">-->
<!--        ID, ZCH, UNISCID, SDSJ, DSRMC, WFXW, CFYJ, SPUNCONTENT, CZSJ, S_SIGN_DATA, S_SIGN_CERT, CFDJJG, CFJDSJ, XZCFLXFS, XZCFLXSJ, GSQX, PENAM, FORFAM, DTUPDATE, SCASECODE, SREALCASECODE, SBOOKCODE, SFLAG, UPDATETIME, SSTATE, SGISTTYPECODE, SGISTTYPENAME, SPUNTYPECODE, SPUNTYPENAME, DSRTYPE, SYSTYPE, DTCASEDATE, SCHECKTYPE, SCHECKTYPENAME, SPRINCIPAL, SPRINCIPALNO-->
<!--    </sql>-->

<!--    <select id="searchByPage" resultMap="BaseResultMap">-->
<!--        &#45;&#45; 清洗过后的行政处罚试图-->
<!--        select * from V_CASE_PUB_NBASEINFO-->
<!--        <where>-->
<!--            <if test="params.uniscid != null and params.uniscid!= ''">-->
<!--                and uniscid = #{params.uniscid}-->
<!--            </if>-->
<!--            <if test="params.dsrmc != null and params.dsrmc != ''">-->
<!--                and dsrmc like  concat('%', #{params.dsrmc}, '%')-->
<!--            </if>-->
<!--            <if test="params.cfdjjg != null and params.cfdjjg != ''">-->
<!--                and cfdjjg = #{params.cfdjjg}-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->

<!--    <select id="findById" resultType="com.chinaweal.aiccs.crgs.punish.entity.TbIlcPunInfoQuery">-->
<!--        select * from V_CASE_PUB_NBASEINFO where id = #{id}-->
<!--    </select>-->

    <!-- 通用查询结果列 -->
    <sql id="As_Base_Column_List">
        CASEID as id, REGNO as zch, UNISCID as uniscid, ENTNAME as dsrmc, PENDECNO as sbookcode, ILLEGACTTYPE as sgisttypename, PENAUTH_CN as cfdjjg, PENDECISSDATE as cfjdsj, PENCONTENT as spuncontent
    </sql>

    <!--使用表查询-->
    <select id="searchByPage" resultMap="BaseResultMap">
        select
        <include refid="As_Base_Column_List"/>
        from case_pub_nbaseinfo
        where ACTYPE = '1'
        <if test="params.region != null and params.region!= '' and params.region!= '市'.toString()">
            and PENAUTH like concat(#{params.region}, '%')
        </if>
        <if test="params.uniscid != null and params.uniscid!= ''">
            and (uniscid = #{params.uniscid} or REGNO = #{params.uniscid})
        </if>
        <if test="params.dsrmc != null and params.dsrmc != ''">
            and ENTNAME like concat('%', #{params.dsrmc}, '%')
        </if>
        <if test="params.cfdjjg != null and params.cfdjjg != ''">
            and PENAUTH_CN = #{params.cfdjjg}
        </if>
    </select>

    <select id="findById" resultType="com.chinaweal.aiccs.crgs.punish.entity.TbIlcPunInfoQuery">
        select <include refid="As_Base_Column_List"/> from case_pub_nbaseinfo where ACTYPE = '1' and CASEID = #{id}
    </select>

</mapper>
