PortalArticleContentMapper.xml 3.13 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.PortalArticleContentMapper">
    
    <resultMap type="PortalArticleContent" id="PortalArticleContentResult">
        <result property="id"    column="id"    />
        <result property="aid"    column="aid"    />
        <result property="content"    column="content"    />
    </resultMap>

    <sql id="selectPortalArticleContentVo">
        select id, aid, content from portal_article_content
    </sql>

    <select id="selectPortalArticleContentList" parameterType="PortalArticleContent" resultMap="PortalArticleContentResult">
        <include refid="selectPortalArticleContentVo"/>
        <where>  
            <if test="aid != null "> and aid = #{aid}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectPortalArticleContentById" parameterType="Long" resultMap="PortalArticleContentResult">
        <include refid="selectPortalArticleContentVo"/>
        where id = #{id}
    </select>

    <select id="selectPortalArticleContentByAid" parameterType="Long" resultMap="PortalArticleContentResult">
        <include refid="selectPortalArticleContentVo"/>
        where aid = #{id}
    </select>
        
    <insert id="insertPortalArticleContent" parameterType="PortalArticleContent" useGeneratedKeys="true" keyProperty="id">
        insert into portal_article_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="aid != null">aid,</if>
            <if test="content != null and content != ''">content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="aid != null">#{aid},</if>
            <if test="content != null and content != ''">#{content},</if>
         </trim>
    </insert>

    <update id="updatePortalArticleContent" parameterType="PortalArticleContent">
        update portal_article_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="aid != null">aid = #{aid},</if>
            <if test="content != null and content != ''">content = #{content},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateArticleContentByAid" parameterType="PortalArticleContent">
        update portal_article_content set content = #{content} where aid = #{aid}
    </update>

    <delete id="deletePortalArticleContentById" parameterType="Long">
        delete from portal_article_content where id = #{id}
    </delete>

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

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