| | |
| | | import com.ycl.service.redis.RedisService; |
| | | import com.ycl.service.user.UmsAdminService; |
| | | import com.ycl.service.user.UmsMenuService; |
| | | import com.ycl.utils.AesEncryptUtil; |
| | | import com.ycl.utils.EasyExcelUtils; |
| | | import com.ycl.utils.redis.RedisKey; |
| | | import com.ycl.vo.user.UserVO; |
| | |
| | | @ApiOperation(value = "登录以后返回token") |
| | | @RequestMapping(value = "/login", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public CommonResult login(@Validated @RequestBody UmsAdminLoginParam umsAdminLoginParam) { |
| | | String token = adminService.login(umsAdminLoginParam.getUsername(), umsAdminLoginParam.getPassword()); |
| | | public CommonResult login(@Validated @RequestBody UmsAdminLoginParam umsAdminLoginParam) throws Exception { |
| | | String password = AesEncryptUtil.desEncrypt(umsAdminLoginParam.getPassword()); |
| | | // String password = umsAdminLoginParam.getPassword(); |
| | | String token = adminService.login(umsAdminLoginParam.getUsername(), password); |
| | | |
| | | if (token == null) { |
| | | return CommonResult.validateFailed("用户名或密码错误"); |
| | | } |
| | |
| | | private DataDictionary2Mapper dataDictionary2Mapper; |
| | | @Resource |
| | | private UmsDepartMapper umsDepartMapper; |
| | | |
| | | @ApiOperation("用户导入") |
| | | @PostMapping("/import") |
| | | public CommonResult importUser(MultipartFile file) throws IOException { |
| | |
| | | param.setNickName(item.getNickName()); |
| | | |
| | | String sex = item.getSex(); |
| | | if (sex.equals("男")){ |
| | | if (sex.equals("男")) { |
| | | param.setSex((byte) 1); |
| | | } else if (sex.equals("女")) { |
| | | param.setSex((byte) 0); |
| | | }else { |
| | | } else { |
| | | throw new RuntimeException("性别输入有误"); |
| | | } |
| | | |
| | | String isDy = item.getIsDy(); |
| | | if (isDy.equals("是")){ |
| | | if (isDy.equals("是")) { |
| | | param.setSex((byte) 1); |
| | | } else if (isDy.equals("否")) { |
| | | param.setSex((byte) 0); |
| | | }else { |
| | | } else { |
| | | throw new RuntimeException("党员输入有误"); |
| | | } |
| | | |
| | |
| | | |
| | | String role = item.getRole(); |
| | | UmsRole umsRole = umsRoleMapper.selectOne(new LambdaQueryWrapper<UmsRole>().eq(UmsRole::getName, role)); |
| | | if (Objects.isNull(umsRole)){ |
| | | if (Objects.isNull(umsRole)) { |
| | | param.setRoleIds(null); |
| | | }else { |
| | | } else { |
| | | List list = new ArrayList<>(); |
| | | list.add(umsRole.getId()); |
| | | param.setRoleIds(list); |
| | |
| | | |
| | | String userType = item.getUserType(); |
| | | DataDictionary dataDictionary = dataDictionary2Mapper.selectOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getName, userType)); |
| | | if (Objects.isNull(dataDictionary)){ |
| | | if (Objects.isNull(dataDictionary)) { |
| | | throw new RuntimeException("用户类型不存在"); |
| | | }else { |
| | | } else { |
| | | param.setUserType(dataDictionary.getId().intValue()); |
| | | } |
| | | |
| | | String department = item.getDepartment(); |
| | | UmsDepart umsDepart = umsDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, department)); |
| | | if (Objects.isNull(umsDepart)){ |
| | | if (Objects.isNull(umsDepart)) { |
| | | throw new RuntimeException("部门不存在"); |
| | | }else { |
| | | } else { |
| | | param.setDepartmentId(umsDepart.getId()); |
| | | } |
| | | |
| | |
| | | }).sheet().doRead(); |
| | | return CommonResult.success(true, "导入成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("获取指定用户信息") |
| | |
| | | return CommonResult.failed("找不到该用户"); |
| | | } else if (status == -3) { |
| | | return CommonResult.failed("旧密码错误"); |
| | | }else if (status == -4) { |
| | | } else if (status == -4) { |
| | | return CommonResult.failed("密码不能和登录名完全一致"); |
| | | } else { |
| | | return CommonResult.failed(); |