CreditMultiFileMapper.xml 11 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.CreditMultiFileMapper">
    
    <resultMap type="CreditMultiFile" id="CreditMultiFileResult">
        <result property="id"    column="id"    />
        <result property="sType"    column="s_type"    />
        <result property="bType"    column="b_type"    />
        <result property="bId"    column="b_id"    />
        <result property="fileType"    column="file_type"    />
        <result property="fileName"    column="file_name"    />
        <result property="filePath"    column="file_path"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="fileSize"    column="file_size"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="uploadDept"    column="upload_dept"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectCreditMultiFileVo">
        select id, s_type, b_type, b_id, file_type, file_name, file_path, file_url, file_size, del_flag, upload_dept, create_by, create_time, update_time from credit_multi_file
    </sql>

    <sql id="selectSimpleMultiFileVo">
        select id, s_type, b_type, b_id, file_type, file_name, file_path, file_url, file_size, upload_dept from credit_multi_file
    </sql>

    <select id="selectCreditMultiFileList" parameterType="CreditMultiFile" resultMap="CreditMultiFileResult">
        <include refid="selectCreditMultiFileVo"/>
        <where>  
            <if test="sType != null  and sType != ''"> and s_type = #{sType}</if>
            <if test="bType != null  and bType != ''"> and b_type = #{bType}</if>
            <if test="bId != null "> and b_id = #{bId}</if>
            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
            <if test="fileName != null  and fileName != ''"> and file_name = #{fileName}</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
            <if test="uploadDept != null "> and upload_dept = #{uploadDept}</if>
        </where>
    </select>

    <select id="selectCreditMultiFileListNew" parameterType="CreditMultiFile" resultMap="CreditMultiFileResult">
        select id, s_type, b_type, b_id, file_type, GROUP_CONCAT(file_name) AS file_name, file_path, file_url, file_size, del_flag, upload_dept, create_by, create_time, update_time from credit_multi_file
        <where>
            <if test="sType != null  and sType != ''"> and s_type = #{sType}</if>
            <if test="bType != null  and bType != ''"> and b_type = #{bType}</if>
            <if test="bId != null "> and b_id = #{bId}</if>
            <if test="fileType != null  and fileType != ''"> and file_type = #{fileType}</if>
            <if test="fileName != null  and fileName != ''"> and file_name = #{fileName}</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
            <if test="uploadDept != null "> and upload_dept = #{uploadDept}</if>
        </where>
        group by upload_dept
    </select>
    
    <select id="selectCreditMultiFileById" parameterType="Long" resultMap="CreditMultiFileResult">
        <include refid="selectCreditMultiFileVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCreditMultiFile" parameterType="CreditMultiFile" useGeneratedKeys="true" keyProperty="id">
        insert into credit_multi_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sType != null and sType != ''">s_type,</if>
            <if test="bType != null and bType != ''">b_type,</if>
            <if test="bId != null">b_id,</if>
            <if test="fileType != null and fileType != ''">file_type,</if>
            <if test="fileName != null and fileName != ''">file_name,</if>
            <if test="filePath != null and filePath != ''">file_path,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="uploadDept != null">upload_dept,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sType != null and sType != ''">#{sType},</if>
            <if test="bType != null and bType != ''">#{bType},</if>
            <if test="bId != null">#{bId},</if>
            <if test="fileType != null and fileType != ''">#{fileType},</if>
            <if test="fileName != null and fileName != ''">#{fileName},</if>
            <if test="filePath != null and filePath != ''">#{filePath},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="uploadDept != null">#{uploadDept},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCreditMultiFile" parameterType="CreditMultiFile">
        update credit_multi_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="sType != null and sType != ''">s_type = #{sType},</if>
            <if test="bType != null and bType != ''">b_type = #{bType},</if>
            <if test="bId != null">b_id = #{bId},</if>
            <if test="fileType != null and fileType != ''">file_type = #{fileType},</if>
            <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
            <if test="filePath != null and filePath != ''">file_path = #{filePath},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            <if test="fileSize != null">file_size = #{fileSize},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCreditMultiFileById" parameterType="Long">
        delete from credit_multi_file where id = #{id}
    </delete>

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

    <delete id="deleteFileByTypeAndBids">
        delete from credit_multi_file where b_id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
        AND b_type = #{bType} AND  upload_dept = #{uploadDept}
    </delete>

    <insert id="batchSaveCreditMultiFile" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO credit_multi_file (id, s_type, b_type, b_id, file_type, file_name, file_path, file_url, file_size, upload_dept, create_time,create_by)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.id},#{item.sType},#{item.bType},#{item.bId},#{item.fileType},#{item.fileName},
            #{item.filePath},#{item.fileUrl},#{item.fileSize},#{item.uploadDept},#{item.createTime},#{item.createBy})
        </foreach>
    </insert>

    <update id="updateBidByIdArray">
        update credit_multi_file set b_id = #{bId}  where id in
        <foreach item="id" collection="idArray" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <select id="searchCreditMultiFileList" parameterType="com.credit.cy.business.model.query.CreditMultiFileQuery" resultMap="CreditMultiFileResult">
        <include refid="selectSimpleMultiFileVo"/>
        <where>
            <if test="bType != null  and bType != ''"> and b_type = #{bType}</if>
            <if test="bidList != null">
                and b_id in
                <foreach item="bId" collection="bidList" open="(" separator="," close=")">
                    #{bId}
                </foreach>
            </if>
            <if test="uploadDept != null "> and upload_dept = #{uploadDept}</if>
        </where>
    </select>

    <select id="selectCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="java.lang.Long">
        select count(1) from credit_multi_file
        <where>
            <if test="bType != null  and bType != ''"> AND b_type = #{bType}</if>
            <if test="bidList != null">
                AND b_id in
                <foreach item="bId" collection="bidList" open="(" separator="," close=")">
                    #{bId}
                </foreach>
            </if>
            <if test="reportDept != null  and reportDept != ''"> AND upload_dept = #{reportDept}</if>
            <if test="null!=reportStartDate"> AND create_Time >= #{reportStartDate}</if>
            <if test="null!=reportEndDate"> AND create_Time <![CDATA[<=]]> #{reportEndDate}</if>
        </where>
    </select>

    <select id="selectDeptCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="java.lang.Long">
        select count(distinct upload_dept) from credit_multi_file
        <where>
            <if test="bType != null and bType != ''"> AND b_type = #{bType}</if>
            <if test="bidList != null">
                AND b_id in
                <foreach item="bId" collection="bidList" open="(" separator="," close=")">
                    #{bId}
                </foreach>
            </if>
            <if test="reportDept != null and reportDept != ''"> AND upload_dept = #{reportDept}</if>
            <if test="null!=reportStartDate"> AND create_Time >= #{reportStartDate}</if>
            <if test="null!=reportEndDate"> AND create_Time <![CDATA[<=]]> #{reportEndDate}</if>
        </where>
    </select>

    <select id="selectGroupCount" parameterType="com.credit.cy.business.model.query.WorkCountQuery" resultType="com.credit.cy.business.model.GroupNumResult">
        select upload_dept as dept,count(1) as total from credit_multi_file
        <where>
            <if test="bType != null and bType != ''"> AND b_type = #{bType}</if>
            <if test="bidList != null">
                AND b_id in
                <foreach item="bId" collection="bidList" open="(" separator="," close=")">
                    #{bId}
                </foreach>
            </if>
            <if test="null!=bid"> AND b_id = #{bid}</if>
            <if test="reportDept != null  and reportDept != ''"> AND upload_dept = #{reportDept}</if>
            <if test="null!=reportStartDate"> AND create_Time >= #{reportStartDate}</if>
            <if test="null!=reportEndDate"> AND create_Time <![CDATA[<=]]> #{reportEndDate}</if>
        </where>
        group by upload_dept
    </select>
</mapper>