mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 08:55:53 +08:00
后端新增新闻模块
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?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.iot.mapper.NewsCategoryMapper">
|
||||
|
||||
<resultMap type="NewsCategory" id="NewsCategoryResult">
|
||||
<result property="categoryId" column="category_id" />
|
||||
<result property="categoryName" column="category_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<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" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.ruoyi.iot.model.IdAndName" id="CategoryShortResult">
|
||||
<result property="id" column="category_id" />
|
||||
<result property="name" column="category_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectNewsCategoryVo">
|
||||
select category_id, category_name, order_num, del_flag, create_by, create_time, update_by, update_time, remark from news_category
|
||||
</sql>
|
||||
|
||||
<select id="selectNewsCategoryList" parameterType="NewsCategory" resultMap="NewsCategoryResult">
|
||||
<include refid="selectNewsCategoryVo"/>
|
||||
<where>
|
||||
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
|
||||
</where>
|
||||
order by order_num
|
||||
</select>
|
||||
|
||||
<select id="selectNewsCategoryShortList" resultMap="CategoryShortResult">
|
||||
select category_id, category_name
|
||||
from news_category
|
||||
order by order_num
|
||||
</select>
|
||||
|
||||
<select id="selectNewsCategoryByCategoryId" parameterType="Long" resultMap="NewsCategoryResult">
|
||||
<include refid="selectNewsCategoryVo"/>
|
||||
where category_id = #{categoryId}
|
||||
</select>
|
||||
|
||||
<insert id="insertNewsCategory" parameterType="NewsCategory" useGeneratedKeys="true" keyProperty="categoryId">
|
||||
insert into news_category
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">category_name,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="delFlag != null">del_flag,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="delFlag != null">#{delFlag},</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>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateNewsCategory" parameterType="NewsCategory">
|
||||
update news_category
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</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>
|
||||
</trim>
|
||||
where category_id = #{categoryId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNewsCategoryByCategoryId" parameterType="Long">
|
||||
delete from news_category where category_id = #{categoryId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteNewsCategoryByCategoryIds" parameterType="String">
|
||||
delete from news_category where category_id in
|
||||
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
|
||||
#{categoryId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?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.iot.mapper.NewsMapper">
|
||||
|
||||
<resultMap type="News" id="NewsResult">
|
||||
<result property="newsId" column="news_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="content" column="content" />
|
||||
<result property="imgUrl" column="img_url" />
|
||||
<result property="isTop" column="is_top" />
|
||||
<result property="isBanner" column="is_banner" />
|
||||
<result property="categoryId" column="category_id" />
|
||||
<result property="categoryName" column="category_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="author" column="author" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<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" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectNewsVo">
|
||||
select news_id, title, content, img_url, is_top, is_banner, category_id, category_name, status, author, del_flag, create_by, create_time, update_by, update_time, remark from news
|
||||
</sql>
|
||||
|
||||
<select id="selectNewsList" parameterType="News" resultMap="NewsResult">
|
||||
<include refid="selectNewsVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="isTop != null "> and is_top = #{isTop}</if>
|
||||
<if test="isBanner != null "> and is_banner = #{isBanner}</if>
|
||||
<if test="categoryName != null and categoryName != ''"> and catgory_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectNewsByNewsId" parameterType="Long" resultMap="NewsResult">
|
||||
<include refid="selectNewsVo"/>
|
||||
where news_id = #{newsId}
|
||||
</select>
|
||||
|
||||
<insert id="insertNews" parameterType="News" useGeneratedKeys="true" keyProperty="newsId">
|
||||
insert into news
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null and title != ''">title,</if>
|
||||
<if test="content != null and content != ''">content,</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
|
||||
<if test="isTop != null">is_top,</if>
|
||||
<if test="isBanner != null">is_banner,</if>
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="author != null and author != ''">author,</if>
|
||||
<if test="delFlag != null">del_flag,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null and title != ''">#{title},</if>
|
||||
<if test="content != null and content != ''">#{content},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
|
||||
<if test="isTop != null">#{isTop},</if>
|
||||
<if test="isBanner != null">#{isBanner},</if>
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="author != null and author != ''">#{author},</if>
|
||||
<if test="delFlag != null">#{delFlag},</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>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateNews" parameterType="News">
|
||||
update news
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="title != null and title != ''">title = #{title},</if>
|
||||
<if test="content != null and content != ''">content = #{content},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
|
||||
<if test="isTop != null">is_top = #{isTop},</if>
|
||||
<if test="isBanner != null">is_banner = #{isBanner},</if>
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="author != null and author != ''">author = #{author},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</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>
|
||||
</trim>
|
||||
where news_id = #{newsId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNewsByNewsId" parameterType="Long">
|
||||
delete from news where news_id = #{newsId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteNewsByNewsIds" parameterType="String">
|
||||
delete from news where news_id in
|
||||
<foreach item="newsId" collection="array" open="(" separator="," close=")">
|
||||
#{newsId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user