【优化】AI 角色分类处理用户角色,为空情况

This commit is contained in:
cherishsince 2024-05-15 23:13:54 +08:00
parent b31e919d52
commit e6fefa06b7

View File

@ -14,6 +14,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@ -132,7 +134,7 @@ public class AiChatRoleServiceImpl implements AiChatRoleService {
@Override
public List<String> getChatRoleCategoryList() {
List<AiChatRoleDO> list = chatRoleMapper.selectListGroupByCategory(CommonStatusEnum.ENABLE.getStatus());
return convertList(list, AiChatRoleDO::getCategory);
return convertList(list.stream().filter(Objects::nonNull).collect(Collectors.toList()), AiChatRoleDO::getCategory);
}
}