用户导入去掉角色名称
parent
e771eb66f4
commit
8352f58b44
|
|
@ -20,7 +20,7 @@ spring:
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- config-common.yml
|
- config-common.yml
|
||||||
- config-port.yml
|
# - config-port.yml
|
||||||
- config-mq.yml
|
- config-mq.yml
|
||||||
- config-log.yml
|
- config-log.yml
|
||||||
- config-sdk-server.yml
|
- config-sdk-server.yml
|
||||||
|
|
@ -38,3 +38,5 @@ spring:
|
||||||
namespace: ${spring.cloud.nacos.config.namespace}
|
namespace: ${spring.cloud.nacos.config.namespace}
|
||||||
inetutils:
|
inetutils:
|
||||||
preferred-networks: 192.168.10.28
|
preferred-networks: 192.168.10.28
|
||||||
|
server:
|
||||||
|
port: 8081
|
||||||
|
|
@ -117,7 +117,7 @@ public class AppUserController {
|
||||||
}
|
}
|
||||||
@ApiOperation("app获取用户在职企业-轮询")
|
@ApiOperation("app获取用户在职企业-轮询")
|
||||||
@PostMapping("/getUserCorpByPhone")
|
@PostMapping("/getUserCorpByPhone")
|
||||||
public SingleResponse<UserLoginCO> getUserCorpByPhone(@Validated @RequestBody UserAppLoginCmd cmd) {
|
public SingleResponse<UserLoginCO> getUserCorpByPhone(@Validated @RequestBody UserAppPhoneCmd cmd) {
|
||||||
return SingleResponse.of(userService.getUserCorpByPhone(cmd));
|
return SingleResponse.of(userService.getUserCorpByPhone(cmd));
|
||||||
}
|
}
|
||||||
@ApiOperation("app获取用户在职企业")
|
@ApiOperation("app获取用户在职企业")
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,6 +77,32 @@ public class UserImportExe {
|
||||||
if (roleCOMultiResponse == null || CollUtil.isEmpty(roleCOMultiResponse.getData())) {
|
if (roleCOMultiResponse == null || CollUtil.isEmpty(roleCOMultiResponse.getData())) {
|
||||||
throw new BizException("未创建角色,请联系管理员");
|
throw new BizException("未创建角色,请联系管理员");
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
Boolean b = corpInfoRepository.isSupper();
|
||||||
|
Long roleId = null;
|
||||||
|
List<RoleCO> roleCOList = roleCOMultiResponse.getData();
|
||||||
|
if(b){
|
||||||
|
//是
|
||||||
|
Optional<RoleCO> superCorpRoleOpt = roleCOList.stream()
|
||||||
|
.filter(roleCO -> roleCO.getRoleName().contains("股份端普通用户"))
|
||||||
|
.findFirst();
|
||||||
|
if (superCorpRoleOpt.isPresent()) {
|
||||||
|
roleId = superCorpRoleOpt.get().getId();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 普通租户查找普通用户或个人账号
|
||||||
|
Optional<RoleCO> normalRoleOpt = roleCOList.stream()
|
||||||
|
.filter(roleCO -> roleCO.getRoleName().contains("普通用户") ||
|
||||||
|
roleCO.getRoleName().contains("个人账户"))
|
||||||
|
.findFirst();
|
||||||
|
if (normalRoleOpt.isPresent()) {
|
||||||
|
roleId = normalRoleOpt.get().getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(roleId == null){
|
||||||
|
throw new BizException("未创建角色,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
// 部门数据
|
// 部门数据
|
||||||
List<DepartmentDO> departmentDOList = departmentRepository.listByCorpInfoId(corpinfoId);
|
List<DepartmentDO> departmentDOList = departmentRepository.listByCorpInfoId(corpinfoId);
|
||||||
List<DepartmentDO> departmentDOTempList = new ArrayList<>();
|
List<DepartmentDO> departmentDOTempList = new ArrayList<>();
|
||||||
|
|
@ -102,7 +125,7 @@ public class UserImportExe {
|
||||||
// 开始处理导入逻辑
|
// 开始处理导入逻辑
|
||||||
for (UserExcelImportEntity importEntity : list) {
|
for (UserExcelImportEntity importEntity : list) {
|
||||||
try {
|
try {
|
||||||
processSingleUser(importEntity, corpFlag, corpinfoId, corpInfoDO, departmentDOList, departmentDOTempList, postDOList, userDOList, userDOTempList, roleCOMultiResponse.getData());
|
processSingleUser(importEntity, corpFlag, corpinfoId, corpInfoDO, departmentDOList, departmentDOTempList, postDOList, userDOList, userDOTempList, roleId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if(CollUtil.isNotEmpty(departmentDOTempList)){
|
if(CollUtil.isNotEmpty(departmentDOTempList)){
|
||||||
// 删除底座创建的部门
|
// 删除底座创建的部门
|
||||||
|
|
@ -131,7 +154,7 @@ public class UserImportExe {
|
||||||
List<PostDO> postDOList,
|
List<PostDO> postDOList,
|
||||||
List<UserDO> userDOList,
|
List<UserDO> userDOList,
|
||||||
List<UserDO> userDOTempList,
|
List<UserDO> userDOTempList,
|
||||||
List<RoleCO> roleList) {
|
Long roleId) {
|
||||||
|
|
||||||
// 1. 处理部门层级,获取最终部门ID
|
// 1. 处理部门层级,获取最终部门ID
|
||||||
Long departmentId = processDepartmentHierarchy(importEntity, corpinfoId, departmentDOList, departmentDOTempList);
|
Long departmentId = processDepartmentHierarchy(importEntity, corpinfoId, departmentDOList, departmentDOTempList);
|
||||||
|
|
@ -140,7 +163,7 @@ public class UserImportExe {
|
||||||
Long postId = processPost(importEntity, corpinfoId, corpInfoDO, departmentId, postDOList);
|
Long postId = processPost(importEntity, corpinfoId, corpInfoDO, departmentId, postDOList);
|
||||||
|
|
||||||
// 3. 处理角色信息
|
// 3. 处理角色信息
|
||||||
Long roleId = processRoleInfo(importEntity, roleList);
|
// Long roleId = processRoleInfo(importEntity, roleList);
|
||||||
|
|
||||||
// 4. 处理用户信息
|
// 4. 处理用户信息
|
||||||
processUserInfo(importEntity, corpFlag, corpinfoId, corpInfoDO, departmentId, postId, userDOList, userDOTempList, roleId);
|
processUserInfo(importEntity, corpFlag, corpinfoId, corpInfoDO, departmentId, postId, userDOList, userDOTempList, roleId);
|
||||||
|
|
@ -346,20 +369,20 @@ public class UserImportExe {
|
||||||
* 处理角色信息
|
* 处理角色信息
|
||||||
*/
|
*/
|
||||||
private Long processRoleInfo(UserExcelImportEntity importEntity, List<RoleCO> roleList) {
|
private Long processRoleInfo(UserExcelImportEntity importEntity, List<RoleCO> roleList) {
|
||||||
if(StringUtils.isBlank(importEntity.getRoleName())){
|
// if(StringUtils.isBlank(importEntity.getRoleName())){
|
||||||
throw new BizException("角色名称不能为空");
|
// throw new BizException("角色名称不能为空");
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
Map<String, RoleCO> roleCOMap = roleList.stream().collect(Collectors.toMap(RoleCO::getRoleName, role -> role));
|
// Map<String, RoleCO> roleCOMap = roleList.stream().collect(Collectors.toMap(RoleCO::getRoleName, role -> role));
|
||||||
String roleName = importEntity.getRoleName();
|
// String roleName = importEntity.getRoleName();
|
||||||
if(roleCOMap.get(roleName) == null){
|
// if(roleCOMap.get(roleName) == null){
|
||||||
throw new BizException("角色不存在: " + roleName);
|
// throw new BizException("角色不存在: " + roleName);
|
||||||
}
|
// }
|
||||||
return roleCOMap.get(roleName).getId();
|
// return roleCOMap.get(roleName).getId();
|
||||||
}catch (IllegalStateException e){
|
// }catch (IllegalStateException e){
|
||||||
throw new BizException("系统角色名称重复,请联系管理员");
|
// throw new BizException("系统角色名称重复,请联系管理员");
|
||||||
}
|
// }
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ public class UserQueryExe {
|
||||||
userLoginCO.setUserCO(userCoConvertor.converDOToCO(userDO));
|
userLoginCO.setUserCO(userCoConvertor.converDOToCO(userDO));
|
||||||
return userLoginCO;
|
return userLoginCO;
|
||||||
}
|
}
|
||||||
public UserLoginCO getUserCorpByPhone(UserAppLoginCmd cmd) {
|
public UserLoginCO getUserCorpByPhone(UserAppPhoneCmd cmd) {
|
||||||
UserLoginCO userLoginCO = new UserLoginCO();
|
UserLoginCO userLoginCO = new UserLoginCO();
|
||||||
//返回企业列表
|
//返回企业列表
|
||||||
//根据手机号获取用户列表
|
//根据手机号获取用户列表
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ public class UserServiceImpl implements UserServiceI {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserLoginCO getUserCorpByPhone(UserAppLoginCmd cmd) {
|
public UserLoginCO getUserCorpByPhone(UserAppPhoneCmd cmd) {
|
||||||
return userQueryExe.getUserCorpByPhone(cmd);
|
return userQueryExe.getUserCorpByPhone(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,6 @@ public interface UserServiceI {
|
||||||
|
|
||||||
List<UserCO> getUserList();
|
List<UserCO> getUserList();
|
||||||
|
|
||||||
UserLoginCO getUserCorpByPhone(UserAppLoginCmd cmd);
|
UserLoginCO getUserCorpByPhone(UserAppPhoneCmd cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.zcloud.basic.info.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* web-client
|
||||||
|
*
|
||||||
|
* @Author zhangyue
|
||||||
|
* @Date 2025-11-04 14:07:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserAppPhoneCmd {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "手机号", name = "phone", required = true)
|
||||||
|
@NotEmpty(message = "手机号不能为空")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -41,5 +41,6 @@ public interface CorpInfoRepository extends BaseRepository<CorpInfoDO> {
|
||||||
|
|
||||||
List<CorpInfoDO> getByIdList(List<Long> corpinfoIds);
|
List<CorpInfoDO> getByIdList(List<Long> corpinfoIds);
|
||||||
|
|
||||||
|
Boolean isSupper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,5 +268,16 @@ public class CorpInfoRepositoryImpl extends BaseRepositoryImpl<CorpInfoMapper, C
|
||||||
return update(updateWrapper);
|
return update(updateWrapper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isSupper() {
|
||||||
|
//判断当前企业是否是监管端
|
||||||
|
CorpInfoDO corpInfoDO = corpInfoMapper.selectById(AuthContext.getTenantId());
|
||||||
|
if(corpInfoDO == null)
|
||||||
|
throw new BizException("当前企业不存在");
|
||||||
|
if(CorpTypeEnum.share.getCode().equals(corpInfoDO.getType()))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue