| | |
| | | @Override |
| | | public boolean checkUserExist(String userName, String oid) throws PLException { |
| | | if(Func.isEmpty(userName) && Func.isEmpty(oid)){ |
| | | throw new PLException("检查用户是否存在时,传递的参数用户名和用户oid都为空!",new String[0]); |
| | | throw new PLException("500", new String[] { "检查用户是否存在时,传递的参数用户名和用户oid都为空!"}); |
| | | } |
| | | UserInfo userInfo = null; |
| | | if(Func.isNotEmpty(userName)) { |
| | |
| | | smUserVO.setUserTypeText(UserTypeEnum.getTextByValue(smUserVO.getUserType())); |
| | | smUserVO.setDescription(userInfo.desc); |
| | | smUserVO.setEmail(userInfo.email); |
| | | smUserVO.setStatus(userInfo.status); |
| | | smUserVO.setPassword(userInfo.pwd); |
| | | //用户所属部门的查询设置 |
| | | List<OrgDepartmentVO> orgDepartmentVOList; |
| | | //查看全局变量中是否存在部门信息,存在的情况最主要是针对多条用户查询的时候避免重复查询的 |
| | |
| | | //分页查询 |
| | | UserInfo[] userInfos = platformClientUtil.getFrameworkService().fetchUserInfoByCondition( |
| | | conditionMap.get("name"), |
| | | conditionMap.get("userName"), |
| | | conditionMap.get("deptId"), |
| | | conditionMap.get("roleId"), |
| | | conditionMap.get("id"), |
| | | conditionMap.get("pkDepartment"), |
| | | conditionMap.get("pkPerson"), |
| | | "developer", //当前登录的用户名 |
| | | pageHelper.getPage(), |
| | | pageHelper.getLimit() |
| | |
| | | dataGrid.setTotal( |
| | | platformClientUtil.getFrameworkService().getUserTotalByCondition( |
| | | conditionMap.get("name"), |
| | | conditionMap.get("userName"), |
| | | conditionMap.get("deptId"), |
| | | conditionMap.get("roleId"), |
| | | conditionMap.get("id"), |
| | | conditionMap.get("pkDepartment"), |
| | | conditionMap.get("pkPerson"), |
| | | "developer" //当前登录的用户名 |
| | | ) |
| | | ); |
| | |
| | | smUserDTO.setCreator("developer"); |
| | | //userObject.setUpdateUser(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserName()); |
| | | smUserDTO.setLastModifier("developer"); |
| | | UserInfo userInfo = changeUserObjectToUserInfo(smUserDTO); |
| | | UserInfo userInfo = changeSmUserDTOToUserInfo(smUserDTO); |
| | | UserEntityInfo userEntityInfo = new UserEntityInfo("developer", ""); |
| | | String oid = platformClientUtil.getFrameworkService().saveUser(userInfo, userEntityInfo); |
| | | if (Func.isEmpty(oid)) { |
| | | return false; |
| | | } |
| | | if(Func.isNotBlank(smUserDTO.getPkDepartment())){ |
| | | platformClientUtil.getFrameworkService().saveUserDept(new String[]{oid}, smUserDTO.getPkDepartment(), userEntityInfo); |
| | | //执行保存用户部门关联关系 |
| | | orgDeptQueryService.saveUsersDept(new String[]{oid},smUserDTO.getPkDepartment()); |
| | | //platformClientUtil.getFrameworkService().saveUserDept(new String[]{oid}, smUserDTO.getPkDepartment(), userEntityInfo); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | //校验 |
| | | check(smUserDTO,false); |
| | | //查询数据库中的 |
| | | SmUserVO dbSmUserVO = getUserByUserId(smUserDTO.getId()); |
| | | //根据用户名查询到了用户,但是oid不是当前修改的用户的oid,说明修改的用户名重复 |
| | | if(Func.isNotEmpty(dbSmUserVO) |
| | | && !dbSmUserVO.getOid().equals(smUserDTO.getOid()) |
| | | ){ |
| | | throw new PLException("用户名已存在,不能将当前用户的用户名修改为" + dbSmUserVO.getId(),new String[0]); |
| | | SmUserVO dbSmUserVO = getUserByUserOid(smUserDTO.getOid()); |
| | | //根据主键没查询到了用户 |
| | | if(Func.isEmpty(dbSmUserVO) || Func.isBlank(dbSmUserVO.getOid())){ |
| | | throw new PLException("500", new String[] { "当前修改的用户不存在"}); |
| | | } |
| | | |
| | | smUserDTO.setLastModifyTime(new Date()); |
| | | //userObject.setUpdateUser(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserName()); |
| | | smUserDTO.setLastModifier("developer"); |
| | | UserInfo userInfo = changeUserObjectToUserInfo(smUserDTO); |
| | | UserInfo userInfo = changeSmUserDTOToUserInfo(smUserDTO); |
| | | boolean updateBoolean = platformClientUtil.getFrameworkService().updateUser(userInfo, new UserEntityInfo("developer", null)); |
| | | //用户关联部门有所更改 |
| | | if(Func.isNotEmpty(smUserDTO.getPkDepartment()) && !smUserDTO.getPkDepartment().equals(dbSmUserVO.getPkDepartment())){ |
| | | //界面传递过来的已关联的部门oid |
| | | List<String> updatePkDept = Func.toStrList(smUserDTO.getPkDepartment(), ","); |
| | | //用户已关联的部门oid |
| | | List<String> associatedPkDept = Func.toStrList(dbSmUserVO.getPkDepartment(), ","); |
| | | //移除 |
| | | updatePkDept.removeAll(associatedPkDept); |
| | | //修改成功,并且用户关联部门有所更改 |
| | | if(updateBoolean && Func.isNotEmpty(smUserDTO.getPkDepartment()) && !smUserDTO.getPkDepartment().equals(dbSmUserVO.getPkDepartment())){ |
| | | //执行保存用户部门关联关系 |
| | | orgDeptQueryService.saveUserDepts(dbSmUserVO.getOid(),updatePkDept); |
| | | orgDeptQueryService.saveUsersDept(new String[]{dbSmUserVO.getOid()},smUserDTO.getPkDepartment()); |
| | | } |
| | | return updateBoolean; |
| | | } |
| | |
| | | if (Func.isNotBlank(smUserDTO.getDescription()) && smUserDTO.getDescription().getBytes().length > 255 ){ |
| | | throw new VciBaseException("描述长度超过上限"); |
| | | } |
| | | if (!smUserDTO.getName().matches("^[A-Za-z0-9_]+$")) { |
| | | if (!smUserDTO.getId().matches("^[A-Za-z0-9_]+$")) { |
| | | throw new VciBaseException("用户名必须是由A-Z a-z 0-9 _组成"); |
| | | } |
| | | if (Func.isNotBlank(smUserDTO.getEmail()) && !smUserDTO.getEmail().matches("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$")){ |
| | | throw new VciBaseException("电子邮箱格式错误"); |
| | | } |
| | | //是新增才做用户名查重处理 |
| | | //是新增才做用户名查重处理,因为用户名一经创建,不允许修改 |
| | | if(isAdd){ |
| | | //根据用户名(账号)查重 |
| | | SmUserVO dbSmUserVO = getUserByUserId(smUserDTO.getId()); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /*** |
| | | * 用户从DTO对象到corba对象 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | public UserInfo changeUserObjectToUserInfo(SmUserDTO user) { |
| | | public UserInfo changeSmUserDTOToUserInfo(SmUserDTO user) { |
| | | UserInfo userInfo = new UserInfo(); |
| | | userInfo.id = user.getOid() == null ? "" : user.getOid(); |
| | | userInfo.userName = user.getId() == null ? "" : user.getId(); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteUser(String[] ids) throws PLException { |
| | | VciBaseUtil.alertNotNull(ids,"待删除的用户id列表不能为空!"); |
| | | if(Func.isEmpty(ids)){ |
| | | throw new VciBaseException("待删除的用户id列表不能为空!"); |
| | | } |
| | | //调用platformClientUtil的删除用户的方法,会一起删除掉具备关联关系的一些信息,如部门 |
| | | return platformClientUtil.getFrameworkService().deleteUser(ids, null); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean disableOrEnableUsers(String[] ids, boolean flag) throws PLException { |
| | | public boolean stopUsers(String[] ids, boolean flag) throws PLException { |
| | | VciBaseUtil.alertNotNull(ids,"停用/启用的用户id列表"); |
| | | return platformClientUtil.getFrameworkService().stopUsers(ids, flag,null); |
| | | } |
| | | |
| | | @Override |
| | | public void downloadImportTemplate() { |
| | | |
| | | } |
| | | |
| | | } |