refactor(auth): 新增 AUTO_TK 功能权限与过期时间字段

This commit is contained in:
2026-04-20 16:28:51 +08:00
parent bfe6b1bc5e
commit cdf31c3e13
8 changed files with 29 additions and 3 deletions

View File

@@ -153,7 +153,10 @@ public class FeatureAuthComponent {
} }
// 校验功能代码(如果指定) // 校验功能代码(如果指定)
if (StrUtil.isNotBlank(requiredFeatureCode) && !requiredFeatureCode.equals(payload.getFeatureCode())) { // 功能码统一按忽略大小写比较,避免发证与校验阶段大小写不一致
if (StrUtil.isNotBlank(requiredFeatureCode)
&& (StrUtil.isBlank(payload.getFeatureCode())
|| !requiredFeatureCode.equalsIgnoreCase(payload.getFeatureCode()))) {
log.warn("功能代码不匹配,需要: {}, Ticket: {}", requiredFeatureCode, payload.getFeatureCode()); log.warn("功能代码不匹配,需要: {}, Ticket: {}", requiredFeatureCode, payload.getFeatureCode());
throw new BusinessException(ErrorCode.TICKET_FEATURE_MISMATCH, "功能代码不匹配"); throw new BusinessException(ErrorCode.TICKET_FEATURE_MISMATCH, "功能代码不匹配");
} }

View File

@@ -135,6 +135,9 @@ public class FeatureAuthController {
case "BROTHER": case "BROTHER":
case "BIG_BROTHER": case "BIG_BROTHER":
return tenant.getBrotherExpireTime(); return tenant.getBrotherExpireTime();
case "AUTO_TK":
// auto_tk 当前走租户通用到期时间
return tenant.getAutoTkExpireTime();
default: default:
return tenant.getExpireTime(); return tenant.getExpireTime();
} }
@@ -160,6 +163,8 @@ public class FeatureAuthController {
return user.getBigBrother() != null && user.getBigBrother() == 1; return user.getBigBrother() != null && user.getBigBrother() == 1;
case "WEB_AI": case "WEB_AI":
return user.getWebAi() != null && user.getWebAi() == 1; return user.getWebAi() != null && user.getWebAi() == 1;
case "AUTO_TK":
return user.getAutoTk() != null && user.getAutoTk() == 1;
default: default:
// 未知功能代码,默认不允许 // 未知功能代码,默认不允许
return false; return false;

View File

@@ -39,8 +39,9 @@ public class TaskExecuteController {
* 2. 请求头 X-Machine-Id: 与 Ticket 中一致的设备 ID * 2. 请求头 X-Machine-Id: 与 Ticket 中一致的设备 ID
*/ */
@PostMapping("/execute-task") @PostMapping("/execute-task")
@RequireFeatureTicket(featureCode = "CRAWL") // 任务执行接口改为校验 auto_tk 功能票据
@ApiOperation(value = "执行任务", notes = "需要 Feature Ticket 校验,功能代码: CRAWL") @RequireFeatureTicket(featureCode = "auto_tk")
@ApiOperation(value = "执行任务", notes = "需要 Feature Ticket 校验,功能代码: auto_tk")
public BaseResponse<Map<String, Object>> executeTask( public BaseResponse<Map<String, Object>> executeTask(
@RequestBody Map<String, Object> taskParams, @RequestBody Map<String, Object> taskParams,
HttpServletRequest request) { HttpServletRequest request) {

View File

@@ -107,6 +107,12 @@ public class SystemTenant {
@TableField(value = "brother_expire_time") @TableField(value = "brother_expire_time")
private LocalDateTime brotherExpireTime; private LocalDateTime brotherExpireTime;
/**
* tks私信过期时间
*/
@ApiModelProperty(value="大哥过期时间")
@TableField(value = "auto_tk_expire_time")
private LocalDateTime autoTkExpireTime;
/** /**
* 账号数量 * 账号数量

View File

@@ -196,6 +196,10 @@ public class SystemUsers {
@ApiModelProperty(value = "能否登录智能回复客户端") @ApiModelProperty(value = "能否登录智能回复客户端")
private Byte webAi; private Byte webAi;
@TableField(value = "auto_tk")
@ApiModelProperty(value = "tk自动回复")
private Byte autoTk;
@TableField(value = "points") @TableField(value = "points")
@ApiModelProperty(value = "用户积分") @ApiModelProperty(value = "用户积分")
private Integer points; private Integer points;

View File

@@ -51,6 +51,8 @@ public class SystemUsersVO {
private Byte webAi; private Byte webAi;
private Byte autoTk;
private Boolean aiReplayEnabled; private Boolean aiReplayEnabled;
private Boolean crawlEnabled; private Boolean crawlEnabled;
@@ -61,5 +63,7 @@ public class SystemUsersVO {
private Boolean webAiEnabled; private Boolean webAiEnabled;
private Boolean autoTkEnabled;
private Integer points; private Integer points;
} }

View File

@@ -128,6 +128,7 @@ public class LoginService {
vo.setBigBrotherEnabled(isEnabled(user.getBigBrother())); vo.setBigBrotherEnabled(isEnabled(user.getBigBrother()));
vo.setAiChatEnabled(isEnabled(user.getAiChat())); vo.setAiChatEnabled(isEnabled(user.getAiChat()));
vo.setWebAiEnabled(isEnabled(user.getWebAi())); vo.setWebAiEnabled(isEnabled(user.getWebAi()));
vo.setAutoTkEnabled(isEnabled(user.getAutoTk()));
} }
private boolean isEnabled(Byte value) { private boolean isEnabled(Byte value) {

View File

@@ -102,6 +102,8 @@ sa-token:
token-style: random-128 token-style: random-128
# 是否输出操作日志 # 是否输出操作日志
is-log: true is-log: true
#活跃时间自动续签token
active-timeout: 86400
md5: md5: