feat(设备日志/后台配置/密钥检测): 补齐已上线未提交的设备日志与app_config,并合入检测模型解耦
三部分均已部署到双节点(当前线上 JAR 009efc3e),本次补齐仓库状态,避免"已上线未提交" 在后续最小构建比对里被误判。 - 设备日志管理:modules/devicelog + DeviceLogOssProperties(主机B 独立 MinIO,仅内网) + V127 device_log_file/device_log_config + admin-vue 日志管理页;客户端/麦象按 offset 增量上报(X-Internal-Token),查询仅超管 - 后台通用配置:modules/appconfig + V128 app_config 键值表;工作台「开店流程」密码改服务端 校验(POST /api/kd-flow/verify),改密码只需 UPDATE 该行、客户端无需重新发版 - 密钥检测模型解耦:新增 aiimage.user-secret.check-model(env AIIMAGE_USER_SECRET_CHECK_MODEL), 默认 doubao-seed-2-0-lite-260215 —— 同系列 mini 在中继分组下无可用渠道(503 model_not_found), 实测 lite 可路由;UserSecretModule 去掉 LlmTarget 改 resolveLlmHost,探测日志带 model= - 前端:密钥面板「检测配置密钥」按钮不再折行;client-changelog 补 4.0.19/4.0.20/4.0.21 条目 注:application.yml 与 PropertiesConfig 同时承载上述多个部分,故未按功能拆分提交
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
package com.nanri.aiimage.modules.appconfig.controller;
|
||||
|
||||
import com.nanri.aiimage.common.api.ApiResponse;
|
||||
import com.nanri.aiimage.modules.appconfig.service.KdFlowService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工作台「开店流程」模块访问密码校验(公开接口,密码本身就是凭据,不额外要求登录态)。
|
||||
*
|
||||
* <p>客户端只在用户点开「开店流程」分组时调用一次;返回体只给 ok 与中文提示,
|
||||
* 不回显服务端配置的密码。
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "开店流程访问校验", description = "工作台「开店流程」模块访问密码的服务端校验")
|
||||
public class KdFlowController {
|
||||
|
||||
private final KdFlowService kdFlowService;
|
||||
|
||||
@PostMapping("/api/kd-flow/verify")
|
||||
@Operation(summary = "校验开店流程访问密码",
|
||||
description = "密码存 app_config.kd_flow_password;改密码只需 UPDATE 该行,客户端无需重新发布")
|
||||
public ApiResponse<Map<String, Object>> verify(@RequestBody(required = false) Map<String, String> body,
|
||||
HttpServletRequest request) {
|
||||
String input = body == null ? null : body.get("password");
|
||||
boolean ok = kdFlowService.matches(input);
|
||||
// 只记输入长度与结果,绝不回显密码本身
|
||||
log.info("[开店流程] 校验请求 remoteAddr={} 输入为空={} 结果={}",
|
||||
request.getRemoteAddr(), input == null || input.isBlank(), ok ? "通过" : "拒绝");
|
||||
if (!ok) {
|
||||
return ApiResponse.fail("密码错误");
|
||||
}
|
||||
return ApiResponse.success("验证通过", Map.of("ok", true));
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.nanri.aiimage.modules.appconfig.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nanri.aiimage.modules.appconfig.model.entity.AppConfigEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AppConfigMapper extends BaseMapper<AppConfigEntity> {
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.nanri.aiimage.modules.appconfig.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 通用应用配置(键值)。首个用途:工作台「开店流程」模块访问密码(key = kd_flow_password)。
|
||||
* <p>只放这类低价值、需要"改一行即生效"的口令,不放密钥类敏感配置。
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_config")
|
||||
public class AppConfigEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 配置键(唯一) */
|
||||
private String configKey;
|
||||
|
||||
/** 配置值 */
|
||||
private String configValue;
|
||||
|
||||
/** 说明 */
|
||||
private String remark;
|
||||
|
||||
/** 更新时间,由数据库 CURRENT_TIMESTAMP 维护 */
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.nanri.aiimage.modules.appconfig.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nanri.aiimage.modules.appconfig.mapper.AppConfigMapper;
|
||||
import com.nanri.aiimage.modules.appconfig.model.entity.AppConfigEntity;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 工作台「开店流程」模块访问密码的服务端校验。
|
||||
*
|
||||
* <p>此前密码写死在客户端源码(KD_FLOW_PASSWORD),改密码必须重新打包装包发给全部用户;
|
||||
* 改由服务端比对后,改密码只需 UPDATE app_config 一行(key = kd_flow_password)。
|
||||
*
|
||||
* <p>不缓存:调用频次极低(用户点一次分组头一次),且改密码后应立即生效。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class KdFlowService {
|
||||
|
||||
/** app_config 中存放开店流程访问密码的键名 */
|
||||
public static final String PASSWORD_KEY = "kd_flow_password";
|
||||
|
||||
private final AppConfigMapper appConfigMapper;
|
||||
|
||||
/** 读取服务端配置的密码;未配置返回 null。 */
|
||||
public String configuredPassword() {
|
||||
AppConfigEntity row = appConfigMapper.selectOne(new LambdaQueryWrapper<AppConfigEntity>()
|
||||
.eq(AppConfigEntity::getConfigKey, PASSWORD_KEY)
|
||||
.last("LIMIT 1"));
|
||||
return row == null ? null : row.getConfigValue();
|
||||
}
|
||||
|
||||
/** 校验用户输入的密码。未配置密码时一律判失败(宁可锁死也不放行)。 */
|
||||
public boolean matches(String input) {
|
||||
String expect = configuredPassword();
|
||||
if (expect == null || expect.isBlank()) {
|
||||
log.warn("[开店流程] app_config 未配置 {},本次校验一律判失败", PASSWORD_KEY);
|
||||
return false;
|
||||
}
|
||||
String actual = input == null ? "" : input.trim();
|
||||
boolean ok = expect.equals(actual);
|
||||
log.info("[开店流程] 服务端校验 输入长度={} 结果={}", actual.length(), ok ? "通过" : "不通过");
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user