fix:同步利元亨用户部门修改
This commit is contained in:
@@ -30,6 +30,7 @@ import com.honeycombis.honeycom.spdm.feign.RemoteTenantServiceFeign;
|
||||
import com.honeycombis.honeycom.spdm.feign.RemoteUserServiceFeign;
|
||||
import com.honeycombis.honeycom.spdm.util.PageResult;
|
||||
import com.honeycombis.honeycom.spdm.util.ResponseR;
|
||||
import com.honeycombis.honeycom.tenant.dto.SysDeptTreeAndListRequestDTO;
|
||||
import com.honeycombis.honeycom.tenant.entity.SysDeptEntity;
|
||||
import com.honeycombis.honeycom.tenant.entity.SysStaffEntity;
|
||||
import com.honeycombis.honeycom.tenant.vo.SysRoleVO;
|
||||
@@ -195,8 +196,8 @@ public class SpdmUserController {
|
||||
if (staffPage != null) {
|
||||
List<SysUserVO> userVOList = new ArrayList<>();
|
||||
staffPage.getRecords().forEach(i -> {
|
||||
R<SysUserVO> sysUserVO = remoteUserServiceFeign.getUserByUserId(Long.valueOf(i.getUserId()), SecurityConstants.FROM_IN, groupQueryDto.getTenantId());
|
||||
userVOList.add(sysUserVO.getData());
|
||||
// R<SysUserVO> sysUserVO = remoteUserServiceFeign.getUserByUserId(Long.valueOf(i.getUserId()), SecurityConstants.FROM_IN, groupQueryDto.getTenantId());
|
||||
userVOList.add(i.getUserInfo());
|
||||
});
|
||||
jsonObject.put("users", PageResult.of(staffPage.getTotal(), staffPage.getCurrent(), staffPage.getSize(), userVOList));
|
||||
}
|
||||
@@ -204,6 +205,62 @@ public class SpdmUserController {
|
||||
return ResponseR.ok(jsonObject);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取部门树")
|
||||
@PostMapping(value = "/getDeptTree")
|
||||
public ResponseR getDeptTree(@RequestBody GroupQueryDto groupQueryDto) {
|
||||
SysDeptTreeAndListRequestDTO req = new SysDeptTreeAndListRequestDTO();
|
||||
req.setDeptName(groupQueryDto.getGroupName());
|
||||
req.setDeptCode(groupQueryDto.getGroupCode());
|
||||
R result = remoteTenantServiceFeign.getDeptTree(req, groupQueryDto.getTenantId());
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
// Feign 反序列化后实际是 LinkedHashMap,需要手动转换
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> deptList = (List<Map<String, Object>>) result.getData();
|
||||
List<GroupResultDto> groupResultDtoList = new ArrayList<>(deptList.size());
|
||||
for (Map<String, Object> deptMap : deptList) {
|
||||
groupResultDtoList.add(convertMapToGroupResultDto(deptMap));
|
||||
}
|
||||
return ResponseR.ok(groupResultDtoList);
|
||||
}
|
||||
return ResponseR.ok();
|
||||
}
|
||||
|
||||
private static final java.time.ZoneId SYSTEM_ZONE_ID = java.time.ZoneId.systemDefault();
|
||||
|
||||
/**
|
||||
* 递归将 Map 转换为 GroupResultDto
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private GroupResultDto convertMapToGroupResultDto(Map<String, Object> map) {
|
||||
Long id = map.get("deptId") != null ? Long.valueOf(map.get("deptId").toString()) : null;
|
||||
String groupCode = (String) map.get("deptCode");
|
||||
String groupName = (String) map.get("deptName");
|
||||
// LocalDateTime createTime = toLocalDateTime(map.get("createTime"));
|
||||
// LocalDateTime updateTime = toLocalDateTime(map.get("updateTime"));
|
||||
|
||||
List<Map<String, Object>> childList = (List<Map<String, Object>>) map.get("children");
|
||||
List<GroupResultDto> children = null;
|
||||
if (CollectionUtils.isNotEmpty(childList)) {
|
||||
children = new ArrayList<>(childList.size());
|
||||
for (Map<String, Object> child : childList) {
|
||||
children.add(convertMapToGroupResultDto(child));
|
||||
}
|
||||
}
|
||||
|
||||
return new GroupResultDto(id, groupCode, groupName, children);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳转换为 LocalDateTime
|
||||
*/
|
||||
private LocalDateTime toLocalDateTime(Object timestamp) {
|
||||
if (timestamp instanceof Number num) {
|
||||
return java.time.Instant.ofEpochMilli(num.longValue()).atZone(SYSTEM_ZONE_ID).toLocalDateTime();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Operation(summary = "根据用户ids返回用户列表")
|
||||
@PostMapping(value = "/listUserByIds")
|
||||
public ResponseR listUserByIds(@RequestBody UserParamDto paramDto) {
|
||||
|
||||
@@ -7,11 +7,10 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "用户组返回参数实体")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GroupResultDto {
|
||||
@Schema(description = "用户组ID")
|
||||
private Long id;
|
||||
@@ -30,4 +29,33 @@ public class GroupResultDto {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "子部门列表")
|
||||
private List<GroupResultDto> children;
|
||||
|
||||
public GroupResultDto() {
|
||||
}
|
||||
|
||||
public GroupResultDto(Long id, String groupCode, String groupName, LocalDateTime createTime, LocalDateTime updateTime) {
|
||||
this.id = id;
|
||||
this.groupCode = groupCode;
|
||||
this.groupName = groupName;
|
||||
this.createTime = createTime;
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public GroupResultDto(Long id, String groupCode, String groupName, LocalDateTime createTime, LocalDateTime updateTime, List<GroupResultDto> children) {
|
||||
this.id = id;
|
||||
this.groupCode = groupCode;
|
||||
this.groupName = groupName;
|
||||
this.createTime = createTime;
|
||||
this.updateTime = updateTime;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public GroupResultDto(Long id, String groupCode, String groupName, List<GroupResultDto> children) {
|
||||
this.id = id;
|
||||
this.groupCode = groupCode;
|
||||
this.groupName = groupName;
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.honeycombis.honeycom.spdm.feign;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.honeycombis.honeycom.common.core.constant.CommonConstants;
|
||||
import com.honeycombis.honeycom.common.core.constant.SecurityConstants;
|
||||
@@ -7,6 +8,7 @@ import com.honeycombis.honeycom.common.core.constant.ServiceNameConstants;
|
||||
import com.honeycombis.honeycom.common.core.util.R;
|
||||
import com.honeycombis.honeycom.common.feign.config.FeignConfig;
|
||||
import com.honeycombis.honeycom.spdm.dto.*;
|
||||
import com.honeycombis.honeycom.tenant.dto.SysDeptTreeAndListRequestDTO;
|
||||
import com.honeycombis.honeycom.tenant.entity.SysDeptEntity;
|
||||
import com.honeycombis.honeycom.tenant.entity.SysPostEntity;
|
||||
import com.honeycombis.honeycom.tenant.entity.SysStaffEntity;
|
||||
@@ -41,6 +43,8 @@ public interface RemoteTenantServiceFeign {
|
||||
R<Page<SysDeptEntity>> listDeptForPage(@SpringQueryMap GroupQueryDto pageQueryDto, @RequestHeader(CommonConstants.TENANT_ID) String tenantIdHeader);
|
||||
@GetMapping("/sysDept/{deptId}")
|
||||
R<SysDeptEntity> queryDeptById(@PathVariable("deptId" ) Long deptId, @RequestHeader(CommonConstants.TENANT_ID) String tenantIdHeader);
|
||||
@PostMapping("/sysDept/tree")
|
||||
R<List<Tree<Long>>> getDeptTree(@RequestBody SysDeptTreeAndListRequestDTO req, @RequestHeader(CommonConstants.TENANT_ID) String tenantIdHeader);
|
||||
|
||||
@GetMapping("/sysStaff/findByDeptIds")
|
||||
R<Map<Long, List<SysStaffVO>>> findByDeptIds(@RequestParam("deptIds") List<Long> deptIds, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
|
||||
Reference in New Issue
Block a user