<?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.system.mapper.operatingmanage.TOperatingmanageNewsMapper">

    <resultMap type="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNews" id="TOperatingmanageNewsResult">
        <result property="newsId"    column="news_id"    />
        <result property="newsTitle"    column="news_title"    />
        <result property="newsType"    column="news_type"    />
        <result property="newsContent"    column="news_content"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="valid"    column="valid"    />
    </resultMap>

    <sql id="selectTOperatingmanageNewsVo">
        select news_id, news_title, news_type, news_content, create_by, create_time, update_by, update_time, valid from t_operatingmanage_news
    </sql>

    <select id="list" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNews" resultMap="TOperatingmanageNewsResult">
        <include refid="selectTOperatingmanageNewsVo"/>
        <where>
            <if test="newsTitle != null  and newsTitle != ''"> and news_title like concat('%', #{newsTitle}, '%')</if>
            <if test="newsType != null  and newsType != ''"> and news_type = #{newsType}</if>
            <if test="newsContent != null  and newsContent != ''"> and news_content = #{newsContent}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateBy != null "> and update_by = #{updateBy}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="valid != null "> and valid = #{valid}</if>
        </where>
        order by news_id desc
    </select>

    <select id="getObjectById" resultMap="TOperatingmanageNewsResult">
        <include refid="selectTOperatingmanageNewsVo"/>
        where news_id = #{id}
    </select>

    <insert id="save" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNews" useGeneratedKeys="true" keyProperty="newsId">
        insert into t_operatingmanage_news
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="newsId != null">news_id,</if>
            <if test="newsTitle != null">news_title,</if>
            <if test="newsType != null">news_type,</if>
            <if test="newsContent != null">news_content,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="valid != null">valid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="newsId != null">#{newsId},</if>
            <if test="newsTitle != null">#{newsTitle},</if>
            <if test="newsType != null">#{newsType},</if>
            <if test="newsContent != null">#{newsContent},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="valid != null">#{valid},</if>
         </trim>
    </insert>

    <update id="update" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNews">
        update t_operatingmanage_news
        <trim prefix="SET" suffixOverrides=",">
            <if test="newsTitle != null">news_title = #{newsTitle},</if>
            <if test="newsType != null">news_type = #{newsType},</if>
            <if test="newsContent != null">news_content = #{newsContent},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},update_time = NOW(),</if>
            <if test="valid != null">valid = #{valid},</if>
        </trim>
        where news_id = #{newsId}
    </update>

    <delete id="remove" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNews">
        delete from t_operatingmanage_news
        where news_id = #{newsId}
    </delete>

    <delete id="batchRemove">
        delete from t_operatingmanage_news where
        news_id in
        <foreach item="newsId" collection="newsId" open="(" separator="," close=")">
            #{newsId}
        </foreach>
    </delete>

</mapper>
