refactor(SQL分层): 剩余 85 条注解 SQL 全量迁进 mapper XML,等价性改由 MyBatis 自己判
96 条语句现在全在 src/main/resources/mapper/<模块>/ 下,注解侧 SQL 归零;判据从"基线清单"
改成完成态(逐接口必须为 0 + XML 语句总数 96 + 反向钉:XML 有则注解必须无)。
搬法上踩实了一个坑:注解参数是 Java 表达式("…" + CLIENT_MODULE_TYPES + "…"),
用只认字面量的抽取器搬家会把常量整段吞掉——上一轮生成的 26 份 XML 里因此出现
IN ()、AS status 前面没有表达式(MySQL 语法错),<script> 形态还被多转义一次变成 &lt;。
更糟的是当时"搬迁前快照"与 XML 由同一个抽取器产出,两边一起错所以逐字比对全绿,
抓到现场的是既有的语义用例(TaskCenter 15 条 + 店铺查重那条断 <> 的)。
所以 MigratedSqlEquivalenceTest 改成:账本存注解原文,Java 侧现场用
getDefaultScriptingLanguageInstance().createSqlSource 编译原文,与 XML 解析出的
MappedStatement 各渲染一遍 BoundSql 对撞(空参数 + foreach 喂满 2 元素各一次),
转义对不对由 MyBatis 判定而不是由生成器判定;账本自己再钉 <script>/<if> 成对、不许出现 IN ()。
resultType 那一支不变:期望值由接口签名反射反推,66 条分母钉住。
取数入口跟着换:6 支原本读 @Select 注解的守卫(TaskCenter/Dedupe/店铺查重/通知保留/
鉴权形状/后台扩权)改走 MapperXmlSupport,断言内容一字未动;后台扩权那条"不许有 wrapper
投影"从全文 doesNotContain(".select(") 改成只扫可执行行——接口里现在只剩签名,
而 javadoc 正写着"别用 selectList(.select(...))",全文判会被自己的注释喂饱。
隔离树全量 4059 例 0 红(基线 4054,+5 为新增等价性与 XML 用例)。这批要生效得随下一版 jar 发版。
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?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.brand.mapper.BrandCrawlTaskMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="selectExpiredTerminalTaskIds" resultType="long">
|
||||
SELECT id FROM brand_crawl_tasks
|
||||
WHERE status IN ('success', 'failed', 'cancelled')
|
||||
AND updated_at < #{cutoff}
|
||||
ORDER BY id ASC
|
||||
LIMIT #{batchSize}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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.collectdata.mapper.CollectDataItemMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO biz_collect_data_item
|
||||
(task_id, row_index, source_file_key, source_filename, keyword, status_value, extra_json, created_at)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.taskId}, #{row.rowIndex}, #{row.sourceFileKey}, #{row.sourceFilename},
|
||||
#{row.keyword}, #{row.statusValue}, #{row.extraJson}, #{row.createdAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.common.mapper.AdminUserMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="countAdminMenuGrants" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM user_column_permission ucp
|
||||
JOIN columns cm ON cm.id = ucp.column_id
|
||||
WHERE ucp.user_id = #{userId}
|
||||
AND cm.menu_type = 'admin'
|
||||
<if test="companyId != null">
|
||||
AND cm.company_id = #{companyId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectCompanySuperAdminEarliestExpiry" resultType="java.time.LocalDateTime">
|
||||
SELECT MIN(expires_at)
|
||||
FROM users
|
||||
WHERE role = 'company_super_admin'
|
||||
AND company_id = #{companyId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,126 @@
|
||||
<?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.common.mapper.ShopManageGroupMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="selectAccessibleCreatorUserIds" resultType="long">
|
||||
SELECT DISTINCT visible_user_id
|
||||
FROM (
|
||||
SELECT #{operatorId} AS visible_user_id
|
||||
UNION
|
||||
SELECT direct_member.user_id AS visible_user_id
|
||||
FROM biz_shop_manage_group leader_group
|
||||
INNER JOIN biz_shop_manage_group_member direct_member ON direct_member.group_id = leader_group.id
|
||||
WHERE leader_group.created_by_id = #{operatorId}
|
||||
OR leader_group.user_id = #{operatorId}
|
||||
UNION
|
||||
SELECT COALESCE(direct_group.created_by_id, direct_group.user_id) AS visible_user_id
|
||||
FROM biz_shop_manage_group_member membership
|
||||
INNER JOIN biz_shop_manage_group direct_group ON direct_group.id = membership.group_id
|
||||
WHERE membership.user_id = #{operatorId}
|
||||
AND COALESCE(direct_group.created_by_id, direct_group.user_id) IS NOT NULL
|
||||
) visible_users
|
||||
WHERE visible_user_id IS NOT NULL
|
||||
ORDER BY visible_user_id ASC
|
||||
</select>
|
||||
<select id="selectAccessibleGroupIds" resultType="long">
|
||||
SELECT DISTINCT accessible_group_id
|
||||
FROM (
|
||||
SELECT g.id AS accessible_group_id
|
||||
FROM biz_shop_manage_group g
|
||||
WHERE g.created_by_id = #{operatorId}
|
||||
OR g.user_id = #{operatorId}
|
||||
UNION
|
||||
SELECT gm.group_id AS accessible_group_id
|
||||
FROM biz_shop_manage_group_member gm
|
||||
WHERE gm.user_id = #{operatorId}
|
||||
UNION
|
||||
SELECT g2.id AS accessible_group_id
|
||||
FROM biz_shop_manage_group_member gm
|
||||
INNER JOIN biz_shop_manage_group g1 ON g1.id = gm.group_id
|
||||
INNER JOIN biz_shop_manage_group g2
|
||||
ON g2.created_by_id = COALESCE(g1.created_by_id, g1.user_id)
|
||||
OR g2.user_id = COALESCE(g1.created_by_id, g1.user_id)
|
||||
WHERE gm.user_id = #{operatorId}
|
||||
AND COALESCE(g1.created_by_id, g1.user_id) IS NOT NULL
|
||||
UNION
|
||||
SELECT member_groups.id AS accessible_group_id
|
||||
FROM biz_shop_manage_group leader_group
|
||||
INNER JOIN biz_shop_manage_group_member direct_member ON direct_member.group_id = leader_group.id
|
||||
INNER JOIN biz_shop_manage_group member_groups
|
||||
ON member_groups.created_by_id = direct_member.user_id
|
||||
OR member_groups.user_id = direct_member.user_id
|
||||
WHERE leader_group.created_by_id = #{operatorId}
|
||||
OR leader_group.user_id = #{operatorId}
|
||||
) accessible_groups
|
||||
WHERE accessible_group_id IS NOT NULL
|
||||
ORDER BY accessible_group_id ASC
|
||||
</select>
|
||||
<select id="selectAllGroups" resultType="com.nanri.aiimage.common.model.entity.ShopManageGroupEntity">
|
||||
SELECT g.id AS id, g.group_name AS groupName
|
||||
FROM biz_shop_manage_group g
|
||||
ORDER BY g.id ASC
|
||||
</select>
|
||||
<select id="selectGroupNamesByUserIds" resultType="com.nanri.aiimage.modules.shopkey.model.dto.UserGroupRef">
|
||||
SELECT u.id AS userId, g.group_name AS groupName
|
||||
FROM users u
|
||||
INNER JOIN biz_shop_manage_group g
|
||||
ON g.created_by_id = u.created_by_id OR g.user_id = u.created_by_id
|
||||
WHERE u.created_by_id IS NOT NULL
|
||||
AND u.id IN
|
||||
<foreach collection='userIds' item='userId' open='(' separator=',' close=')'>
|
||||
#{userId}
|
||||
</foreach>
|
||||
ORDER BY g.id ASC
|
||||
</select>
|
||||
<select id="selectLeaderIdsByMemberUserId" resultType="long">
|
||||
SELECT DISTINCT COALESCE(g.created_by_id, g.user_id) AS leader_id
|
||||
FROM biz_shop_manage_group_member gm
|
||||
INNER JOIN biz_shop_manage_group g ON g.id = gm.group_id
|
||||
WHERE gm.user_id = #{userId}
|
||||
AND COALESCE(g.created_by_id, g.user_id) IS NOT NULL
|
||||
</select>
|
||||
<select id="selectLedGroups" resultType="com.nanri.aiimage.common.model.entity.ShopManageGroupEntity">
|
||||
SELECT g.id AS id, g.group_name AS groupName
|
||||
FROM biz_shop_manage_group g
|
||||
WHERE g.created_by_id = #{operatorId} OR g.user_id = #{operatorId}
|
||||
ORDER BY g.id ASC
|
||||
</select>
|
||||
<select id="selectManagedMemberUserIds" resultType="long">
|
||||
SELECT DISTINCT gm.user_id
|
||||
FROM biz_shop_manage_group g
|
||||
INNER JOIN biz_shop_manage_group_member gm ON gm.group_id = g.id
|
||||
INNER JOIN users u ON u.id = gm.user_id
|
||||
WHERE g.created_by_id = #{operatorId}
|
||||
OR g.user_id = #{operatorId}
|
||||
ORDER BY gm.user_id ASC
|
||||
</select>
|
||||
<select id="selectUserIdsByGroupId" resultType="long">
|
||||
SELECT u.id AS userId
|
||||
FROM users u
|
||||
INNER JOIN biz_shop_manage_group g ON g.id = #{groupId}
|
||||
WHERE u.id = COALESCE(g.created_by_id, g.user_id)
|
||||
OR u.created_by_id = COALESCE(g.created_by_id, g.user_id)
|
||||
ORDER BY u.id ASC
|
||||
</select>
|
||||
<select id="selectUserIdsByGroupIds" resultType="long">
|
||||
SELECT DISTINCT visible_user_id
|
||||
FROM (
|
||||
SELECT COALESCE(g.created_by_id, g.user_id) AS visible_user_id
|
||||
FROM biz_shop_manage_group g
|
||||
WHERE g.id IN
|
||||
<foreach collection='groupIds' item='groupId' open='(' separator=',' close=')'>
|
||||
#{groupId}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT gm.user_id AS visible_user_id
|
||||
FROM biz_shop_manage_group_member gm
|
||||
WHERE gm.group_id IN
|
||||
<foreach collection='groupIds' item='groupId' open='(' separator=',' close=')'>
|
||||
#{groupId}
|
||||
</foreach>
|
||||
) visible_users
|
||||
WHERE visible_user_id IS NOT NULL
|
||||
ORDER BY visible_user_id ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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.dedupe.mapper.DedupeTotalDataMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<insert id="insertBatchIgnore">
|
||||
INSERT IGNORE INTO biz_dedupe_total_data
|
||||
(data_value, country, group_id, uploader_user_id, uploader_username, company_id)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.dataValue}, #{row.country}, #{row.groupId}, #{row.uploaderUserId}, #{row.uploaderUsername}, #{row.companyId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectAllDataValues" resultType="string">
|
||||
SELECT data_value FROM biz_dedupe_total_data
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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.devicelog.mapper.DeviceLogFileMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<delete id="deleteOlderThanBatch">
|
||||
DELETE FROM device_log_file
|
||||
WHERE log_date < #{cutoff}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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.imagevideo.mapper.ImageVideoAdminTaskMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="countAdminTaskPage" resultType="long">
|
||||
SELECT COUNT(*) AS total
|
||||
FROM biz_image_video_async_task t
|
||||
LEFT JOIN users u ON u.id = t.user_id
|
||||
WHERE t.task_type = 'IMAGE_VIDEO_WORKFLOW'
|
||||
AND t.submitted_at >= DATE_SUB(NOW(), INTERVAL 3 DAY)
|
||||
<if test="userId != null"> AND t.user_id = #{userId}</if>
|
||||
<if test="userIds != null"> AND t.user_id IN
|
||||
<foreach collection="userIds" item="uid" open="(" separator="," close=")">#{uid}</foreach>
|
||||
</if>
|
||||
<if test="username != null and username != ''"> AND u.username LIKE CONCAT('%', #{username}, '%')</if>
|
||||
<if test="status != null and status != ''"> AND t.status = #{status}</if>
|
||||
<if test="executeId != null and executeId != ''"> AND t.coze_execute_id LIKE CONCAT('%', #{executeId}, '%')</if>
|
||||
<if test="submittedFrom != null"> AND t.submitted_at >= #{submittedFrom}</if>
|
||||
<if test="submittedTo != null"> AND t.submitted_at <= #{submittedTo}</if>
|
||||
</select>
|
||||
<select id="selectAdminTaskDetail" resultType="map">
|
||||
SELECT t.id, t.user_id, t.status, t.request_json, t.submit_response_json, t.result_json,
|
||||
t.video_urls_json, t.debug_url, t.archived_videos_json, t.archive_status,
|
||||
t.archive_error, t.archive_attempt_count,
|
||||
DATE_FORMAT(t.archived_at, '%Y-%m-%d %H:%i:%s') AS archived_at,
|
||||
t.error_message, t.coze_execute_id, t.coze_status,
|
||||
DATE_FORMAT(t.submitted_at, '%Y-%m-%d %H:%i:%s') AS submitted_at,
|
||||
DATE_FORMAT(t.completed_at, '%Y-%m-%d %H:%i:%s') AS completed_at,
|
||||
u.username,
|
||||
COALESCE((
|
||||
SELECT GROUP_CONCAT(DISTINCT g.group_name ORDER BY g.id SEPARATOR '、')
|
||||
FROM biz_shop_manage_group g
|
||||
LEFT JOIN biz_shop_manage_group_member gm ON gm.group_id = g.id
|
||||
WHERE g.created_by_id = t.user_id OR g.user_id = t.user_id OR gm.user_id = t.user_id
|
||||
), '') AS group_name
|
||||
FROM biz_image_video_async_task t
|
||||
LEFT JOIN users u ON u.id = t.user_id
|
||||
WHERE t.task_type = 'IMAGE_VIDEO_WORKFLOW'
|
||||
AND t.submitted_at &gt;= DATE_SUB(NOW(), INTERVAL 3 DAY)
|
||||
AND t.id = #{taskId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectAdminTaskPage" resultType="map">
|
||||
SELECT t.id, t.user_id, t.status, t.request_json, t.submit_response_json, t.result_json,
|
||||
t.video_urls_json, t.debug_url, t.archived_videos_json, t.archive_status,
|
||||
t.archive_error, t.archive_attempt_count,
|
||||
DATE_FORMAT(t.archived_at, '%Y-%m-%d %H:%i:%s') AS archived_at,
|
||||
t.error_message, t.coze_execute_id, t.coze_status,
|
||||
DATE_FORMAT(t.submitted_at, '%Y-%m-%d %H:%i:%s') AS submitted_at,
|
||||
DATE_FORMAT(t.completed_at, '%Y-%m-%d %H:%i:%s') AS completed_at,
|
||||
u.username,
|
||||
COALESCE((
|
||||
SELECT GROUP_CONCAT(DISTINCT g.group_name ORDER BY g.id SEPARATOR '、')
|
||||
FROM biz_shop_manage_group g
|
||||
LEFT JOIN biz_shop_manage_group_member gm ON gm.group_id = g.id
|
||||
WHERE g.created_by_id = t.user_id OR g.user_id = t.user_id OR gm.user_id = t.user_id
|
||||
), '') AS group_name
|
||||
FROM biz_image_video_async_task t
|
||||
LEFT JOIN users u ON u.id = t.user_id
|
||||
WHERE t.task_type = 'IMAGE_VIDEO_WORKFLOW'
|
||||
AND t.submitted_at >= DATE_SUB(NOW(), INTERVAL 3 DAY)
|
||||
<if test="userId != null"> AND t.user_id = #{userId}</if>
|
||||
<if test="userIds != null"> AND t.user_id IN
|
||||
<foreach collection="userIds" item="uid" open="(" separator="," close=")">#{uid}</foreach>
|
||||
</if>
|
||||
<if test="username != null and username != ''"> AND u.username LIKE CONCAT('%', #{username}, '%')</if>
|
||||
<if test="status != null and status != ''"> AND t.status = #{status}</if>
|
||||
<if test="executeId != null and executeId != ''"> AND t.coze_execute_id LIKE CONCAT('%', #{executeId}, '%')</if>
|
||||
<if test="submittedFrom != null"> AND t.submitted_at >= #{submittedFrom}</if>
|
||||
<if test="submittedTo != null"> AND t.submitted_at <= #{submittedTo}</if>
|
||||
ORDER BY t.submitted_at DESC, t.id DESC
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
<select id="selectAdminZipRows" resultType="map">
|
||||
SELECT t.id, t.user_id, t.video_urls_json, t.archived_videos_json
|
||||
FROM biz_image_video_async_task t
|
||||
WHERE t.task_type = 'IMAGE_VIDEO_WORKFLOW'
|
||||
AND t.submitted_at >= DATE_SUB(NOW(), INTERVAL 3 DAY)
|
||||
AND t.id IN
|
||||
<foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
|
||||
#{taskId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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.imagevideo.mapper.ImageVideoAsyncTaskMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<update id="claimPending">
|
||||
UPDATE biz_image_video_async_task SET status = 'RUNNING', owner_instance_id = CASE WHEN owner_instance_id IS NULL OR owner_instance_id = '' THEN #{ownerInstanceId} ELSE owner_instance_id END, updated_at = NOW(), attempt_count = attempt_count + 1 WHERE id = #{taskId} AND status = 'PENDING' AND (owner_instance_id = #{ownerInstanceId} OR owner_instance_id IS NULL OR owner_instance_id = '')
|
||||
</update>
|
||||
<update id="claimWaiting">
|
||||
UPDATE biz_image_video_async_task SET status = 'POLLING', owner_instance_id = CASE WHEN owner_instance_id IS NULL OR owner_instance_id = '' THEN #{ownerInstanceId} ELSE owner_instance_id END, updated_at = NOW(), attempt_count = attempt_count + 1 WHERE id = #{taskId} AND status = 'WAITING' AND (owner_instance_id = #{ownerInstanceId} OR owner_instance_id IS NULL OR owner_instance_id = '')
|
||||
</update>
|
||||
<update id="requeuePollingTasks">
|
||||
UPDATE biz_image_video_async_task SET status = 'WAITING', updated_at = NOW() WHERE status = 'POLLING' AND (owner_instance_id = #{ownerInstanceId} OR owner_instance_id IS NULL OR owner_instance_id = '')
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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.invalidasin.mapper.InvalidAsinDataMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<insert id="insertBatchIgnore">
|
||||
INSERT IGNORE INTO biz_invalid_asin_data
|
||||
(data_value, brand, record_source, uploader_user_id)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.dataValue}, #{row.brand}, #{row.recordSource}, #{row.uploaderUserId,jdbcType=BIGINT})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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.notification.mapper.UserNotificationMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<delete id="deleteReadBeforeBatch">
|
||||
DELETE FROM biz_user_notification
|
||||
WHERE read_at IS NOT NULL AND created_at < #{cutoff}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
<delete id="deleteUnreadBeforeBatch">
|
||||
DELETE FROM biz_user_notification
|
||||
WHERE read_at IS NULL AND created_at < #{cutoff}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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.permission.mapper.UserColumnPermissionMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="countByUserIdAndColumnId" resultType="long">
|
||||
SELECT COUNT(*) FROM user_column_permission WHERE user_id = #{userId} AND column_id = #{columnId}
|
||||
</select>
|
||||
<delete id="deleteByColumnId">
|
||||
DELETE FROM user_column_permission WHERE column_id = #{columnId}
|
||||
</delete>
|
||||
<delete id="deleteByUserId">
|
||||
DELETE FROM user_column_permission WHERE user_id = #{userId}
|
||||
</delete>
|
||||
<delete id="deleteByUserIdAndColumnIds">
|
||||
DELETE FROM user_column_permission
|
||||
WHERE user_id = #{userId}
|
||||
AND column_id IN
|
||||
<foreach collection="columnIds" item="columnId" open="(" separator="," close=")">
|
||||
#{columnId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<insert id="insert">
|
||||
INSERT INTO user_column_permission (user_id, column_id) VALUES (#{userId}, #{columnId})
|
||||
</insert>
|
||||
<select id="selectByColumnId" resultType="com.nanri.aiimage.modules.permission.model.entity.UserColumnPermissionEntity">
|
||||
SELECT user_id, column_id FROM user_column_permission WHERE column_id = #{columnId}
|
||||
</select>
|
||||
<select id="selectByUserId" resultType="com.nanri.aiimage.modules.permission.model.entity.UserColumnPermissionEntity">
|
||||
SELECT user_id, column_id FROM user_column_permission WHERE user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.pricetrack.mapper.PriceTrackLoopRunMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<delete id="deleteFinishedBefore">
|
||||
DELETE FROM biz_price_track_loop_run
|
||||
WHERE status IN ('SUCCESS', 'FAILED', 'STOPPED')
|
||||
AND cleanup_at < #{cutoff}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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.publish.mapper.PublishItemMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO biz_publish_item
|
||||
(task_id, file_id, row_index, source_id, asin, country, brand, price_value,
|
||||
status_value, sync_status, sync_countries, created_at, updated_at)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.taskId}, #{row.fileId}, #{row.rowIndex}, #{row.sourceId}, #{row.asin},
|
||||
#{row.country}, #{row.brand}, #{row.priceValue}, #{row.statusValue},
|
||||
#{row.syncStatus}, #{row.syncCountries}, #{row.createdAt}, #{row.updatedAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?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.shopdatacrawl.mapper.ShopDataCrawlAdminTasksMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="countDailyFileObjectReferences" resultType="long">
|
||||
SELECT COUNT(1) FROM biz_shop_data_crawl_daily_file
|
||||
WHERE result_file_url = #{objectKey}
|
||||
</select>
|
||||
<select id="selectDownloadRowById" resultType="com.nanri.aiimage.modules.shopdatacrawl.model.dto.ShopDataCrawlDownloadRowDto">
|
||||
SELECT df.id AS resultId, df.latest_task_id AS taskId, df.user_id AS userId,
|
||||
df.shop_name AS sourceFilename, df.result_filename AS resultFilename,
|
||||
df.result_file_url AS resultFileUrl
|
||||
FROM biz_shop_data_crawl_daily_file df
|
||||
WHERE df.id = #{dailyFileId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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.shopdatacrawl.mapper.ShopDataCrawlItemMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<delete id="deleteBatch">
|
||||
DELETE FROM biz_shop_data_crawl_item
|
||||
WHERE shop_name = #{shopName} AND business_date = #{businessDate}
|
||||
</delete>
|
||||
<delete id="deleteByDailyFileId">
|
||||
DELETE FROM biz_shop_data_crawl_item
|
||||
WHERE daily_file_id = #{dailyFileId}
|
||||
</delete>
|
||||
<delete id="deleteOlderThanBatch">
|
||||
DELETE FROM biz_shop_data_crawl_item
|
||||
WHERE business_date < #{cutoff}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO biz_shop_data_crawl_item
|
||||
(shop_id, shop_name, group_name, business_date, country, asin, brand, price,
|
||||
item_date, units_sold, item_json, result_id, task_id, daily_file_id)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.shopId}, #{row.shopName}, #{row.groupName}, #{row.businessDate}, #{row.country},
|
||||
#{row.asin}, #{row.brand}, #{row.price}, #{row.itemDate}, #{row.unitsSold},
|
||||
#{row.itemJson}, #{row.resultId}, #{row.taskId}, #{row.dailyFileId})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?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.shopduplicatecheck.mapper.ShopDataDuplicateScanMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<delete id="deleteOlderThanBatch">
|
||||
DELETE FROM shop_data_duplicate_scan
|
||||
WHERE created_at < #{cutoff}
|
||||
AND id < #{protectFromId}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
<select id="selectLatestFullRow" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ScanFullRowDto">
|
||||
SELECT id, summary_json AS summaryJson, payload_json AS payloadJson, created_at AS createdAt FROM shop_data_duplicate_scan WHERE status = 'SUCCESS' ORDER BY id DESC LIMIT 1
|
||||
</select>
|
||||
<select id="selectLatestLightRow" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ScanLightRowDto">
|
||||
SELECT id, created_at AS createdAt FROM shop_data_duplicate_scan WHERE status = 'SUCCESS' ORDER BY id DESC LIMIT 1
|
||||
</select>
|
||||
<select id="selectNthNewestId" resultType="long">
|
||||
SELECT id FROM shop_data_duplicate_scan ORDER BY id DESC LIMIT 1 OFFSET #{offset}
|
||||
</select>
|
||||
</mapper>
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?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.shopduplicatecheck.mapper.ShopDuplicateCheckItemMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="countShopBatch" resultType="long">
|
||||
SELECT COUNT(1) FROM biz_shop_data_crawl_item
|
||||
WHERE shop_name = #{shopName} AND business_date = #{businessDate}
|
||||
</select>
|
||||
<select id="selectDistinctShopNames" resultType="string">
|
||||
SELECT DISTINCT shop_name FROM biz_shop_data_crawl_item
|
||||
</select>
|
||||
<select id="selectLatestItemsByShop" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ShopLatestItemRowDto">
|
||||
SELECT i.shop_name AS shopName,
|
||||
i.country AS country,
|
||||
i.asin AS asin,
|
||||
i.item_date AS itemDate,
|
||||
i.price AS price,
|
||||
i.brand AS brand
|
||||
FROM biz_shop_data_crawl_item i
|
||||
WHERE i.shop_name = #{shopName}
|
||||
AND i.business_date = (
|
||||
SELECT MAX(business_date) FROM biz_shop_data_crawl_item WHERE shop_name = #{shopName}
|
||||
)
|
||||
</select>
|
||||
<select id="selectLegacyMigrationFiles" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ShopDailyFileMigrationDto">
|
||||
SELECT ranked.daily_file_id AS dailyFileId,
|
||||
ranked.business_date AS businessDate,
|
||||
ranked.latest_result_id AS latestResultId,
|
||||
fr.source_filename AS shopName,
|
||||
fr.result_file_url AS resultFileUrl,
|
||||
fr.task_id AS taskId
|
||||
FROM (
|
||||
SELECT df.id AS daily_file_id,
|
||||
df.business_date,
|
||||
df.latest_result_id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY df.shop_key
|
||||
ORDER BY df.business_date DESC, df.id DESC) AS row_no
|
||||
FROM biz_shop_data_crawl_daily_file df
|
||||
WHERE df.compensation_done = 1
|
||||
) ranked
|
||||
JOIN biz_file_result fr ON fr.id = ranked.latest_result_id
|
||||
WHERE ranked.row_no = 1
|
||||
AND fr.module_type = 'SHOP_DATA_CRAWL'
|
||||
</select>
|
||||
<select id="selectMemberPayload" resultType="string">
|
||||
SELECT row_payload FROM biz_shop_data_crawl_daily_member
|
||||
WHERE daily_file_id = #{dailyFileId} AND result_id = #{resultId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?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.shopduplicatecheck.mapper.ShopDuplicateCheckSourceMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="selectAllShopLabels" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ShopGroupLabelDto">
|
||||
SELECT TRIM(sm.shop_name) AS shopName,
|
||||
GROUP_CONCAT(DISTINCT COALESCE(NULLIF(g.group_name, ''), NULLIF(sm.group_name, ''))
|
||||
ORDER BY sm.id SEPARATOR '、') AS groupName
|
||||
FROM biz_shop_manage sm
|
||||
LEFT JOIN biz_shop_manage_group g ON g.id = sm.group_id
|
||||
WHERE TRIM(COALESCE(sm.shop_name, '')) <> ''
|
||||
GROUP BY TRIM(sm.shop_name)
|
||||
</select>
|
||||
<select id="selectGroupLabels" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ShopGroupLabelDto">
|
||||
SELECT TRIM(sm.shop_name) AS shopName,
|
||||
GROUP_CONCAT(DISTINCT COALESCE(NULLIF(g.group_name, ''), NULLIF(sm.group_name, ''))
|
||||
ORDER BY sm.id SEPARATOR '、') AS groupName
|
||||
FROM biz_shop_manage sm
|
||||
LEFT JOIN biz_shop_manage_group g ON g.id = sm.group_id
|
||||
WHERE TRIM(sm.shop_name) IN
|
||||
<foreach collection='shopNames' item='name' open='(' separator=',' close=')'>#{name}</foreach>
|
||||
GROUP BY TRIM(sm.shop_name)
|
||||
</select>
|
||||
<select id="selectLatestResultRows" resultType="com.nanri.aiimage.modules.shopduplicatecheck.model.dto.ShopSourceRowDto">
|
||||
SELECT ranked.result_id AS resultId,
|
||||
ranked.shop_name AS shopName,
|
||||
ranked.result_file_url AS resultFileUrl,
|
||||
ranked.result_file_size AS resultFileSize,
|
||||
ranked.request_json AS requestJson,
|
||||
ranked.country_codes_json AS countryCodesJson
|
||||
FROM (
|
||||
SELECT r.id AS result_id,
|
||||
r.source_filename AS shop_name,
|
||||
r.result_file_url,
|
||||
r.result_file_size,
|
||||
t.request_json,
|
||||
df.country_codes_json,
|
||||
COALESCE(df.last_success_at, df.updated_at, t.finished_at,
|
||||
t.updated_at, t.created_at) AS latest_file_updated_at,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY TRIM(COALESCE(r.source_filename, ''))
|
||||
ORDER BY COALESCE(df.last_success_at, df.updated_at,
|
||||
t.finished_at, t.updated_at, t.created_at) DESC,
|
||||
r.id DESC) AS row_no
|
||||
FROM biz_file_result r
|
||||
JOIN biz_file_task t ON t.id = r.task_id
|
||||
LEFT JOIN biz_shop_data_crawl_daily_file df ON df.latest_result_id = r.id
|
||||
WHERE r.module_type = 'SHOP_DATA_CRAWL'
|
||||
AND t.module_type = 'SHOP_DATA_CRAWL'
|
||||
AND TRIM(COALESCE(r.result_file_url, '')) <> ''
|
||||
) ranked
|
||||
WHERE ranked.row_no = 1
|
||||
ORDER BY ranked.latest_file_updated_at DESC, ranked.result_id DESC
|
||||
</select>
|
||||
<select id="selectManagedShopNames" resultType="string">
|
||||
SELECT DISTINCT TRIM(sm.shop_name) AS shopName
|
||||
FROM biz_shop_manage sm
|
||||
WHERE sm.group_id IN (
|
||||
SELECT id FROM biz_shop_manage_group
|
||||
WHERE created_by_id = #{operatorId} OR user_id = #{operatorId}
|
||||
)
|
||||
</select>
|
||||
<select id="selectShopNamesOwnedBy" resultType="string">
|
||||
SELECT DISTINCT TRIM(sm.shop_name)
|
||||
FROM biz_shop_manage sm
|
||||
WHERE TRIM(COALESCE(sm.shop_name, '')) <> ''
|
||||
AND sm.created_by_id IN
|
||||
<foreach collection="memberIds" item="mid" open="(" separator="," close=")">#{mid}</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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.shopkey.mapper.QueryAsinMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO biz_query_asin (group_id, shop_name, asin_de, asin_uk, asin_fr, asin_it, asin_es)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.groupId}, #{row.shopName}, #{row.asinDe}, #{row.asinUk}, #{row.asinFr}, #{row.asinIt}, #{row.asinEs})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectByGroupIdsAndShopNames" resultType="com.nanri.aiimage.modules.shopkey.model.entity.QueryAsinEntity">
|
||||
SELECT id, group_id, shop_name, asin_de, asin_uk, asin_fr, asin_it, asin_es, created_at, updated_at
|
||||
FROM biz_query_asin
|
||||
WHERE group_id IN
|
||||
<foreach collection="groupIds" item="groupId" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
AND shop_name IN
|
||||
<foreach collection="shopNames" item="shopName" open="(" separator="," close=")">
|
||||
#{shopName}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectByShopNames" resultType="com.nanri.aiimage.modules.shopkey.model.entity.QueryAsinEntity">
|
||||
SELECT id, group_id, shop_name, asin_de, asin_uk, asin_fr, asin_it, asin_es, created_at, updated_at
|
||||
FROM biz_query_asin
|
||||
WHERE shop_name IN
|
||||
<foreach collection="shopNames" item="shopName" open="(" separator="," close=")">
|
||||
#{shopName}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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.softwareversion.mapper.SoftwareVersionMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<update id="markLatestById">
|
||||
UPDATE web_config SET is_latest = (id = #{id})
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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.task.mapper.FileResultMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="selectRowsUpdatedAtByTaskIds" resultType="com.nanri.aiimage.modules.task.model.dto.TaskRowsVersionDto">
|
||||
SELECT task_id AS taskId, MAX(updated_at) AS latestRowAt, COUNT(*) AS rowCount
|
||||
FROM biz_file_result
|
||||
WHERE module_type = #{moduleType}
|
||||
AND task_id IN
|
||||
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">#{taskId}</foreach>
|
||||
GROUP BY task_id
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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.task.mapper.FileTaskMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="selectExpiredTerminalTaskIds" resultType="long">
|
||||
SELECT id FROM biz_file_task
|
||||
WHERE module_type = #{moduleType}
|
||||
AND status IN ('SUCCESS', 'FAILED', 'CANCELLED', 'CANCELED')
|
||||
AND updated_at < #{cutoff}
|
||||
ORDER BY id ASC
|
||||
LIMIT #{batchSize}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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.task.mapper.TaskResultItemMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<insert id="upsertBatch">
|
||||
INSERT INTO biz_task_result_item
|
||||
(task_id, module_type, result_id, scope_key, scope_hash, item_key, asin, status,
|
||||
payload_json, payload_hash, created_at, updated_at)
|
||||
VALUES
|
||||
<foreach collection="rows" item="row" separator=",">
|
||||
(#{row.taskId}, #{row.moduleType}, #{row.resultId}, #{row.scopeKey}, #{row.scopeHash},
|
||||
#{row.itemKey}, #{row.asin}, #{row.status}, #{row.payloadJson}, #{row.payloadHash},
|
||||
#{row.createdAt}, #{row.updatedAt})
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
result_id = VALUES(result_id),
|
||||
scope_key = VALUES(scope_key),
|
||||
asin = VALUES(asin),
|
||||
status = VALUES(status),
|
||||
payload_json = VALUES(payload_json),
|
||||
payload_hash = VALUES(payload_hash),
|
||||
updated_at = VALUES(updated_at)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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.task.mapper.TaskScopeStateMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="selectLastChunkAtByTaskIds" resultType="com.nanri.aiimage.modules.task.model.dto.TaskScopeLastChunkDto">
|
||||
SELECT task_id AS taskId, MAX(last_chunk_at) AS lastChunkAt
|
||||
FROM biz_task_scope_state
|
||||
WHERE task_id IN
|
||||
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">#{taskId}</foreach>
|
||||
GROUP BY task_id
|
||||
HAVING MAX(last_chunk_at) IS NOT NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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.taskcenter.mapper.TaskCenterQueryMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<select id="countFinishedTasksSince" resultType="long">
|
||||
SELECT COUNT(*) FROM ( SELECT t.id FROM biz_file_task t WHERE t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL') AND t.status IN ('CANCELED','CANCELLED','FAILED','SUCCESS') AND COALESCE(t.finished_at, t.updated_at) >= #{since}<if test='userIds != null'> AND t.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if> UNION ALL SELECT b.id FROM brand_crawl_tasks b WHERE b.status IN ('cancelled','failed','success') AND b.updated_at >= #{since}<if test='userIds != null'> AND b.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if>) u
|
||||
</select>
|
||||
<select id="countRunningTasks" resultType="long">
|
||||
SELECT COUNT(*) FROM ( SELECT t.id FROM biz_file_task t WHERE t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL') AND t.status IN ('PENDING','RUNNING','SCHEDULED')<if test='userIds != null'> AND t.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if> UNION ALL SELECT b.id FROM brand_crawl_tasks b WHERE b.status IN ('pending','running')<if test='userIds != null'> AND b.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if>) u
|
||||
</select>
|
||||
<select id="countShops" resultType="long">
|
||||
SELECT COUNT(*) FROM biz_shop_manage s WHERE 1 = 1<if test='userIds != null'> AND s.created_by_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if>
|
||||
</select>
|
||||
<select id="countStuckTasks" resultType="long">
|
||||
SELECT COUNT(*) FROM ( SELECT t.id FROM biz_file_task t WHERE t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL') AND t.status IN ('PENDING','RUNNING','SCHEDULED') AND t.updated_at < #{idleBefore}<if test='userIds != null'> AND t.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if> UNION ALL SELECT b.id FROM brand_crawl_tasks b WHERE b.status IN ('pending','running') AND b.updated_at < #{idleBefore}<if test='userIds != null'> AND b.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if>) u
|
||||
</select>
|
||||
<select id="countTaskPage" resultType="long">
|
||||
SELECT COUNT(*) FROM (SELECT t.id AS id, t.task_no AS taskNo, UPPER(t.module_type) AS moduleType, CASE WHEN UPPER(t.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(t.status) END AS status, t.user_id AS userId, t.device_id AS deviceId, t.created_at AS createdAt, t.finished_at AS finishedAt, t.updated_at AS updatedAt, t.source_file_count AS totalCount, t.success_file_count AS successCount, t.failed_file_count AS failedCount, 0 AS brand FROM biz_file_task t WHERE t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL')<if test='userIds != null'> AND t.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if><if test='moduleType != null'> AND UPPER(t.module_type) = #{moduleType}</if><if test='statuses != null'> AND CASE WHEN UPPER(t.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(t.status) END IN <foreach collection='statuses' item='st' open='(' separator=',' close=')'>#{st}</foreach></if><if test='startTime != null'> AND t.created_at >= #{startTime}</if><if test='endTime != null'> AND t.created_at <= #{endTime}</if><if test='shop != null'> AND (EXISTS (SELECT 1 FROM biz_publish_file p WHERE p.task_id = t.id AND LOWER(TRIM(p.shop_name)) = LOWER(TRIM(#{shop}))) OR (t.module_type IN ('PATROL_DELETE','PRICE_TRACK','PRODUCT_RISK_RESOLVE','QUERY_ASIN','SHOP_DATA_CRAWL','SHOP_MATCH') AND EXISTS (SELECT 1 FROM biz_file_result f WHERE f.task_id = t.id AND LOWER(TRIM(f.source_filename)) = LOWER(TRIM(#{shop})))))</if> UNION ALL SELECT b.id, CONCAT('brand-', b.id), 'BRAND', CASE WHEN UPPER(b.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(b.status) END, b.user_id, b.device_id, b.created_at, CASE WHEN b.status IN ('cancelled','failed','success') THEN b.updated_at END, b.updated_at, b.progress_total, b.progress_current, 0, 1 FROM brand_crawl_tasks b WHERE 1 = 1<if test='userIds != null'> AND b.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if><if test='moduleType != null'> AND 'BRAND' = #{moduleType}</if><if test='statuses != null'> AND CASE WHEN UPPER(b.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(b.status) END IN <foreach collection='statuses' item='st' open='(' separator=',' close=')'>#{st}</foreach></if><if test='startTime != null'> AND b.created_at >= #{startTime}</if><if test='endTime != null'> AND b.created_at <= #{endTime}</if><if test='shop != null'> AND 1 = 0</if>) m
|
||||
</select>
|
||||
<select id="selectActiveTasks" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterTaskRow">
|
||||
SELECT m.* FROM (SELECT t.id AS id, t.task_no AS taskNo, UPPER(t.module_type) AS moduleType, CASE WHEN UPPER(t.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(t.status) END AS status, t.user_id AS userId, t.device_id AS deviceId, t.created_at AS createdAt, t.finished_at AS finishedAt, t.updated_at AS updatedAt, t.source_file_count AS totalCount, t.success_file_count AS successCount, t.failed_file_count AS failedCount, 0 AS brand FROM biz_file_task t WHERE t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL') AND t.status IN ('PENDING','RUNNING','SCHEDULED')<if test='userIds != null'> AND t.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if> UNION ALL SELECT b.id, CONCAT('brand-', b.id), 'BRAND', CASE WHEN UPPER(b.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(b.status) END, b.user_id, b.device_id, b.created_at, CASE WHEN b.status IN ('cancelled','failed','success') THEN b.updated_at END, b.updated_at, b.progress_total, b.progress_current, 0, 1 FROM brand_crawl_tasks b WHERE b.status IN ('pending','running')<if test='userIds != null'> AND b.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if>) m ORDER BY m.createdAt DESC, m.id DESC LIMIT #{limit}
|
||||
</select>
|
||||
<select id="selectBrandTaskById" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterTaskRow">
|
||||
SELECT b.id AS id, CONCAT('brand-', b.id) AS taskNo, 'BRAND' AS moduleType, CASE WHEN UPPER(b.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(b.status) END AS status, b.user_id AS userId, b.device_id AS deviceId, b.created_at AS createdAt, CASE WHEN b.status IN ('cancelled','failed','success') THEN b.updated_at END AS finishedAt, b.updated_at AS updatedAt, b.progress_total AS totalCount, b.progress_current AS successCount, 0 AS failedCount, 1 AS brand, b.error_message AS errorMessage FROM brand_crawl_tasks b WHERE b.id = #{id}
|
||||
</select>
|
||||
<select id="selectCollectDataKeywordStats" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterCollectStatsRow">
|
||||
SELECT t.id AS taskId, JSON_UNQUOTE(JSON_EXTRACT(t.result_json, '$.totalRows')) AS totalRows, JSON_UNQUOTE(JSON_EXTRACT(t.result_json, '$.processedRows')) AS processedRows FROM biz_file_task t WHERE t.id IN <foreach collection='taskIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach> AND UPPER(t.module_type) = 'COLLECT_DATA' AND t.result_json IS NOT NULL
|
||||
</select>
|
||||
<select id="selectDeviceNames" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterDeviceRow">
|
||||
SELECT d.device_id AS deviceId, MAX(d.device_name) AS deviceName FROM device_log_file d WHERE d.device_id IN <foreach collection='deviceIds' item='did' open='(' separator=',' close=')'>#{did}</foreach> GROUP BY d.device_id
|
||||
</select>
|
||||
<select id="selectFileResultShops" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterShopRow">
|
||||
SELECT f.task_id AS taskId, f.source_filename AS shop FROM biz_file_result f JOIN biz_file_task ft ON ft.id = f.task_id AND ft.module_type IN ('PATROL_DELETE','PRICE_TRACK','PRODUCT_RISK_RESOLVE','QUERY_ASIN','SHOP_DATA_CRAWL','SHOP_MATCH') WHERE f.task_id IN <foreach collection='taskIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach> AND f.source_filename IS NOT NULL AND f.source_filename != '' GROUP BY f.task_id, f.source_filename
|
||||
</select>
|
||||
<select id="selectPublishShopStats" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterShopStatRow">
|
||||
SELECT p.shop_name AS scopeKey, COUNT(*) AS total, SUM(UPPER(p.status) = 'SUCCESS') AS success, SUM(UPPER(p.status) = 'FAILED') AS failed FROM biz_publish_file p WHERE p.task_id = #{taskId} AND p.shop_name IS NOT NULL AND p.shop_name != '' GROUP BY p.shop_name ORDER BY COUNT(*) DESC, p.shop_name LIMIT 200
|
||||
</select>
|
||||
<select id="selectPublishShops" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterShopRow">
|
||||
SELECT p.task_id AS taskId, p.shop_name AS shop FROM biz_publish_file p WHERE p.task_id IN <foreach collection='taskIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach> AND p.shop_name IS NOT NULL AND p.shop_name != '' GROUP BY p.task_id, p.shop_name
|
||||
</select>
|
||||
<select id="selectResultItemShopStats" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterShopStatRow">
|
||||
SELECT i.scope_key AS scopeKey, COUNT(*) AS total, SUM(UPPER(i.status) = 'SUCCESS') AS success, SUM(UPPER(i.status) = 'FAILED') AS failed FROM biz_task_result_item i WHERE i.task_id = #{taskId} AND i.scope_key IS NOT NULL AND i.scope_key != '' GROUP BY i.scope_key ORDER BY COUNT(*) DESC, i.scope_key LIMIT 200
|
||||
</select>
|
||||
<select id="selectShopNames" resultType="string">
|
||||
SELECT DISTINCT s.shop_name FROM biz_shop_manage s WHERE 1 = 1<if test='userIds != null'> AND s.created_by_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if> ORDER BY s.shop_name LIMIT 2000
|
||||
</select>
|
||||
<select id="selectSnapshots" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterSnapshotRow">
|
||||
SELECT s.task_id AS taskId, s.module_type AS moduleType, s.total_count AS totalCount, s.success_count AS successCount, s.failed_count AS failedCount, s.pending_count AS pendingCount, s.current_scope_key AS currentScopeKey, s.message AS message FROM biz_task_progress_snapshot s WHERE s.task_id IN <foreach collection='taskIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>
|
||||
</select>
|
||||
<select id="selectTaskByTaskNo" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterTaskRow">
|
||||
SELECT t.id AS id, t.task_no AS taskNo, UPPER(t.module_type) AS moduleType, CASE WHEN UPPER(t.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(t.status) END AS status, t.user_id AS userId, t.device_id AS deviceId, t.created_at AS createdAt, t.finished_at AS finishedAt, t.updated_at AS updatedAt, t.source_file_count AS totalCount, t.success_file_count AS successCount, t.failed_file_count AS failedCount, 0 AS brand, t.error_message AS errorMessage FROM biz_file_task t WHERE t.task_no = #{taskNo} AND t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL') LIMIT 1
|
||||
</select>
|
||||
<select id="selectTaskCountries" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterCountryRow">
|
||||
SELECT t.id AS taskId, COALESCE(NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.filters.countryCode')), ''), 'null'),NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.countryCode')), ''), 'null'),NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.country')), ''), 'null'),NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.publish_country')), ''), 'null'),NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.countryCodes')), ''), 'null'),NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.country_codes')), ''), 'null'),NULLIF(NULLIF(JSON_UNQUOTE(JSON_EXTRACT(t.request_json, '$.filters.countryCodes')), ''), 'null')) AS country FROM biz_file_task t WHERE t.id IN <foreach collection='taskIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>
|
||||
</select>
|
||||
<select id="selectTaskPage" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterTaskRow">
|
||||
SELECT m.* FROM (SELECT t.id AS id, t.task_no AS taskNo, UPPER(t.module_type) AS moduleType, CASE WHEN UPPER(t.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(t.status) END AS status, t.user_id AS userId, t.device_id AS deviceId, t.created_at AS createdAt, t.finished_at AS finishedAt, t.updated_at AS updatedAt, t.source_file_count AS totalCount, t.success_file_count AS successCount, t.failed_file_count AS failedCount, 0 AS brand FROM biz_file_task t WHERE t.module_type IN ('PUBLISH','DELETE_BRAND','PRODUCT_RISK_RESOLVE','PRICE_TRACK','SHOP_MATCH','PATROL_DELETE','QUERY_ASIN','WITHDRAW','APPEARANCE_PATENT','SIMILAR_ASIN','COLLECT_DATA','SHOP_DATA_CRAWL')<if test='userIds != null'> AND t.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if><if test='moduleType != null'> AND UPPER(t.module_type) = #{moduleType}</if><if test='statuses != null'> AND CASE WHEN UPPER(t.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(t.status) END IN <foreach collection='statuses' item='st' open='(' separator=',' close=')'>#{st}</foreach></if><if test='startTime != null'> AND t.created_at >= #{startTime}</if><if test='endTime != null'> AND t.created_at <= #{endTime}</if><if test='shop != null'> AND (EXISTS (SELECT 1 FROM biz_publish_file p WHERE p.task_id = t.id AND LOWER(TRIM(p.shop_name)) = LOWER(TRIM(#{shop}))) OR (t.module_type IN ('PATROL_DELETE','PRICE_TRACK','PRODUCT_RISK_RESOLVE','QUERY_ASIN','SHOP_DATA_CRAWL','SHOP_MATCH') AND EXISTS (SELECT 1 FROM biz_file_result f WHERE f.task_id = t.id AND LOWER(TRIM(f.source_filename)) = LOWER(TRIM(#{shop})))))</if> UNION ALL SELECT b.id, CONCAT('brand-', b.id), 'BRAND', CASE WHEN UPPER(b.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(b.status) END, b.user_id, b.device_id, b.created_at, CASE WHEN b.status IN ('cancelled','failed','success') THEN b.updated_at END, b.updated_at, b.progress_total, b.progress_current, 0, 1 FROM brand_crawl_tasks b WHERE 1 = 1<if test='userIds != null'> AND b.user_id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach></if><if test='moduleType != null'> AND 'BRAND' = #{moduleType}</if><if test='statuses != null'> AND CASE WHEN UPPER(b.status) = 'CANCELED' THEN 'CANCELLED' ELSE UPPER(b.status) END IN <foreach collection='statuses' item='st' open='(' separator=',' close=')'>#{st}</foreach></if><if test='startTime != null'> AND b.created_at >= #{startTime}</if><if test='endTime != null'> AND b.created_at <= #{endTime}</if><if test='shop != null'> AND 1 = 0</if>) m ORDER BY m.createdAt DESC, m.id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
<select id="selectUserIdsByUsername" resultType="long">
|
||||
SELECT id FROM users WHERE username LIKE CONCAT('%', #{keyword}, '%') LIMIT 500
|
||||
</select>
|
||||
<select id="selectUsernames" resultType="com.nanri.aiimage.modules.taskcenter.model.dto.TaskCenterUserRow">
|
||||
SELECT id AS userId, username FROM users WHERE id IN <foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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.usersecret.mapper.UserSecretUsageMapper">
|
||||
<!-- 由注解 SQL 平移而来,SQL 文本未改写;语句 id 与接口方法名逐字一致。
|
||||
等价性由 MigratedSqlEquivalenceTest 按搬迁前的 fixture 逐条比对。 -->
|
||||
<delete id="deleteBefore">
|
||||
DELETE FROM biz_user_secret_usage_daily
|
||||
WHERE business_date < #{cutoff}
|
||||
LIMIT #{batchSize}
|
||||
</delete>
|
||||
<insert id="increment">
|
||||
INSERT INTO biz_user_secret_usage_daily (user_id, module_key, business_date, call_count, created_at, updated_at)
|
||||
VALUES (#{userId}, #{moduleKey}, #{businessDate}, #{count}, NOW(), NOW())
|
||||
ON DUPLICATE KEY UPDATE call_count = call_count + #{count}, updated_at = NOW()
|
||||
</insert>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user