fix(cost-guard): 注解 SQL 收进 XML、新端点进守卫名单,并按实扫对齐 catch 棘轮
三格护栏红都在本笔自己头上:UserSecretUsageMapper/UserTaskGuardMapper 的 5 条 注解 SQL 迁进 mapper XML(两处语句台账同步);cost-guard 两个端点身份取自 JWT, 进 AdminApiGuardFilter 无条件名单而不是登记成「方法内自校验」;catch 静默棘轮 先摘掉 6 处能去的静默出口(含 resume 写失败被吞成「已继续任务」的假成功), 余下 6 处带 [cost-guard] 锚点的 fail-open 逐处记名入账。
This commit is contained in:
@@ -22,4 +22,23 @@
|
||||
updated_at = NOW()
|
||||
WHERE user_id = #{userId} AND module_key = #{moduleKey} AND business_date = #{businessDate}
|
||||
</update>
|
||||
<select id="sumByUserAndModule" resultType="com.nanri.aiimage.modules.usersecret.model.dto.UserSecretUsageAggregate">
|
||||
SELECT user_id AS userId,
|
||||
module_key AS moduleKey,
|
||||
COALESCE(SUM(call_count), 0) AS callCount,
|
||||
COALESCE(SUM(prompt_tokens + completion_tokens), 0) AS tokens
|
||||
FROM biz_user_secret_usage_daily
|
||||
WHERE business_date = #{businessDate}
|
||||
GROUP BY user_id, module_key
|
||||
</select>
|
||||
<select id="sumForUser" resultType="com.nanri.aiimage.modules.usersecret.model.dto.UserSecretUsageAggregate">
|
||||
SELECT user_id AS userId,
|
||||
module_key AS moduleKey,
|
||||
COALESCE(SUM(call_count), 0) AS callCount,
|
||||
COALESCE(SUM(prompt_tokens + completion_tokens), 0) AS tokens
|
||||
FROM biz_user_secret_usage_daily
|
||||
WHERE business_date = #{businessDate}
|
||||
AND user_id = #{userId}
|
||||
GROUP BY user_id, module_key
|
||||
</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.usersecret.mapper.UserTaskGuardMapper">
|
||||
<insert id="pause">
|
||||
INSERT INTO biz_user_task_guard (user_id, paused, reason, paused_at, updated_at)
|
||||
VALUES (#{userId}, 1, #{reason}, NOW(), NOW())
|
||||
ON DUPLICATE KEY UPDATE paused = 1, reason = #{reason},
|
||||
paused_at = NOW(), updated_at = NOW()
|
||||
</insert>
|
||||
<update id="resume">
|
||||
UPDATE biz_user_task_guard
|
||||
SET paused = 0, reason = '', paused_at = NULL, updated_at = NOW()
|
||||
WHERE user_id = #{userId}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user