feat: (REQ-3057) 人群列表排序修复

This commit is contained in:
xudawei 2024-11-21 10:37:01 +08:00
parent 3f4c7c3ff9
commit 7e6911dc7c
5 changed files with 21 additions and 11 deletions

View File

@ -24,7 +24,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Set;
import java.util.List;
/**
* 群聊
@ -69,7 +69,7 @@ public interface ChatGroupApi {
* 人群列表
*/
@PostMapping("api/im/chat/group/listCrowType")
ApiResult<Set<ChatGroupCrowTypeResp>> listCrowType(@RequestBody @Validated ListCrowTypesReq req);
ApiResult<List<ChatGroupCrowTypeResp>> listCrowType(@RequestBody @Validated ListCrowTypesReq req);
/**
* 加入群聊

View File

@ -71,9 +71,9 @@ public class ChatGroupCreateReq implements Serializable {
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum CrowTypeEnum {
WORKSPACE("workspace", "项目","项目管理人员","除去班组长及工人,包含项目经理、施工员、财务、安全员、安全员、安全员......."),
OU("ou", "单位" ,"本单位项目管理人员", "本单位项目的管理人员,除去班组长及工人,包含项目经理、施工员、财务、安全员、安全员、安全员......."),
TEAM("team", "班组", "项目班组群", "本项目内的班组长、带班长、工人"),
WORKSPACE("workspace", "项目","项目管理人员","除去班组长及工人,包含项目经理、施工员、财务、安全员、安全员、安全员.......",1),
OU("ou", "单位" ,"本单位项目管理人员", "本单位项目的管理人员,除去班组长及工人,包含项目经理、施工员、财务、安全员、安全员、安全员.......",2),
TEAM("team", "班组", "项目班组群", "本项目内的班组长、带班长、工人",3),
;
private String code;
@ -84,6 +84,8 @@ public class ChatGroupCreateReq implements Serializable {
private String content;
private Integer orderBy;
public static Set<CrowTypeEnum> workspaceOu() {
return Sets.newHashSet(WORKSPACE,OU);
}

View File

@ -1,13 +1,15 @@
package cn.axzo.im.center.api.vo.resp;
import cn.axzo.im.center.api.vo.req.chatgroup.ChatGroupCreateReq;
import com.google.common.collect.Sets;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -40,11 +42,12 @@ public class ChatGroupCrowTypeResp {
/**
* 构建人群列表返回对象
*/
public static Set<ChatGroupCrowTypeResp> buildRespByCrowType(Set<ChatGroupCreateReq.CrowTypeEnum> crowTypeSet) {
public static List<ChatGroupCrowTypeResp> buildRespByCrowType(Set<ChatGroupCreateReq.CrowTypeEnum> crowTypeSet) {
if (CollectionUtils.isEmpty(crowTypeSet)) {
return Sets.newHashSet();
return Lists.newArrayList();
}
return crowTypeSet.stream().map(ChatGroupCreateReq.CrowTypeEnum::buildCrowTypeRespByEnum).collect(Collectors.toSet());
List<ChatGroupCreateReq.CrowTypeEnum> crowTypes = crowTypeSet.stream().sorted(Comparator.comparingInt(ChatGroupCreateReq.CrowTypeEnum::getOrderBy)).collect(Collectors.toList());
return crowTypes.stream().map(ChatGroupCreateReq.CrowTypeEnum::buildCrowTypeRespByEnum).collect(Collectors.toList());
}
}

View File

@ -28,11 +28,11 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
/**
@ -103,7 +103,7 @@ public class ChatGroupController implements ChatGroupApi {
* 人群列表
*/
@Override
public ApiResult<Set<ChatGroupCrowTypeResp>> listCrowType(@RequestBody @Validated ListCrowTypesReq req) {
public ApiResult<List<ChatGroupCrowTypeResp>> listCrowType(@RequestBody @Validated ListCrowTypesReq req) {
Set<ChatGroupCreateReq.CrowTypeEnum> crowTypeEnums = chatGroupService.fetchCrowTypeByWorkspacePersonId(req.getWorkspaceId(), req.getPersonId());
return ApiResult.ok(ChatGroupCrowTypeResp.buildRespByCrowType(crowTypeEnums));
}

View File

@ -65,6 +65,7 @@ import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Sets;
@ -420,6 +421,10 @@ public class ChatGroupServiceImpl extends ServiceImpl<ChatGroupMapper, ChatGrou
Set<ChatGroupCreateReq.CrowTypeEnum> roleResult = Sets.newHashSet();
if (CollectionUtils.isNotEmpty(saasRoleUserV2DTOS)) {
for (SaasRoleUserV2DTO saasRoleUserV2DTO : saasRoleUserV2DTOS) {
if (Objects.isNull(saasRoleUserV2DTO.getSaasRole()) || StringUtils.isBlank(saasRoleUserV2DTO.getSaasRole().getRoleType())) {
continue;
}
if (RoleTypeEnum.SUPER_ADMIN.apply(saasRoleUserV2DTO.getSaasRole().getRoleType())) {
roleResult = ChatGroupCreateReq.CrowTypeEnum.workspaceOu();
break;