<?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.ruoyi.zongzhi.mapper.TcNetworkArticleMapper">
    
    <resultMap type="TcNetworkArticle" id="TcNetworkArticleResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="type"    column="type"    />
        <result property="articleTitle"    column="article_title"    />
        <result property="releaseTime"    column="release_time"    />
        <result property="source"    column="source"    />
        <result property="url"    column="url"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateId"    column="update_id"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
        <result property="status"    column="status"    />
        <result property="isStatus"    column="is_status"    />
    </resultMap>

    <sql id="selectTcNetworkArticleVo">
        select id, area_id, type, article_title,status, is_status,release_time, source, url, create_id, create_by, create_time, update_id, update_time, update_by, remark from tc_network_article
    </sql>

    <select id="selectTcNetworkArticleList" parameterType="TcNetworkArticle" resultMap="TcNetworkArticleResult">
        <include refid="selectTcNetworkArticleVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="articleTitle != null  and articleTitle != ''"> and article_title = #{articleTitle}</if>
            <if test="releaseTime != null "> and release_time = #{releaseTime}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
            <if test="isStatus != null "> and is_status = #{isStatus}</if>
        </where>
    </select>
    
    <select id="selectTcNetworkArticleById" parameterType="Long" resultMap="TcNetworkArticleResult">
        <include refid="selectTcNetworkArticleVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcNetworkArticle" parameterType="TcNetworkArticle">
        insert into tc_network_article
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="areaId != null">area_id,</if>
            <if test="type != null">type,</if>
            <if test="articleTitle != null">article_title,</if>
            <if test="releaseTime != null">release_time,</if>
            <if test="source != null">source,</if>
            <if test="url != null">url,</if>
            <if test="status != null">status,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
            <if test="isStatus != null">is_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="type != null">#{type},</if>
            <if test="articleTitle != null">#{articleTitle},</if>
            <if test="releaseTime != null">#{releaseTime},</if>
            <if test="source != null">#{source},</if>
            <if test="url != null">#{url},</if>
            <if test="status != null">#{status},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isStatus != null">#{isStatus},</if>
         </trim>
    </insert>

    <update id="updateTcNetworkArticle" parameterType="TcNetworkArticle">
        update tc_network_article
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="articleTitle != null">article_title = #{articleTitle},</if>
            <if test="releaseTime != null">release_time = #{releaseTime},</if>
            <if test="source != null">source = #{source},</if>
            <if test="url != null">url = #{url},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isStatus != null">is_status=#{isStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcNetworkArticleById" parameterType="Long">
        delete from tc_network_article where id = #{id}
    </delete>

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