增加访客记录接口,并发插入错误兼容处理

This commit is contained in:
tianfeng 2026-03-09 16:50:29 +08:00
parent db8930a76e
commit 4cba23c4c9

View File

@ -13,6 +13,8 @@ import com.red.circle.other.infra.database.rds.service.user.user.UserInterviewSe
import com.red.circle.tool.core.text.StringUtils; import com.red.circle.tool.core.text.StringUtils;
import java.util.Objects; import java.util.Objects;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@ -20,6 +22,7 @@ import org.springframework.stereotype.Component;
* *
* @author pengliang on 2023/8/10 * @author pengliang on 2023/8/10
*/ */
@Slf4j
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class UserSupportRelationVisitorAddCmdExe { public class UserSupportRelationVisitorAddCmdExe {
@ -46,10 +49,15 @@ public class UserSupportRelationVisitorAddCmdExe {
return; return;
} }
userInterviewService.save(new UserInterview() try {
.setUserId(cmd.getReqUserId()) userInterviewService.save(new UserInterview()
.setInterviewUserId(cmd.getUserId()) .setUserId(cmd.getReqUserId())
); .setInterviewUserId(cmd.getUserId())
);
} catch (DuplicateKeyException e) {
log.warn("relation_user_interview duplicate, userId={}, interviewUserId={}, ignored", cmd.getReqUserId(), cmd.getUserId());
return;
}
userRelationsCalculatorGateway.process( userRelationsCalculatorGateway.process(
new UserRelationsCalculator() new UserRelationsCalculator()
.setUserId(cmd.getUserId()) .setUserId(cmd.getUserId())