feat(brandgating): 品牌Gating库后端模块并入管理后台

直连主库既有 biz_brand_gating 表(原独立小网页后台 8090 下线的前置),
六端点挂 /api/admin/brand-gating,权限键 admin_brand_gating,走 admin
第一道门前缀守卫无需额外登记。列表/统计/新增/删除/启停用对齐桌面版
(停用记 disabled_at、恒刷 updated_at);批量导入 { text } 按桌面版
parse_batch 逐条同款解析,去重靠唯一键+批内四键预检。
SQL 账本 115→124、select 账本 78→86,8 条 select 点入 NOT_MIGRATED。
This commit is contained in:
2026-10-23 21:56:45 +08:00
parent 2d408199d6
commit 2c85f47c3b
20 changed files with 1283 additions and 7 deletions
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nanri.aiimage.modules.brandgating.mapper.BrandGatingMapper">
<!-- 品牌Gating库(biz_brand_gating)。行为口径对齐桌面版 gating_web_admin.py:
列表筛选(list_gating L138-162)、统计(stats L165-178)、启停(set_status_gating L196-201)。
动态筛选全部走 #{} 占位符,不做任何字符串拼接。 -->
<!-- 「全部」在桌面版里就是“不限”的哨兵值(也是表内真实取值),与空串一并放行不过滤 -->
<sql id="filterConds">
<if test="f.keyword != null and f.keyword != ''">
AND (brand LIKE CONCAT('%', #{f.keyword}, '%') OR asin LIKE CONCAT('%', #{f.keyword}, '%'))
</if>
<if test="f.country != null and f.country != '' and f.country != '全部'">AND country = #{f.country}</if>
<if test="f.gatingType != null and f.gatingType != '' and f.gatingType != '全部'">AND gating_type = #{f.gatingType}</if>
<if test="f.status != null">AND status = #{f.status}</if>
<if test="f.source != null and f.source != '' and f.source != '全部'">AND source = #{f.source}</if>
</sql>
<select id="countByFilter" resultType="long">
SELECT COUNT(*)
FROM biz_brand_gating
<where>
<include refid="filterConds"/>
</where>
</select>
<select id="selectRows" resultType="com.nanri.aiimage.modules.brandgating.model.vo.BrandGatingRowVo">
SELECT id, brand, asin, country, gating_type, status, source, shop_name, remark,
created_at, updated_at, disabled_at
FROM biz_brand_gating
<where>
<include refid="filterConds"/>
</where>
ORDER BY id DESC
LIMIT #{f.offset}, #{f.limit}
</select>
<select id="countAll" resultType="long">
SELECT COUNT(*) FROM biz_brand_gating
</select>
<select id="countByStatus" resultType="long">
SELECT COUNT(*) FROM biz_brand_gating WHERE status = #{status}
</select>
<select id="countDistinctBrands" resultType="long">
SELECT COUNT(DISTINCT brand) FROM biz_brand_gating WHERE status = 1
</select>
<select id="countGroupByType" resultType="com.nanri.aiimage.modules.brandgating.model.dto.BrandGatingNameCountRow">
SELECT gating_type AS name, COUNT(*) AS count
FROM biz_brand_gating
WHERE status = 1
GROUP BY gating_type
ORDER BY count DESC
</select>
<select id="countGroupByCountry" resultType="com.nanri.aiimage.modules.brandgating.model.dto.BrandGatingNameCountRow">
SELECT country AS name, COUNT(*) AS count
FROM biz_brand_gating
WHERE status = 1
GROUP BY country
ORDER BY count DESC
</select>
<select id="countGroupBySource" resultType="com.nanri.aiimage.modules.brandgating.model.dto.BrandGatingNameCountRow">
SELECT source AS name, COUNT(*) AS count
FROM biz_brand_gating
WHERE status = 1
GROUP BY source
ORDER BY count DESC
</select>
<!-- 启停:status=1 清 disabled_at、=0 记 disabled_at=NOW(),两种都刷 updated_at=NOW()
(桌面版 set_status_gating 的两条 UPDATE 合一;IF 走 #{} 参数,不拼接) -->
<update id="updateStatus">
UPDATE biz_brand_gating
SET status = #{status},
disabled_at = IF(#{status} = 1, NULL, NOW()),
updated_at = NOW()
WHERE id = #{id}
</update>
</mapper>