|
@@ -0,0 +1,179 @@
|
|
|
+<?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.PoNewsMapper">
|
|
|
+
|
|
|
+ <resultMap type="PoNews" id="PoNewsResult">
|
|
|
+ <result property="newsId" column="news_id" />
|
|
|
+ <result property="newsTitle" column="news_title" />
|
|
|
+ <result property="newsContent" column="news_content" />
|
|
|
+ <result property="status" column="status" />
|
|
|
+ <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="remark" column="remark" />
|
|
|
+ <result property="sort" column="sort" />
|
|
|
+ <result property="publisherId" column="publisher_id" />
|
|
|
+ <result property="userId" column="user_id" />
|
|
|
+ <result property="delFlag" column="del_flag"/>
|
|
|
+ <result property="image" column="image"/>
|
|
|
+ <result property="newsTime" column="news_time"/>
|
|
|
+ </resultMap>
|
|
|
+<!--查询po_news表所有-->
|
|
|
+ <sql id="selectPoNewsVo">
|
|
|
+ select news_id, news_title, news_content, status, create_by, create_time, update_by, update_time,
|
|
|
+ remark, sort, publisher_id, user_id ,del_flag ,image ,news_time from po_news
|
|
|
+ </sql>
|
|
|
+
|
|
|
+<!-- 分页查询-->
|
|
|
+ <select id="selectPoNewsList" parameterType="PoNews" resultMap="PoNewsResult">
|
|
|
+ <include refid="selectPoNewsVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="newsTitle != null and newsTitle != ''"> and news_title = #{newsTitle}</if>
|
|
|
+ <if test="newsContent != null and newsContent != ''"> and news_content = #{newsContent}</if>
|
|
|
+ <if test="status != null and status != ''"> and status = #{status}</if>
|
|
|
+ <if test="sort != null "> and sort = #{sort}</if>
|
|
|
+ <if test="publisherId != null "> and publisher_id = #{publisherId}</if>
|
|
|
+ <if test="userId != null "> and user_id = #{userId}</if>
|
|
|
+ <if test="delFlag != null and delFlag != ''">and del_flag = #{delFlag}</if>
|
|
|
+ <if test="image != null and image != ''">and image = #{image}</if>
|
|
|
+ <if test="newsTime != null ">and news_time = #{newsTime}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- 通过Id查询-->
|
|
|
+ <select id="selectPoNewsByNewsId" parameterType="String" resultMap="PoNewsResult">
|
|
|
+ <include refid="selectPoNewsVo"/>
|
|
|
+ where news_id = #{newsId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- 增加-->
|
|
|
+ <insert id="insertPoNews" parameterType="PoNews">
|
|
|
+ insert into po_news
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="newsId != null">news_id,</if>
|
|
|
+ <if test="newsTitle != null and newsTitle != ''">news_title,</if>
|
|
|
+ <if test="newsContent != null and newsContent != ''">news_content,</if>
|
|
|
+ <if test="status != null">status,</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="remark != null">remark,</if>
|
|
|
+ <if test="sort != null">sort,</if>
|
|
|
+ <if test="publisherId != null">publisher_id,</if>
|
|
|
+ <if test="userId != null">user_id,</if>
|
|
|
+ <if test="delFlag != null and delFlag != ''">del_flag,</if>
|
|
|
+ <if test="image != null and image != ''">image,</if>
|
|
|
+ <if test="newsTime != null">news_time,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="newsId != null">#{newsId},</if>
|
|
|
+ <if test="newsTitle != null and newsTitle != ''">#{newsTitle},</if>
|
|
|
+ <if test="newsContent != null and newsContent != ''">#{newsContent},</if>
|
|
|
+ <if test="status != null">#{status},</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="remark != null">#{remark},</if>
|
|
|
+ <if test="sort != null">#{sort},</if>
|
|
|
+ <if test="publisherId != null">#{publisherId},</if>
|
|
|
+ <if test="userId != null">#{userId},</if>
|
|
|
+ <if test="delFlag != null and delFlag != '' ">#{delFlag},</if>
|
|
|
+ <if test="image != null and image != ''">#{image},</if>
|
|
|
+ <if test="newsTime != null">#{newsTime},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+<!-- 修改-->
|
|
|
+ <update id="updatePoNews" parameterType="PoNews">
|
|
|
+ update po_news
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="newsTitle != null and newsTitle != ''">news_title = #{newsTitle},</if>
|
|
|
+ <if test="newsContent != null and newsContent != ''">news_content = #{newsContent},</if>
|
|
|
+ <if test="status != null">status = #{status},</if>
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ <if test="sort != null">sort = #{sort},</if>
|
|
|
+ <if test="publisherId != null">publisher_id = #{publisherId},</if>
|
|
|
+ <if test="userId != null">user_id = #{userId},</if>
|
|
|
+ <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag}</if>
|
|
|
+ <if test="image != null and image != ''">image = #{image}</if>
|
|
|
+ <if test="newsTime != null">news_time = #{newsTime}</if>
|
|
|
+ </trim>
|
|
|
+ where news_id = #{newsId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+<!-- 删除-->
|
|
|
+ <delete id="deletePoNewsByNewsId" parameterType="Long">
|
|
|
+ delete from po_news where news_id = #{newsId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+<!-- 批量删除-->
|
|
|
+ <delete id="deletePoNewsByNewsIds" parameterType="String">
|
|
|
+ delete from po_news where news_id in
|
|
|
+ <foreach item="newsId" collection="array" open="(" separator="," close=")">
|
|
|
+ #{newsId}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 标题时间都不为空-->
|
|
|
+ <select id="selectPoNewsListByTitleAndNewsTimeStartAndNewsTimeEnd"
|
|
|
+ resultType="PoNews" resultMap="PoNewsResult">
|
|
|
+ <include refid="selectPoNewsVo"></include>
|
|
|
+ <where>
|
|
|
+ <if test="newsTitle != null and newsTitle != ''"> and news_title like concat('%', #{newsTitle}, '%')</if>
|
|
|
+ <if test="newsTimeStart != null and newsTimeEnd != null "> and news_time between #{newsTimeStart} and #{newsTimeEnd}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- 标题不为空时间为空-->
|
|
|
+ <select id="selectPoNewsListByTitle" resultType="PoNews" resultMap="PoNewsResult">
|
|
|
+ <include refid="selectPoNewsVo"></include>
|
|
|
+ <where>
|
|
|
+ <if test="newsTitle != null and newsTitle != ''">and news_title like concat('%', #{newsTitle}, '%')</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- 标题为空时间不为空-->
|
|
|
+ <select id="selectPoNewsByTime" resultType="PoNews" resultMap="PoNewsResult">
|
|
|
+ <include refid="selectPoNewsVo"></include>
|
|
|
+ <where>
|
|
|
+ <if test="newsTimeStart != null and newsTimeEnd != null "> and news_time between #{newsTimeStart} and #{newsTimeEnd}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- 查询详细内容-->
|
|
|
+ <select id="selectContentByNewsId" resultType="PoNews" resultMap="PoNewsResult">
|
|
|
+ select news_content from po_news where news_id = #{newsId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+<!-- 校验标题是否重复-->
|
|
|
+ <select id="checkPostNewsTitleUnique" resultType="String" resultMap="PoNewsResult">
|
|
|
+ select news_id, news_title from po_news where news_title = #{newsTitle} and del_flag = '0' limit 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 校验图片是否重复-->
|
|
|
+ <select id="checkPostNewsImageUnique" resultType="String" resultMap="PoNewsResult">
|
|
|
+ select news_id,image from po_news where image = #{image} and del_flag = '0' limit 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 通过消息Id查询用户Id-->
|
|
|
+ <select id="selectUserByNewsId" resultType="String">
|
|
|
+ select u.user_id from po_news n LEFT JOIN po_user u ON n.user_id = u.user_id
|
|
|
+ where n.news_id = #{newsId}
|
|
|
+ </select>
|
|
|
+<!-- 校验时间是否相同-->
|
|
|
+ <select id="checkPostNewsTimeUnique" resultType="String" resultMap="PoNewsResult">
|
|
|
+ select news_id,create_time from po_news where create_time = #{createTime} and del_flag = '0' limit 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+</mapper>
|