feat: 优化
This commit is contained in:
@@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.tik.muye.aiagent.dal;
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
|
||||
/**
|
||||
* AI智能体收藏 DO
|
||||
*/
|
||||
@TenantIgnore
|
||||
@TableName("muye_ai_agent_favorite")
|
||||
@KeySequence("muye_ai_agent_favorite_seq")
|
||||
@Data
|
||||
|
||||
@@ -20,7 +20,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
@Validated
|
||||
public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService {
|
||||
|
||||
private static final ErrorCode FAVORITE_EXISTS = new ErrorCode(1_013_001_000, "已收藏该智能体");
|
||||
private static final ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_013_001_001, "未收藏该智能体");
|
||||
|
||||
@Resource
|
||||
@@ -28,10 +27,10 @@ public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService {
|
||||
|
||||
@Override
|
||||
public Long createFavorite(Long userId, Long agentId) {
|
||||
// 检查是否已收藏
|
||||
// 检查是否已收藏(幂等:已存在则直接返回)
|
||||
AiAgentFavoriteDO existFavorite = aiAgentFavoriteMapper.selectByUserIdAndAgentId(userId, agentId);
|
||||
if (existFavorite != null) {
|
||||
throw exception(FAVORITE_EXISTS);
|
||||
return existFavorite.getId();
|
||||
}
|
||||
|
||||
// 创建收藏
|
||||
|
||||
Reference in New Issue
Block a user