feat: 优化

This commit is contained in:
2026-02-26 20:27:41 +08:00
parent 2d96e8ca4e
commit 72fa2c63a1
4 changed files with 52 additions and 53 deletions

View File

@@ -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

View File

@@ -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();
}
// 创建收藏