fix(video): AI 算法预置数据 @PostConstruct 插入时显式设置 creator/updater

启动时 initPresetAlgorithms() 在 @PostConstruct 执行,此时无登录上下文:
- DefaultDBFieldHandler.insertFill 在 getLoginUserId()==null 时不填充
  creator/updater
- SQL video_ai_algorithm.creator NOT NULL 约束触发
  "Column 'creator' cannot be null" 启动失败

手动设置 creator/updater = "1"(系统用户)作为系统级初始化的占位,
同时 update 分支也显式设置 updater 避免同类问题。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
lzh
2026-04-22 13:48:52 +08:00
parent 42cb3d9d57
commit 1ac72b23c5

View File

@@ -54,6 +54,9 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
});
}
/** 系统级初始化使用的 creator/updater@PostConstruct 无登录上下文时 MP 自动填充会留空 */
private static final String SYSTEM_USER = "1";
@PostConstruct
public void initPresetAlgorithms() {
for (Map.Entry<String, String[]> entry : PRESET_ALGORITHMS.entrySet()) {
@@ -68,6 +71,8 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
algo.setDescription(vals[2]);
algo.setParamSchema(vals[3]);
algo.setIsActive(true);
algo.setCreator(SYSTEM_USER);
algo.setUpdater(SYSTEM_USER);
algorithmMapper.add(algo);
log.info("[AI算法] 初始化预置算法: {}", code);
} else {
@@ -75,6 +80,7 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
existing.setTargetClass(vals[1]);
existing.setDescription(vals[2]);
existing.setParamSchema(vals[3]);
existing.setUpdater(SYSTEM_USER);
algorithmMapper.updateByCode(existing);
log.info("[AI算法] 校正预置算法数据: {}", code);
}