fix: Webhook同步修复——实现findUserIdByPhone,补充PROCESSING状态coverUrl同步
1. 实现 findUserIdByPhone() 方法(原为 TODO 占位),注入 SysUserMapper 按手机号查询用户 2. updateProcessing() 方法补充 coverUrl 字段同步,AI创作过程中推送的封面图不再被丢弃 3. insertNewWork 中增加 WARN 日志,记录手机号未找到用户或手机号为空的情况 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6365dd8dd0
commit
5bb159358f
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.competition.common.enums.Visibility;
|
||||
import com.competition.modules.leai.util.LeaiUtil;
|
||||
import com.competition.modules.sys.entity.SysUser;
|
||||
import com.competition.modules.sys.mapper.SysUserMapper;
|
||||
import com.competition.modules.ugc.entity.UgcWork;
|
||||
import com.competition.modules.ugc.entity.UgcWorkPage;
|
||||
import com.competition.modules.ugc.mapper.UgcWorkMapper;
|
||||
@ -28,6 +30,7 @@ public class LeaiSyncService implements ILeaiSyncService {
|
||||
private final UgcWorkMapper ugcWorkMapper;
|
||||
private final UgcWorkPageMapper ugcWorkPageMapper;
|
||||
private final LeaiApiClient leaiApiClient;
|
||||
private final SysUserMapper sysUserMapper;
|
||||
|
||||
/**
|
||||
* V4.0 核心同步逻辑
|
||||
@ -128,7 +131,11 @@ public class LeaiSyncService implements ILeaiSyncService {
|
||||
Long userId = findUserIdByPhone(phone);
|
||||
if (userId != null) {
|
||||
work.setUserId(userId);
|
||||
} else {
|
||||
log.warn("通过手机号未找到对应用户,作品将无法关联用户: remoteWorkId={}, phone={}", remoteWorkId, phone);
|
||||
}
|
||||
} else if (phone == null) {
|
||||
log.warn("Webhook回调中手机号为空,无法关联用户: remoteWorkId={}", remoteWorkId);
|
||||
}
|
||||
|
||||
ugcWorkMapper.insert(work);
|
||||
@ -165,6 +172,12 @@ public class LeaiSyncService implements ILeaiSyncService {
|
||||
if (remoteData.containsKey("progressMessage")) {
|
||||
wrapper.set(UgcWork::getProgressMessage, LeaiUtil.toString(remoteData.get("progressMessage"), null));
|
||||
}
|
||||
// 同步封面图(AI创作过程中可能推送 coverUrl)
|
||||
Object coverUrl = remoteData.get("coverUrl");
|
||||
if (coverUrl == null) coverUrl = remoteData.get("cover_url");
|
||||
if (coverUrl != null) {
|
||||
wrapper.set(UgcWork::getCoverUrl, coverUrl.toString());
|
||||
}
|
||||
wrapper.set(UgcWork::getModifyTime, LocalDateTime.now());
|
||||
|
||||
ugcWorkMapper.update(null, wrapper);
|
||||
@ -269,11 +282,12 @@ public class LeaiSyncService implements ILeaiSyncService {
|
||||
|
||||
/**
|
||||
* 通过手机号查找用户ID
|
||||
* 多租户场景:需要确定租户后查找
|
||||
*/
|
||||
private Long findUserIdByPhone(String phone) {
|
||||
// TODO: 如果需要按租户隔离,需要传入 orgId(即租户 code/tenant_code)查找租户再查找用户
|
||||
// 当前简化处理:直接通过手机号查用户
|
||||
return null; // 暂时不自动关联用户,后续通过 phone + orgId(租户 code)查询
|
||||
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysUser::getPhone, phone)
|
||||
.last("LIMIT 1");
|
||||
SysUser user = sysUserMapper.selectOne(wrapper);
|
||||
return user != null ? user.getId() : null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user