PortalArticleMapper.xml 10.2 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.PortalArticleMapper">
    
    <resultMap type="PortalArticle" id="PortalArticleResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="newsType"    column="news_type"    />
        <result property="subType"    column="sub_type"    />
        <result property="dataFrom"    column="data_from"    />
        <result property="summary"    column="summary"    />
        <result property="dataStatus"    column="data_status"    />
        <result property="publishStatus"    column="publish_status"    />
        <result property="topStatus"    column="top_status"    />
        <result property="imageKeys"    column="image_keys"    />
        <result property="publishTime"    column="publish_time"    />
        <result property="editor"    column="editor"    />
        <result property="editorDept"    column="editor_dept"    />
        <result property="editorSource"    column="editor_source"    />
        <result property="reviewer"    column="reviewer"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="auditReason"    column="audit_reason"    />
        <result property="readCount"    column="read_count"    />
        <result property="linkCount"    column="link_count"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectPortalArticleVo">
        select id, title, news_type, sub_type, data_from, summary, data_status, publish_status, top_status, image_keys, publish_time, editor, editor_dept, editor_source, reviewer, audit_time, audit_reason, read_count, link_count, create_by, update_by, create_time, update_time, del_flag from portal_article
    </sql>

    <sql id="selectSimpleArticleVo">
        select id, title, news_type, sub_type, data_from, summary, data_status, publish_status, top_status, image_keys, publish_time, editor, editor_dept, editor_source, reviewer, audit_time, read_count, link_count from portal_article
    </sql>

    <sql id="selectLeastArticleVo">
        select id, title, news_type, sub_type, data_from, publish_time, read_count, link_count from portal_article
    </sql>

    <select id="selectPortalArticleList" parameterType="PortalArticle" resultMap="PortalArticleResult">
        <include refid="selectPortalArticleVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="newsType != null  and newsType != ''"> and news_type = #{newsType}</if>
            <if test="subType != null  and subType != ''"> and sub_type = #{subType}</if>
            <if test="dataFrom != null  and dataFrom != ''"> and data_from = #{dataFrom}</if>
            <if test="summary != null  and summary != ''"> and summary = #{summary}</if>
            <if test="dataStatus != null "> and data_status = #{dataStatus}</if>
            <if test="publishStatus != null "> and publish_status = #{publishStatus}</if>
            <if test="topStatus != null "> and top_status = #{topStatus}</if>
            <if test="imageKeys != null  and imageKeys != ''"> and image_keys = #{imageKeys}</if>
            <if test="publishTime != null "> and publish_time = #{publishTime}</if>
            <if test="editor != null  and editor != ''"> and editor = #{editor}</if>
            <if test="editorDept != null  and editorDept != ''"> and editor_dept = #{editorDept}</if>
            <if test="editorSource != null "> and editor_source = #{editorSource}</if>
            <if test="reviewer != null  and reviewer != ''"> and reviewer = #{reviewer}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="auditReason != null  and auditReason != ''"> and audit_reason = #{auditReason}</if>
            <if test="readCount != null "> and read_count = #{readCount}</if>
            <if test="linkCount != null "> and link_count = #{linkCount}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
        </where>
    </select>
    
    <select id="selectPortalArticleById" parameterType="Long" resultMap="PortalArticleResult">
        <include refid="selectPortalArticleVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPortalArticle" parameterType="PortalArticle" useGeneratedKeys="true" keyProperty="id">
        insert into portal_article
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">title,</if>
            <if test="newsType != null and newsType != ''">news_type,</if>
            <if test="subType != null and subType != ''">sub_type,</if>
            <if test="dataFrom != null and dataFrom != ''">data_from,</if>
            <if test="summary != null and summary != ''">summary,</if>
            <if test="dataStatus != null">data_status,</if>
            <if test="publishStatus != null">publish_status,</if>
            <if test="topStatus != null">top_status,</if>
            <if test="imageKeys != null">image_keys,</if>
            <if test="publishTime != null">publish_time,</if>
            <if test="editor != null">editor,</if>
            <if test="editorDept != null">editor_dept,</if>
            <if test="editorSource != null">editor_source,</if>
            <if test="reviewer != null">reviewer,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="auditReason != null">audit_reason,</if>
            <if test="readCount != null">read_count,</if>
            <if test="linkCount != null">link_count,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">#{title},</if>
            <if test="newsType != null and newsType != ''">#{newsType},</if>
            <if test="subType != null and subType != ''">#{subType},</if>
            <if test="dataFrom != null and dataFrom != ''">#{dataFrom},</if>
            <if test="summary != null and summary != ''">#{summary},</if>
            <if test="dataStatus != null">#{dataStatus},</if>
            <if test="publishStatus != null">#{publishStatus},</if>
            <if test="topStatus != null">#{topStatus},</if>
            <if test="imageKeys != null">#{imageKeys},</if>
            <if test="publishTime != null">#{publishTime},</if>
            <if test="editor != null">#{editor},</if>
            <if test="editorDept != null">#{editorDept},</if>
            <if test="editorSource != null">#{editorSource},</if>
            <if test="reviewer != null">#{reviewer},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="auditReason != null">#{auditReason},</if>
            <if test="readCount != null">#{readCount},</if>
            <if test="linkCount != null">#{linkCount},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updatePortalArticle" parameterType="PortalArticle">
        update portal_article
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="newsType != null and newsType != ''">news_type = #{newsType},</if>
            <if test="subType != null and subType != ''">sub_type = #{subType},</if>
            <if test="dataFrom != null and dataFrom != ''">data_from = #{dataFrom},</if>
            <if test="summary != null and summary != ''">summary = #{summary},</if>
            <if test="dataStatus != null">data_status = #{dataStatus},</if>
            <if test="publishStatus != null">publish_status = #{publishStatus},</if>
            <if test="topStatus != null">top_status = #{topStatus},</if>
            <if test="imageKeys != null">image_keys = #{imageKeys},</if>
            <if test="publishTime != null">publish_time = #{publishTime},</if>
            <if test="editor != null">editor = #{editor},</if>
            <if test="reviewer != null">reviewer = #{reviewer},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="auditReason != null">audit_reason = #{auditReason},</if>
            <if test="readCount != null">read_count = #{readCount},</if>
            <if test="linkCount != null">link_count = #{linkCount},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePortalArticleByIdList" parameterType="Long">
        delete from portal_article where id in
        <foreach item="id" collection="list" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateAudit" parameterType="PortalArticle">
        update portal_article
        <trim prefix="SET" suffixOverrides=",">
            <if test="reviewer != null">reviewer = #{reviewer},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="auditReason != null">audit_reason = #{auditReason},</if>
            <if test="publishStatus != null">publish_status = #{publishStatus},</if>
        </trim>
        where id = #{id}
    </update>
</mapper>