feat: Add news information management module with API and database support
- Introduced new API endpoints for querying and managing news information in the CMS. - Implemented data model for NewsInfo and NewsInfoQuery with validation. - Created NewsInfoMapper for database interactions and corresponding XML mappings. - Developed INewsInfoService interface and its implementation for business logic. - Added RichTextSanitizer utility for cleaning HTML content to prevent XSS attacks. - Created unit tests for RichTextSanitizer to ensure proper functionality. - Updated database schema with news_info table and necessary fields, including status and module. - Added migration scripts for setting up the news information module in the database. - Integrated jsoup library for HTML sanitization.
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?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.cms.mapper.news.NewsInfoMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.cms.domain.news.NewsInfo" id="NewsInfoResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="module" column="module"/>
|
||||
<result property="moduleName" column="module_name"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="content" column="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="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="moduleNameColumn">
|
||||
(select data.dict_label
|
||||
from bussiness_dict_data data
|
||||
where data.dict_type = 'news_module'
|
||||
and data.dict_value = news.module
|
||||
order by data.dict_sort, data.dict_code
|
||||
limit 1) as module_name
|
||||
</sql>
|
||||
|
||||
<sql id="selectNewsInfoListVo">
|
||||
select news.id, news.module, <include refid="moduleNameColumn"/>, news.title,
|
||||
news.status, news.create_time, news.update_time
|
||||
from news_info news
|
||||
</sql>
|
||||
|
||||
<sql id="selectNewsInfoDetailVo">
|
||||
select news.id, news.module, <include refid="moduleNameColumn"/>, news.title,
|
||||
news.content, news.status, news.create_by, news.create_time,
|
||||
news.update_by, news.update_time, news.remark
|
||||
from news_info news
|
||||
</sql>
|
||||
|
||||
<select id="selectNewsInfoList" resultMap="NewsInfoResult">
|
||||
<include refid="selectNewsInfoListVo"/>
|
||||
<where>
|
||||
news.del_flag = '0'
|
||||
<if test="query.title != null and query.title != ''">
|
||||
and news.title like '%' || #{query.title}::varchar || '%'
|
||||
</if>
|
||||
<if test="query.module != null and query.module != ''">
|
||||
and news.module = #{query.module}
|
||||
</if>
|
||||
<if test="query.status != null and query.status != ''">
|
||||
and news.status = #{query.status}
|
||||
</if>
|
||||
</where>
|
||||
order by news.create_time desc, news.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectNewsInfoById" resultMap="NewsInfoResult">
|
||||
<include refid="selectNewsInfoDetailVo"/>
|
||||
where news.id = #{id} and news.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectPublishedNewsInfoById" resultMap="NewsInfoResult">
|
||||
<include refid="selectNewsInfoDetailVo"/>
|
||||
where news.id = #{id} and news.del_flag = '0' and news.status = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertNewsInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into news_info (
|
||||
module, title, content, status, create_by, create_time, del_flag, remark
|
||||
) values (
|
||||
#{module}, #{title}, #{content}, #{status}, #{createBy}, CURRENT_TIMESTAMP, '0',
|
||||
COALESCE(#{remark}, '')
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateNewsInfo">
|
||||
update news_info
|
||||
set module = #{module},
|
||||
title = #{title},
|
||||
content = #{content},
|
||||
<if test="status != null and status != ''">
|
||||
status = #{status},
|
||||
</if>
|
||||
update_by = #{updateBy},
|
||||
update_time = CURRENT_TIMESTAMP,
|
||||
remark = COALESCE(#{remark}, '')
|
||||
where id = #{id} and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="updateNewsInfoStatus">
|
||||
update news_info
|
||||
set status = #{status}, update_by = #{updateBy}, update_time = CURRENT_TIMESTAMP
|
||||
where id = #{id} and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="deleteNewsInfoByIds">
|
||||
update news_info
|
||||
set del_flag = '2', update_by = #{updateBy}, update_time = CURRENT_TIMESTAMP
|
||||
where del_flag = '0'
|
||||
and id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user