package com.emotion.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.emotion.entity.AiEndpointConfig; import com.emotion.mapper.AiEndpointConfigMapper; import com.emotion.service.AiEndpointConfigService; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import java.util.List; @Service public class AiEndpointConfigServiceImpl extends ServiceImpl implements AiEndpointConfigService { @Override public List listVisible() { return list(new LambdaQueryWrapper() .eq(AiEndpointConfig::getIsDeleted, 0) .orderByDesc(AiEndpointConfig::getCreateTime)); } @Override public AiEndpointConfig saveEndpoint(AiEndpointConfig endpoint) { applyDefaults(endpoint); save(endpoint); return endpoint; } @Override public AiEndpointConfig updateEndpoint(AiEndpointConfig endpoint) { updateById(endpoint); return getById(endpoint.getId()); } @Override public AiEndpointConfig getEnabledById(String id) { AiEndpointConfig endpoint = getById(id); if (endpoint == null || endpoint.getIsEnabled() == null || endpoint.getIsEnabled() != 1) { return null; } return endpoint; } private void applyDefaults(AiEndpointConfig endpoint) { if (!StringUtils.hasText(endpoint.getResponseMode())) { endpoint.setResponseMode("streaming"); } if (endpoint.getSupportStream() == null) { endpoint.setSupportStream(1); } if (endpoint.getIsEnabled() == null) { endpoint.setIsEnabled(1); } if (endpoint.getTimeoutMs() == null) { endpoint.setTimeoutMs(60000); } } }