zhou zhou
18 小时以前 82624affb0251b75b62b35567d3eb260c06efe78
rsf-server/src/main/java/com/vincent/rsf/server/ai/service/impl/AiParamServiceImpl.java
@@ -8,6 +8,8 @@
import com.vincent.rsf.server.ai.dto.AiParamValidateResultDto;
import com.vincent.rsf.server.ai.entity.AiParam;
import com.vincent.rsf.server.ai.mapper.AiParamMapper;
import com.vincent.rsf.server.ai.store.AiConfigCacheStore;
import com.vincent.rsf.server.ai.store.AiConversationCacheStore;
import com.vincent.rsf.server.ai.service.AiParamService;
import com.vincent.rsf.server.system.enums.StatusType;
import lombok.RequiredArgsConstructor;
@@ -24,7 +26,8 @@
public class AiParamServiceImpl extends ServiceImpl<AiParamMapper, AiParam> implements AiParamService {
    private final AiParamValidationSupport aiParamValidationSupport;
    private final AiRedisSupport aiRedisSupport;
    private final AiConfigCacheStore aiConfigCacheStore;
    private final AiConversationCacheStore aiConversationCacheStore;
    @Override
    public AiParam getActiveParam(Long tenantId) {
@@ -97,7 +100,8 @@
        if (!super.updateById(target)) {
            throw new CoolException("设置默认 AI 参数失败");
        }
        aiRedisSupport.evictTenantConfigCaches(tenantId);
        aiConfigCacheStore.evictTenantConfigCaches(tenantId);
        aiConversationCacheStore.evictTenantRuntimeCaches(tenantId);
        return target;
    }
@@ -138,7 +142,8 @@
    public boolean save(AiParam entity) {
        boolean saved = super.save(entity);
        if (saved && entity != null && entity.getTenantId() != null) {
            aiRedisSupport.evictTenantConfigCaches(entity.getTenantId());
            aiConfigCacheStore.evictTenantConfigCaches(entity.getTenantId());
            aiConversationCacheStore.evictTenantRuntimeCaches(entity.getTenantId());
        }
        return saved;
    }
@@ -147,7 +152,8 @@
    public boolean updateById(AiParam entity) {
        boolean updated = super.updateById(entity);
        if (updated && entity != null && entity.getTenantId() != null) {
            aiRedisSupport.evictTenantConfigCaches(entity.getTenantId());
            aiConfigCacheStore.evictTenantConfigCaches(entity.getTenantId());
            aiConversationCacheStore.evictTenantRuntimeCaches(entity.getTenantId());
        }
        return updated;
    }
@@ -166,7 +172,10 @@
                    .map(AiParam::getTenantId)
                    .filter(java.util.Objects::nonNull)
                    .distinct()
                    .forEach(aiRedisSupport::evictTenantConfigCaches);
                    .forEach(tenantId -> {
                        aiConfigCacheStore.evictTenantConfigCaches(tenantId);
                        aiConversationCacheStore.evictTenantRuntimeCaches(tenantId);
                    });
        }
        return removed;
    }