新增站点编码配置,支持新闻分类与文章按站点隔离。主要变更包括: - 数据库表增加 site_code 字段及索引 - 后台管理界面支持按站点筛选 - 前台接口支持通过查询参数或请求头指定站点 - 新增站点配置与解析逻辑
48 lines
2.2 KiB
XML
48 lines
2.2 KiB
XML
<?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.wuhansaga.server.mapper.NewsCategoryMapper">
|
|
|
|
<resultMap id="newsCategoryResult" type="com.wuhansaga.server.entity.NewsCategory" autoMapping="true">
|
|
<id property="newsCategoryId" column="category_id"/>
|
|
</resultMap>
|
|
|
|
<select id="selectAll" resultMap="newsCategoryResult">
|
|
SELECT * FROM f_news_category WHERE del_flag = 0
|
|
<if test="siteCode != null and siteCode != ''">AND site_code = #{siteCode}</if>
|
|
ORDER BY sort_order ASC
|
|
</select>
|
|
|
|
<select id="selectPublished" resultMap="newsCategoryResult">
|
|
SELECT * FROM f_news_category WHERE del_flag = 0 AND is_published = 1
|
|
<if test="siteCode != null and siteCode != ''">AND site_code = #{siteCode}</if>
|
|
ORDER BY sort_order ASC
|
|
</select>
|
|
|
|
<select id="selectById" resultMap="newsCategoryResult">
|
|
SELECT * FROM f_news_category WHERE category_id = #{id} AND del_flag = 0
|
|
</select>
|
|
|
|
<insert id="insert" useGeneratedKeys="true" keyProperty="newsCategoryId" keyColumn="category_id">
|
|
INSERT INTO f_news_category (site_code, name_zh, name_en, sort_order, is_published, create_by, remark)
|
|
VALUES (#{siteCode}, #{nameZh}, #{nameEn}, #{sortOrder}, #{isPublished}, #{createBy}, #{remark})
|
|
</insert>
|
|
|
|
<update id="update" parameterType="com.wuhansaga.server.entity.NewsCategory">
|
|
UPDATE f_news_category
|
|
<set>
|
|
<if test="siteCode != null">site_code = #{siteCode},</if>
|
|
<if test="nameZh != null">name_zh = #{nameZh},</if>
|
|
<if test="nameEn != null">name_en = #{nameEn},</if>
|
|
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
|
|
<if test="isPublished != null">is_published = #{isPublished},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
</set>
|
|
WHERE category_id = #{newsCategoryId} AND del_flag = 0
|
|
</update>
|
|
|
|
<update id="deleteById">
|
|
UPDATE f_news_category SET del_flag = 1 WHERE category_id = #{id}
|
|
</update>
|
|
</mapper>
|