ReportTemplateMapper.xml 3.25 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.ReportTemplateMapper">
    
    <resultMap type="com.credit.cy.business.domain.ReportTemplate" id="ReportTemplateResult">
        <result property="id"    column="id"    />
        <result property="reportType"    column="report_type"    />
        <result property="fileKey"    column="file_key"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectReportTemplateVo">
        select id, report_type, file_key, create_time, update_time from report_template
    </sql>

    <select id="selectReportTemplateList" parameterType="com.credit.cy.business.domain.ReportTemplate" resultMap="ReportTemplateResult">
        <include refid="selectReportTemplateVo"/>
        <where>  
            <if test="reportType != null  and reportType != ''"> and report_type = #{reportType}</if>
            <if test="fileKey != null  and fileKey != ''"> and file_key = #{fileKey}</if>
        </where>
    </select>
    
    <select id="selectReportTemplateById" parameterType="Long" resultMap="ReportTemplateResult">
        <include refid="selectReportTemplateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertReportTemplate" parameterType="com.credit.cy.business.domain.ReportTemplate">
        insert into report_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="reportType != null and reportType != ''">report_type,</if>
            <if test="fileKey != null and fileKey != ''">file_key,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="reportType != null and reportType != ''">#{reportType},</if>
            <if test="fileKey != null and fileKey != ''">#{fileKey},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateReportTemplate" parameterType="com.credit.cy.business.domain.ReportTemplate">
        update report_template
        <trim prefix="SET" suffixOverrides=",">
            <if test="reportType != null and reportType != ''">report_type = #{reportType},</if>
            <if test="fileKey != null and fileKey != ''">file_key = #{fileKey},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteReportTemplateById" parameterType="Long">
        delete from report_template where id = #{id}
    </delete>

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

</mapper>