用户批量导入
parent
f27fb33063
commit
9c84548f12
|
|
@ -60,7 +60,6 @@ public class UserController {
|
|||
@ApiOperation("新增用户")
|
||||
@PostMapping("/save")
|
||||
public SingleResponse<UserCO> add(@Validated @RequestBody UserAddCmd cmd) {
|
||||
SSOUser ssoUser = AuthContext.getCurrentUser();
|
||||
return userService.add(cmd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.jjb.saas.config.client.dicttree.facade.ConfDictTreeFacade;
|
|||
import com.jjb.saas.config.client.dicttree.response.ConfDictTreeCO;
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||
import com.zcloud.basic.info.domain.gateway.CorpInfoGateway;
|
||||
import com.zcloud.basic.info.domain.gateway.UserEmploymentLogGateway;
|
||||
|
|
@ -129,6 +130,9 @@ public class UserAddExe {
|
|||
UserE userE = new UserE();
|
||||
Long corpinfoId = AuthContext.getTenantId();
|
||||
|
||||
Map<String, Long> roleMap = userRepository.getRoleMap();
|
||||
|
||||
|
||||
CorpInfoDO corpInfoDO = corpInfoRepository.getById(corpinfoId);
|
||||
// 部门数据
|
||||
List<DepartmentDO> departmentDOList = departmentRepository.listByCorpInfoId(corpinfoId);
|
||||
|
|
@ -142,11 +146,11 @@ public class UserAddExe {
|
|||
if(CollectionUtil.isNotEmpty(confDictCOList)){
|
||||
dictMap = confDictCOList.stream().collect(Collectors.toMap(ConfDictTreeCO::getDictLabel, ConfDictTreeCO::getDictValue));
|
||||
}
|
||||
|
||||
List<UserE> userEList = userE.parseImportTemplateData(file,
|
||||
BeanUtil.copyToList(departmentDOList, DepartmentE.class),
|
||||
BeanUtil.copyToList(postDOList, PostE.class),
|
||||
BeanUtil.copyToList(userDOList, UserE.class),
|
||||
roleMap,
|
||||
dictMap);
|
||||
|
||||
// 批量插入用户
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import javax.validation.constraints.NotNull;
|
|||
public class UserVerifyQryCmd {
|
||||
|
||||
@ApiModelProperty(value = "用户id", name = "id", required = true)
|
||||
@NotNull(message = "用户id不能为空")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "登录账号", name = "username")
|
||||
private String username;
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ public class UserE extends BaseE {
|
|||
|
||||
/**
|
||||
* 人员修改过程中,是否存在转岗、入职离职
|
||||
*
|
||||
* @param oldUserE
|
||||
* @param newUserE
|
||||
* @return
|
||||
|
|
@ -198,6 +199,7 @@ public class UserE extends BaseE {
|
|||
List<DepartmentE> departmentList,
|
||||
List<PostE> postList,
|
||||
List<UserE> userList,
|
||||
Map<String, Long> roleMap,
|
||||
Map<String, String> dictMap) {
|
||||
List<UserExcelImportEntity> list = new ArrayList<>();
|
||||
try {
|
||||
|
|
@ -238,6 +240,9 @@ public class UserE extends BaseE {
|
|||
if (StringUtils.isEmpty(entity.getRoleName())) {
|
||||
errList.add("第" + (i + 2) + "行用户角色不能为空。");
|
||||
}
|
||||
if(!roleMap.containsKey(entity.getRoleName())){
|
||||
errList.add("第" + (i + 2) + "行用户角色不存在。");
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getDepartmentName())) {
|
||||
errList.add("第" + (i + 2) + "行所属部门不能为空。");
|
||||
} else {
|
||||
|
|
@ -318,7 +323,7 @@ public class UserE extends BaseE {
|
|||
userE.setPostId(postEMap.get(entity.getPostName()).getId());
|
||||
userE.setPostName(entity.getPostName());
|
||||
}
|
||||
|
||||
userE.setRoleId(roleMap.get(entity.getRoleName()));
|
||||
// 用户名
|
||||
userE.setUsername(entity.getUsername());
|
||||
// 姓名
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.alibaba.cola.dto.PageResponse;
|
|||
import com.alibaba.cola.dto.Response;
|
||||
import com.baomidou.mybatisplus.core.injector.methods.UpdateById;
|
||||
import com.jjb.saas.framework.repository.repo.BaseRepository;
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import com.zcloud.basic.info.domain.model.CorpInfoE;
|
||||
import com.zcloud.basic.info.domain.model.UserE;
|
||||
import com.zcloud.basic.info.persistence.dataobject.UserDO;
|
||||
|
|
@ -52,5 +53,8 @@ public interface UserRepository extends BaseRepository<UserDO> {
|
|||
Map<Long, String> getDepartmentLeaderByDepartmentId(List<Long> departmentIds);
|
||||
|
||||
Long getDefaultRoleId();
|
||||
|
||||
Map<String, Long> getRoleMap();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -255,5 +255,16 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> getRoleMap() {
|
||||
MultiResponse<RoleCO> multiResponse = roleFacade.listRoles();
|
||||
if (multiResponse.isSuccess()){
|
||||
|
||||
return multiResponse.getData().stream()
|
||||
.collect(Collectors.toMap(RoleCO::getRoleName, RoleCO::getId));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue