CreditCatalogMapper.xml 13.1 KB
<?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.credit.cy.business.mapper.CreditCatalogMapper">
    
    <resultMap type="CreditCatalog" id="CreditCatalogResult">
        <result property="id"    column="id"    />
        <result property="catalogName"    column="catalog_name"    />
        <result property="largeType"    column="large_type"    />
        <result property="catalogType"    column="catalog_type"    />
        <result property="catalogCode"    column="catalog_code"    />
        <result property="regionId"    column="region_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="counterpartType"    column="counterpart_type"    />
        <result property="uploadCycle"    column="upload_cycle"    />
        <result property="openType"    column="open_type"    />
        <result property="catalogBasis"    column="catalog_basis"    />
        <result property="catalogContent"    column="catalog_content"    />
        <result property="templateFile"    column="template_file"    />
        <result property="reportDate"    column="report_date"    />
        <result property="reportDept"    column="report_dept"    />
        <result property="checkStatus"    column="check_status"    />
        <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"    />
    </resultMap>

    <sql id="selectCreditCatalogVo">
        select id, catalog_name, large_type, catalog_type, catalog_code, region_id, dept_id, dept_name, counterpart_type, upload_cycle, open_type, catalog_basis, catalog_content, template_file, report_date, report_dept, check_status, del_flag, create_by, create_time, update_by, update_time from credit_catalog
    </sql>

    <select id="selectCreditCatalogList" parameterType="CreditCatalog" resultMap="CreditCatalogResult">
        <include refid="selectCreditCatalogVo"/>
        <where>  
            <if test="catalogName != null  and catalogName != ''"> and catalog_name like concat('%',#{catalogName}, '%')</if>
            <if test="largeType != null  and largeType != ''"> and large_type = #{largeType}</if>
            <if test="catalogType != null  and catalogType != ''"> and catalog_type = #{catalogType}</if>
            <if test="catalogCode != null  and catalogCode != ''"> and catalog_code = #{catalogCode}</if>
            <if test="regionId != null  and regionId != ''"> and region_id = #{regionId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name = #{deptName}</if>
            <if test="counterpartType != null  and counterpartType != ''"> and counterpart_type = #{counterpartType}</if>
            <if test="uploadCycle != null  and uploadCycle != ''"> and upload_cycle = #{uploadCycle}</if>
            <if test="openType != null  and openType != ''"> and open_type = #{openType}</if>
            <if test="catalogBasis != null  and catalogBasis != ''"> and catalog_basis = #{catalogBasis}</if>
            <if test="catalogContent != null  and catalogContent != ''"> and catalog_content = #{catalogContent}</if>
            <if test="templateFile != null  and templateFile != ''"> and template_file = #{templateFile}</if>
            <if test="reportDate != null "> and report_date = #{reportDate}</if>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="checkStatus != null"> and check_status = #{checkStatus}</if>
            <if test="delFlag != null"> and del_flag = #{delFlag}</if>
        </where>
    </select>
    
    <select id="selectCreditCatalogById" parameterType="Long" resultMap="CreditCatalogResult">
        <include refid="selectCreditCatalogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCreditCatalog" parameterType="CreditCatalog" useGeneratedKeys="true" keyProperty="id">
        insert into credit_catalog
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="catalogName != null and catalogName != ''">catalog_name,</if>
            <if test="largeType != null and largeType != ''">large_type,</if>
            <if test="catalogType != null and catalogType != ''">catalog_type,</if>
            <if test="catalogCode != null">catalog_code,</if>
            <if test="regionId != null">region_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="counterpartType != null and counterpartType != ''">counterpart_type,</if>
            <if test="uploadCycle != null">upload_cycle,</if>
            <if test="openType != null and openType != ''">open_type,</if>
            <if test="catalogBasis != null and catalogBasis != ''">catalog_basis,</if>
            <if test="catalogContent != null">catalog_content,</if>
            <if test="templateFile != null">template_file,</if>
            <if test="reportDate != null">report_date,</if>
            <if test="reportDept != null">report_dept,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="catalogName != null and catalogName != ''">#{catalogName},</if>
            <if test="largeType != null and largeType != ''">#{largeType},</if>
            <if test="catalogType != null and catalogType != ''">#{catalogType},</if>
            <if test="catalogCode != null">#{catalogCode},</if>
            <if test="regionId != null">#{regionId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="counterpartType != null and counterpartType != ''">#{counterpartType},</if>
            <if test="uploadCycle != null">#{uploadCycle},</if>
            <if test="openType != null and openType != ''">#{openType},</if>
            <if test="catalogBasis != null and catalogBasis != ''">#{catalogBasis},</if>
            <if test="catalogContent != null">#{catalogContent},</if>
            <if test="templateFile != null">#{templateFile},</if>
            <if test="reportDate != null">#{reportDate},</if>
            <if test="reportDept != null">#{reportDept},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCreditCatalog" parameterType="CreditCatalog">
        update credit_catalog
        <trim prefix="SET" suffixOverrides=",">
            <if test="catalogName != null and catalogName != ''">catalog_name = #{catalogName},</if>
            <if test="largeType != null and largeType != ''">large_type = #{largeType},</if>
            <if test="catalogType != null and catalogType != ''">catalog_type = #{catalogType},</if>
            <if test="catalogCode != null">catalog_code = #{catalogCode},</if>
            <if test="regionId != null">region_id = #{regionId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="counterpartType != null and counterpartType != ''">counterpart_type = #{counterpartType},</if>
            <if test="uploadCycle != null">upload_cycle = #{uploadCycle},</if>
            <if test="openType != null and openType != ''">open_type = #{openType},</if>
            <if test="catalogBasis != null and catalogBasis != ''">catalog_basis = #{catalogBasis},</if>
            <if test="catalogContent != null">catalog_content = #{catalogContent},</if>
            <if test="templateFile != null">template_file = #{templateFile},</if>
            <if test="reportDate != null">report_date = #{reportDate},</if>
            <if test="reportDept != null">report_dept = #{reportDept},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCreditCatalogById" parameterType="Long">
        delete from credit_catalog where id = #{id}
    </delete>

    <delete id="deleteCreditCatalogByIds" parameterType="String">
        delete from credit_catalog where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <insert id="batchSave" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
        insert into credit_catalog (id, catalog_name, large_type, catalog_type, catalog_code, dept_id, dept_name, counterpart_type, upload_cycle, open_type, catalog_basis, catalog_content, report_date, report_dept, check_status, create_by, create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.id},#{item.catalogName},#{item.largeType},#{item.catalogType},#{item.catalogCode},#{item.deptId},
            #{item.deptName},#{item.counterpartType},#{item.uploadCycle},#{item.openType},#{item.catalogBasis},#{item.catalogContent},
            #{item.reportDate},#{item.reportDept},#{item.checkStatus}, #{item.createBy},#{item.createTime})
        </foreach>
    </insert>

    <select id="selectDataByIdList" parameterType="Long" resultMap="CreditCatalogResult">
        <include refid="selectCreditCatalogVo"/> where id in
        <foreach item="id" collection="list" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <update id="checkReport" parameterType="Long">
        update credit_catalog set check_status = 2, report_date = now()
        where id in
        <foreach item="id" collection="list" open="(" separator="," close=")">
            #{id}
        </foreach>
        and check_status = 1
    </update>

    <select id="searchCreditCatalogList" parameterType="com.credit.cy.business.model.CreditCatalogQuery" resultMap="CreditCatalogResult">
        <include refid="selectCreditCatalogVo"/>
        <where>
            <if test="catalogName != null  and catalogName != ''"> and catalog_name like concat('%',#{catalogName}, '%')</if>
            <if test="largeTypeList != null "> and large_type in
                <foreach item="largeType" collection="largeTypeList" open="(" separator="," close=")">
                    #{largeType}
                </foreach>
            </if>
            <if test="catalogTypeList != null "> and catalog_type in
                <foreach item="catalogType" collection="catalogTypeList" open="(" separator="," close=")">
                    #{catalogType}
                </foreach>
            </if>
            <if test="catalogCode != null  and catalogCode != ''"> and catalog_code = #{catalogCode}</if>
            <if test="regionId != null  and regionId != ''"> and region_id = #{regionId}</if>
            <if test="deptIdList != null "> and dept_id in
                <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
            <if test="counterpartTypeList != null "> and counterpart_type in
                <foreach item="counterpartType" collection="counterpartTypeList" open="(" separator="," close=")">
                    #{counterpartType}
                </foreach>
            </if>
            <if test="uploadCycleList != null "> and upload_cycle in
                <foreach item="uploadCycle" collection="uploadCycleList" open="(" separator="," close=")">
                    #{uploadCycle}
                </foreach>
            </if>
            <if test="openTypeList != null "> and open_type in
                <foreach item="openType" collection="openTypeList" open="(" separator="," close=")">
                    #{openType}
                </foreach>
            </if>
            <if test="reportDate != null "> and report_date = #{reportDate}</if>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="checkStatus != null"> and check_status = #{checkStatus}</if>
        </where>
    </select>
    <select id="getMaxId" resultType="java.lang.Long">
        select id from credit_catalog where check_status='2' order by id desc limit 1;
    </select>
</mapper>