feat(news): 支持新闻中心多站点隔离功能
新增站点编码配置,支持新闻分类与文章按站点隔离。主要变更包括: - 数据库表增加 site_code 字段及索引 - 后台管理界面支持按站点筛选 - 前台接口支持通过查询参数或请求头指定站点 - 新增站点配置与解析逻辑
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<resultMap id="newsResult" type="com.wuhansaga.server.entity.News">
|
||||
<id property="newsId" column="news_id"/>
|
||||
<result property="categoryId" column="category_id"/>
|
||||
<result property="siteCode" column="site_code"/>
|
||||
<result property="titleZh" column="title_zh"/>
|
||||
<result property="titleEn" column="title_en"/>
|
||||
<result property="excerptZh" column="excerpt_zh"/>
|
||||
@@ -12,11 +13,21 @@
|
||||
<result property="contentZh" column="content_zh"/>
|
||||
<result property="contentEn" column="content_en"/>
|
||||
<result property="coverImage" column="cover_image"/>
|
||||
<result property="metaTitleZh" column="meta_title_zh"/>
|
||||
<result property="metaTitleEn" column="meta_title_en"/>
|
||||
<result property="metaDescriptionZh" column="meta_description_zh"/>
|
||||
<result property="metaDescriptionEn" column="meta_description_en"/>
|
||||
<result property="metaKeywords" column="meta_keywords"/>
|
||||
<result property="isFeatured" column="is_featured"/>
|
||||
<result property="isPublished" column="is_published"/>
|
||||
<result property="viewCount" column="view_count"/>
|
||||
<result property="sortOrder" column="sort_order"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="categoryNameZh" column="category_name_zh"/>
|
||||
<result property="categoryNameEn" column="category_name_en"/>
|
||||
</resultMap>
|
||||
@@ -26,8 +37,10 @@
|
||||
FROM f_news n
|
||||
LEFT JOIN f_news_category nc ON n.category_id = nc.category_id
|
||||
WHERE n.del_flag = 0
|
||||
<if test="siteCode != null and siteCode != ''">AND n.site_code = #{siteCode}</if>
|
||||
<if test="categoryId != null">AND n.category_id = #{categoryId}</if>
|
||||
<if test="isFeatured != null">AND n.is_featured = #{isFeatured}</if>
|
||||
<if test="isPublished != null">AND n.is_published = #{isPublished}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (n.title_zh LIKE CONCAT('%',#{keyword},'%') OR n.title_en LIKE CONCAT('%',#{keyword},'%'))
|
||||
</if>
|
||||
@@ -35,11 +48,14 @@
|
||||
</select>
|
||||
|
||||
<select id="selectCount" resultType="long">
|
||||
SELECT COUNT(*) FROM f_news WHERE del_flag = 0
|
||||
<if test="categoryId != null">AND category_id = #{categoryId}</if>
|
||||
<if test="isFeatured != null">AND is_featured = #{isFeatured}</if>
|
||||
SELECT COUNT(*) FROM f_news n
|
||||
WHERE n.del_flag = 0
|
||||
<if test="siteCode != null and siteCode != ''">AND n.site_code = #{siteCode}</if>
|
||||
<if test="categoryId != null">AND n.category_id = #{categoryId}</if>
|
||||
<if test="isFeatured != null">AND n.is_featured = #{isFeatured}</if>
|
||||
<if test="isPublished != null">AND n.is_published = #{isPublished}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (title_zh LIKE CONCAT('%',#{keyword},'%') OR title_en LIKE CONCAT('%',#{keyword},'%'))
|
||||
AND (n.title_zh LIKE CONCAT('%',#{keyword},'%') OR n.title_en LIKE CONCAT('%',#{keyword},'%'))
|
||||
</if>
|
||||
</select>
|
||||
|
||||
@@ -48,6 +64,7 @@
|
||||
FROM f_news n
|
||||
LEFT JOIN f_news_category nc ON n.category_id = nc.category_id
|
||||
WHERE n.del_flag = 0 AND n.is_published = 1
|
||||
AND n.site_code = #{siteCode}
|
||||
<if test="categoryId != null">AND n.category_id = #{categoryId}</if>
|
||||
<if test="isFeatured != null">AND n.is_featured = #{isFeatured}</if>
|
||||
ORDER BY n.sort_order ASC, n.create_time DESC
|
||||
@@ -60,11 +77,19 @@
|
||||
WHERE n.news_id = #{id} AND n.del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectPublishedById" resultMap="newsResult">
|
||||
SELECT n.*, nc.name_zh AS category_name_zh, nc.name_en AS category_name_en
|
||||
FROM f_news n
|
||||
LEFT JOIN f_news_category nc ON n.category_id = nc.category_id
|
||||
WHERE n.news_id = #{id} AND n.del_flag = 0 AND n.is_published = 1
|
||||
AND n.site_code = #{siteCode}
|
||||
</select>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="newsId">
|
||||
INSERT INTO f_news (category_id, title_zh, title_en, excerpt_zh, excerpt_en, content_zh, content_en,
|
||||
INSERT INTO f_news (category_id, site_code, title_zh, title_en, excerpt_zh, excerpt_en, content_zh, content_en,
|
||||
cover_image, meta_title_zh, meta_title_en, meta_description_zh, meta_description_en,
|
||||
meta_keywords, is_featured, is_published, sort_order, create_by, remark)
|
||||
VALUES (#{categoryId}, #{titleZh}, #{titleEn}, #{excerptZh}, #{excerptEn}, #{contentZh}, #{contentEn},
|
||||
VALUES (#{categoryId}, #{siteCode}, #{titleZh}, #{titleEn}, #{excerptZh}, #{excerptEn}, #{contentZh}, #{contentEn},
|
||||
#{coverImage}, #{metaTitleZh}, #{metaTitleEn}, #{metaDescriptionZh}, #{metaDescriptionEn},
|
||||
#{metaKeywords}, #{isFeatured}, #{isPublished}, #{sortOrder}, #{createBy}, #{remark})
|
||||
</insert>
|
||||
@@ -73,6 +98,7 @@
|
||||
UPDATE f_news
|
||||
<set>
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="siteCode != null">site_code = #{siteCode},</if>
|
||||
<if test="titleZh != null">title_zh = #{titleZh},</if>
|
||||
<if test="titleEn != null">title_en = #{titleEn},</if>
|
||||
<if test="excerptZh != null">excerpt_zh = #{excerptZh},</if>
|
||||
@@ -80,6 +106,11 @@
|
||||
<if test="contentZh != null">content_zh = #{contentZh},</if>
|
||||
<if test="contentEn != null">content_en = #{contentEn},</if>
|
||||
<if test="coverImage != null">cover_image = #{coverImage},</if>
|
||||
<if test="metaTitleZh != null">meta_title_zh = #{metaTitleZh},</if>
|
||||
<if test="metaTitleEn != null">meta_title_en = #{metaTitleEn},</if>
|
||||
<if test="metaDescriptionZh != null">meta_description_zh = #{metaDescriptionZh},</if>
|
||||
<if test="metaDescriptionEn != null">meta_description_en = #{metaDescriptionEn},</if>
|
||||
<if test="metaKeywords != null">meta_keywords = #{metaKeywords},</if>
|
||||
<if test="isFeatured != null">is_featured = #{isFeatured},</if>
|
||||
<if test="isPublished != null">is_published = #{isPublished},</if>
|
||||
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
|
||||
|
||||
Reference in New Issue
Block a user