| | |
| | | * 清空旧的登录信息,保证同时只有一个用户再登录,后登录用户会挤掉前一个用户 |
| | | * @param username |
| | | */ |
| | | public void cacheUserToken(String username,Integer identity,String newToken){ |
| | | String userKey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + username+"_"+identity); |
| | | String oldToken = (String) redisUtils.get(userKey); |
| | | if (StringUtils.isNotBlank(oldToken)) { |
| | | String oldTokenkey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + JwtTokenUtil.md5Encode(oldToken)); |
| | | redisUtils.del(oldTokenkey); |
| | | redisUtils.del(userKey); |
| | | } |
| | | redisUtils.set(userKey, newToken,(JwtTokenUtil.EXPIRATION*2/1000)+2); |
| | | // public void cacheUserToken(String username,Integer identity,String newToken){ |
| | | // String userKey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + username+"_"+identity); |
| | | // String oldToken = (String) redisUtils.get(userKey); |
| | | // if (StringUtils.isNotBlank(oldToken)) { |
| | | // String oldTokenkey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + JwtTokenUtil.md5Encode(oldToken)); |
| | | // redisUtils.del(oldTokenkey); |
| | | // redisUtils.del(userKey); |
| | | // } |
| | | // redisUtils.set(userKey, newToken,(JwtTokenUtil.EXPIRATION*2/1000)+2); |
| | | // |
| | | // |
| | | // String tokenKey= redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN+":"+JwtTokenUtil.md5Encode(newToken)); |
| | | // // 设置超时时间 |
| | | // redisUtils.set(tokenKey,newToken); |
| | | // redisUtils.expire(tokenKey,JwtTokenUtil.EXPIRATION*2/1000); |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 清空旧的登录信息,保证同时只有一个用户再登录,后登录用户会挤掉前一个用户 |
| | | * @param username |
| | | */ |
| | | public void cacheUserToken(String username,Integer identity,String newToken){ |
| | | // String userKey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + username+"_"+identity); |
| | | // String oldToken = (String) redisUtils.get(userKey); |
| | | // if (StringUtils.isNotBlank(oldToken)) { |
| | | // String oldTokenkey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + JwtTokenUtil.md5Encode(oldToken)); |
| | | // redisUtils.del(oldTokenkey); |
| | | // redisUtils.del(userKey); |
| | | // } |
| | | // redisUtils.set(userKey, newToken,(JwtTokenUtil.EXPIRATION*2/1000)+2); |
| | | |
| | | String tokenKey= redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN+":"+JwtTokenUtil.md5Encode(newToken)); |
| | | // 设置超时时间 |
| | | redisUtils.set(tokenKey,newToken); |
| | | redisUtils.expire(tokenKey,JwtTokenUtil.EXPIRATION*2/1000); |
| | | redisUtils.set(tokenKey,newToken,JwtTokenUtil.EXPIRATION*2/1000); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验验证码 |
| | |
| | | if(StringUtils.isNotBlank(jwtToken)){ |
| | | String username=JwtTokenUtil.getUsername(jwtToken); |
| | | Integer identity=JwtTokenUtil.getIdentity(jwtToken); |
| | | String userKey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + username+"_"+identity); |
| | | // String userKey = redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN + ":" + username+"_"+identity); |
| | | String tokenKey= redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN+":"+JwtTokenUtil.md5Encode(jwtToken)); |
| | | //删除redis缓存 |
| | | redisUtils.del(tokenKey); |
| | | redisUtils.del(userKey); |
| | | // redisUtils.del(userKey); |
| | | } |
| | | } |
| | | |
| | |
| | | if(!checkPhoneUnique(new SysUser().setUsername(user.getPhone()).setIdentity(UserIdentityEnum.EXPERT.getCode()))){ |
| | | throw new ApiException("手机号已存在"); |
| | | } |
| | | List<SysAttach> socialAttach=user.getSocialAttach(); |
| | | List<SysAttach> medicalAttach=user.getMedicalAttach(); |
| | | List<SysAttach> salaryAttach=user.getSalaryAttach(); |
| | | //疆外企业必须上传社保、医保、薪资 |
| | | SysAgency agency=agencyService.getAgencyById(user.getAgencyId()); |
| | | if(agency.getAttribute()==0){ |
| | | if(ObjectUtil.isEmpty(socialAttach)||ObjectUtil.isEmpty(medicalAttach)||ObjectUtil.isEmpty(salaryAttach)){ |
| | | throw new ApiException("疆内企业必须上传社保、医保、工资照片"); |
| | | } |
| | | } |
| | | |
| | | String major=user.getMajor(); |
| | | List<Integer> majors=new ArrayList<>(); |
| | | JSONObject jsonObject=JSONObject.parseObject(major); |
| | |
| | | if(!b){ |
| | | throw new ApiException("创建专家信息失败"); |
| | | } |
| | | List<SysAttach> socialAttach=user.getSocialAttach(); |
| | | List<SysAttach> medicalAttach=user.getMedicalAttach(); |
| | | List<SysAttach> salaryAttach=user.getSalaryAttach(); |
| | | |
| | | List<SysAttach> attaches=new ArrayList<>(); |
| | | for(SysAttach attach:socialAttach){ |
| | | attach.setType(AttachTypeEnum.SOCIAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | if(socialAttach!=null&& !socialAttach.isEmpty()) { |
| | | for (SysAttach attach : socialAttach) { |
| | | attach.setType(AttachTypeEnum.SOCIAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | } |
| | | for(SysAttach attach:medicalAttach){ |
| | | attach.setType(AttachTypeEnum.MEDICAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | if(medicalAttach!=null&& !medicalAttach.isEmpty()) { |
| | | for (SysAttach attach : medicalAttach) { |
| | | attach.setType(AttachTypeEnum.MEDICAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | } |
| | | for(SysAttach attach:salaryAttach){ |
| | | attach.setType(AttachTypeEnum.SALARY.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | if(salaryAttach!=null&& !salaryAttach.isEmpty()) { |
| | | for (SysAttach attach : salaryAttach) { |
| | | attach.setType(AttachTypeEnum.SALARY.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | } |
| | | attachService.saveBatch(attaches); |
| | | if(!attaches.isEmpty()) { |
| | | attachService.saveBatch(attaches); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | delCacheByUsername(user.getUsername(),user.getIdentity()); |
| | | delCacheByUsername(user.getPhone(),user.getIdentity()); |
| | | user=new SysUser().setId(userId); |
| | | user.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | user.setDelFlag(DeleteFlagEnum.DELETED.getCode()); |
| | |
| | | throw new ApiException("手机号已存在"); |
| | | } |
| | | delCacheByUsername(user.getUsername(),UserIdentityEnum.MONITOR.getCode()); |
| | | delCacheByUsername(user.getPhone(),UserIdentityEnum.MONITOR.getCode()); |
| | | user.setPassword(null); |
| | | user.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | boolean b=updateById(user); |
| | |
| | | if(!agencyService.checkAgencyNameUnique(agency)){ |
| | | throw new ApiException("机构名称已存在"); |
| | | } |
| | | SysUser currentUser=ShiroUtils.getSysUser(); |
| | | if(!currentUser.getIdentity().equals(UserIdentityEnum.MONITOR.getCode())){ |
| | | if(!user.getId().equals(currentUser.getId())){ |
| | | throw new ApiException("只能修改自身数据"); |
| | | } |
| | | } |
| | | |
| | | delCacheByUsername(user.getUsername(),UserIdentityEnum.AGENCY.getCode()); |
| | | agency.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | delCacheByUsername(user.getPhone(),UserIdentityEnum.AGENCY.getCode()); |
| | | agency.setUpdateBy(currentUser.getUsername()); |
| | | agencyService.updateById(agency); |
| | | user.setPassword(null); |
| | | user.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | user.setUpdateBy(currentUser.getUsername()); |
| | | boolean b=updateById(user); |
| | | if(!b){ |
| | | throw new ApiException("更新用户失败"); |
| | |
| | | if(!checkPhoneUnique(user.setIdentity(UserIdentityEnum.EXPERT.getCode()))){ |
| | | throw new ApiException("手机号已存在"); |
| | | } |
| | | List<SysAttach> socialAttach=user.getSocialAttach(); |
| | | List<SysAttach> medicalAttach=user.getMedicalAttach(); |
| | | List<SysAttach> salaryAttach=user.getSalaryAttach(); |
| | | //疆外企业必须上传社保、医保、薪资 |
| | | SysAgency agency=agencyService.getAgencyById(user.getAgencyId()); |
| | | if(agency.getAttribute()==0){ |
| | | if(ObjectUtil.isEmpty(socialAttach)||ObjectUtil.isEmpty(medicalAttach)||ObjectUtil.isEmpty(salaryAttach)){ |
| | | throw new ApiException("疆内企业必须上传社保、医保、工资照片"); |
| | | } |
| | | } |
| | | |
| | | String major=user.getMajor(); |
| | | if(StringUtils.isNotBlank(major)){ |
| | | List<Integer> majors=new ArrayList<>(); |
| | |
| | | // 刪除旧数据 |
| | | // attachService.deleteAttachsByUserId(user.getId(),null); |
| | | |
| | | List<SysAttach> socialAttach=user.getSocialAttach(); |
| | | List<SysAttach> medicalAttach=user.getMedicalAttach(); |
| | | List<SysAttach> salaryAttach=user.getSalaryAttach(); |
| | | List<SysAttach> attaches=new ArrayList<>(); |
| | | for(SysAttach attach:socialAttach){ |
| | | attach.setType(AttachTypeEnum.SOCIAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | if(socialAttach!=null&& !socialAttach.isEmpty()) { |
| | | for (SysAttach attach : socialAttach) { |
| | | attach.setType(AttachTypeEnum.SOCIAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | } |
| | | for(SysAttach attach:medicalAttach){ |
| | | attach.setType(AttachTypeEnum.MEDICAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | if(medicalAttach!=null&& !medicalAttach.isEmpty()) { |
| | | for (SysAttach attach : medicalAttach) { |
| | | attach.setType(AttachTypeEnum.MEDICAL.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | } |
| | | for(SysAttach attach:salaryAttach){ |
| | | attach.setType(AttachTypeEnum.SALARY.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | if(salaryAttach!=null&& !salaryAttach.isEmpty()) { |
| | | for (SysAttach attach : salaryAttach) { |
| | | attach.setType(AttachTypeEnum.SALARY.getCode()); |
| | | attach.setUserId(user.getId()); |
| | | attaches.add(attach); |
| | | } |
| | | } |
| | | attachService.saveOrUpdateBatch(attaches); |
| | | if(!attaches.isEmpty()) { |
| | | attachService.saveOrUpdateBatch(attaches); |
| | | } |
| | | |
| | | List<Long> newIds=attaches.stream().map(SysAttach::getId).collect(Collectors.toList()); |
| | | List<Long> delIds=new ArrayList<>(); |
| | | for(SysAttach attach:existAttaches){ |
| | | if(!newIds.contains(attach.getId())){ |
| | | List<Long> newIds = attaches.stream().map(SysAttach::getId).collect(Collectors.toList()); |
| | | List<Long> delIds = new ArrayList<>(); |
| | | for (SysAttach attach : existAttaches) { |
| | | if (!newIds.contains(attach.getId())) { |
| | | delIds.add(attach.getId()); |
| | | } |
| | | } |
| | | if(!delIds.isEmpty()){ |
| | | if (!delIds.isEmpty()) { |
| | | attachService.deleteAttachsByIds(delIds); |
| | | } |
| | | |
| | | delCacheByUsername(user.getUsername(),UserIdentityEnum.EXPERT.getCode()); |
| | | delCacheByUsername(user.getPhone(),UserIdentityEnum.EXPERT.getCode()); |
| | | return row; |
| | | } |
| | | |
| | |
| | | SysUser newUser=new SysUser().setId(user.getId()).setPassword(JwtTokenUtil.encryptPassword(oldUser.getUsername(),originPsword,oldUser.getSalt())); |
| | | newUser.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | delCacheByUsername(oldUser.getUsername(),oldUser.getIdentity()); |
| | | delCacheByUsername(oldUser.getPhone(),oldUser.getIdentity()); |
| | | return updateById(newUser); |
| | | } |
| | | |
| | |
| | | SysUser su=new SysUser().setId(user.getId()).setStatus(user.getStatus()); |
| | | su.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | delCacheByUsername(existUser.getUsername(),existUser.getIdentity()); |
| | | delCacheByUsername(existUser.getPhone(),existUser.getIdentity()); |
| | | return updateById(su); |
| | | } |
| | | |
| | |
| | | SysUser su=new SysUser().setId(user.getId()).setState(user.getState()); |
| | | su.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | | delCacheByUsername(existUser.getUsername(),existUser.getIdentity()); |
| | | delCacheByUsername(existUser.getPhone(),existUser.getIdentity()); |
| | | return updateById(su); |
| | | } |
| | | } |