【优化】角色分类列表 group

This commit is contained in:
cherishsince 2024-05-15 18:16:50 +08:00
parent 78bb2d1dc8
commit 314a015a2e
2 changed files with 3 additions and 2 deletions

View File

@ -50,8 +50,9 @@ public interface AiChatRoleMapper extends BaseMapperX<AiChatRoleDO> {
default List<AiChatRoleDO> selectListGroupByCategory(Integer status) { default List<AiChatRoleDO> selectListGroupByCategory(Integer status) {
return selectList(new LambdaQueryWrapperX<AiChatRoleDO>() return selectList(new LambdaQueryWrapperX<AiChatRoleDO>()
.select(AiChatRoleDO::getCategory)
.eq(AiChatRoleDO::getStatus, status) .eq(AiChatRoleDO::getStatus, status)
.apply("GROUP BY category")); .groupBy(AiChatRoleDO::getCategory));
} }
} }

View File

@ -132,7 +132,7 @@ public class AiChatRoleServiceImpl implements AiChatRoleService {
@Override @Override
public List<String> getChatRoleCategoryList() { public List<String> getChatRoleCategoryList() {
List<AiChatRoleDO> list = chatRoleMapper.selectListGroupByCategory(CommonStatusEnum.ENABLE.getStatus()); List<AiChatRoleDO> list = chatRoleMapper.selectListGroupByCategory(CommonStatusEnum.ENABLE.getStatus());
return convertList(list, AiChatRoleDO::getName); return convertList(list, AiChatRoleDO::getCategory);
} }
} }