| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public ResultBody doctorUserReg(UserRegVo userRegVo, SysUser sysUserd) { |
| | | if(sysUserd.getId()==null){ |
| | | sysUserd = this.baseMapper.selectById(userRegVo.getUserId()); |
| | | } |
| | | //检查手机号是否已经注册 H端登录名和手机号存一样的值 |
| | | if (phoneIsUsed(userRegVo.getMobile())) { |
| | | return ResultBody.failed("该手机号已经注册"); |
| | | } |
| | | //创建人id |
| | | Long createUserId = 0L; |
| | | Long createUserId = CommonConstant.CREATE_USER_ID; |
| | | //创建人id |
| | | String createUserName = "自动创建"; |
| | | String createUserName = CommonConstant.CREATE_USER_NAME; |
| | | //是否注册用户 |
| | | Boolean isReg = false; |
| | | //业务成功 |
| | |
| | | if (StringUtils.isBlank(userRegVo.getPassword())) { |
| | | defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | sysUser.setPassword(passwordEncoder.encode(defaultPassWord)); |
| | | sysUser.setDefaultAuth(false); |
| | | userRegVo.setPassword(defaultPassWord); |
| | | } else { |
| | | sysUser.setPassword(passwordEncoder.encode(userRegVo.getPassword())); |
| | | sysUser.setDefaultAuth(false); |
| | | } |
| | | sysUser.setNickname(userRegVo.getNickname()); |
| | | sysUser.setSex(userRegVo.getSex()); |
| | |
| | | sysUser.setType(UserType.DOCTOR.name()); |
| | | } |
| | | sysUser.setHAdminUser(false); |
| | | sysUser.setDefaultAuth(false); |
| | | sysUser.setOpenId(userRegVo.getOpenId()); |
| | | sysUser.setDel(false); |
| | | sysUser.setTenantId("hospital"); |
| | |
| | | sysDoctor.setDoctorRankId(userRegVo.getDoctorRankId()); |
| | | sysDoctor.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysDoctor.setDoctorState(userRegVo.getDoctorState()); |
| | | if (isReg) { |
| | | sysDoctor.setDoctorState(false); |
| | | } |
| | | else |
| | | { |
| | | sysDoctor.setDoctorState(true); |
| | | } |
| | | sysDoctor.setDoctorTel(userRegVo.getMobile()); |
| | | sysDoctor.setDoctorName(userRegVo.getNickname()); |
| | | sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId()); |
| | |
| | | return 0; |
| | | } else { |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("departmentId", depatmentId); |
| | | selectMap.put("department_id", depatmentId); |
| | | selectMap.put("enabled", 1); |
| | | List<SysDoctor> sysDoctorList = sysDoctorMapper.selectByMap(selectMap); |
| | | if (sysDoctorList == null) { |
| | | if (sysDoctorList != null) { |
| | | int doctorCount = sysDoctorList.size(); |
| | | int accountCount = sysDepartment.getAccountsCount(); |
| | | return (accountCount - doctorCount); |
| | |
| | | } |
| | | return new com.kidgrow.usercenter.model.SysDoctor(); |
| | | } |
| | | |
| | | /** |
| | | * 检查手机号是注册用户还是正式用户 |
| | | * @param userTel |
| | | * @return |
| | | */ |
| | | public ResultBody isRegUser(String userTel) |
| | | { |
| | | if (StringUtils.isNotBlank(userTel)) { |
| | | List<SysUser> users = baseMapper.selectList( |
| | | new QueryWrapper<SysUser>().eq("username", userTel) |
| | | ); |
| | | if (users != null&&users.size()==1) { |
| | | SysUser sysUser=users.get(0); |
| | | if (sysUser.getCreateUserId()==CommonConstant.CREATE_USER_ID&&sysUser.getCreateUserName().equals(CommonConstant.CREATE_USER_NAME)) { |
| | | return ResultBody.ok().data(true); |
| | | } |
| | | return ResultBody.ok().data(false); |
| | | } |
| | | else |
| | | { |
| | | return ResultBody.failed("用户数据有误!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return ResultBody.failed("必要参数有误!"); |
| | | } |
| | | } |
| | | } |