use of co.yixiang.modules.system.service.dto.UserDto in project yshopmall by guchengwuyue.
the class SysUserServiceImpl method download.
@Override
public void download(List<UserDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (UserDto user : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("邮箱", user.getEmail());
map.put("状态:1启用、0禁用", user.getEnabled());
map.put("密码", user.getPassword());
map.put("用户名", user.getUsername());
map.put("部门名称", user.getDeptId());
map.put("手机号码", user.getPhone());
map.put("创建日期", user.getCreateTime());
map.put("最后修改密码的日期", user.getLastPasswordResetTime());
map.put("昵称", user.getNickName());
map.put("性别", user.getSex());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
use of co.yixiang.modules.system.service.dto.UserDto in project yshopmall by guchengwuyue.
the class SysUserController method updateEmail.
@ForbidSubmit
@Log("修改邮箱")
@ApiOperation("修改邮箱")
@PostMapping(value = "/updateEmail/{code}")
public ResponseEntity<Object> updateEmail(@PathVariable String code, @RequestBody User user) {
// 密码解密
RSA rsa = new RSA(privateKey, null);
String password = new String(rsa.decrypt(user.getPassword(), KeyType.PrivateKey));
UserDto userDto = userService.findByName(SecurityUtils.getUsername());
if (!passwordEncoder.matches(password, userDto.getPassword())) {
throw new BadRequestException("密码错误");
}
VerificationCode verificationCode = new VerificationCode(code, YshopConstant.RESET_MAIL, "email", user.getEmail());
verificationCodeService.validated(verificationCode);
userService.updateEmail(userDto.getUsername(), user.getEmail());
return new ResponseEntity<>(HttpStatus.OK);
}
use of co.yixiang.modules.system.service.dto.UserDto in project yshopmall by guchengwuyue.
the class SysUserController method updatePass.
@ForbidSubmit
@ApiOperation("修改密码")
@PostMapping(value = "/updatePass")
public ResponseEntity<Object> updatePass(@RequestBody UserPassVo passVo) {
// 密码解密
RSA rsa = new RSA(privateKey, null);
String oldPass = new String(rsa.decrypt(passVo.getOldPass(), KeyType.PrivateKey));
String newPass = new String(rsa.decrypt(passVo.getNewPass(), KeyType.PrivateKey));
UserDto user = userService.findByName(SecurityUtils.getUsername());
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
throw new BadRequestException("修改失败,旧密码错误");
}
if (passwordEncoder.matches(newPass, user.getPassword())) {
throw new BadRequestException("新密码不能与旧密码相同");
}
userService.updatePass(user.getUsername(), passwordEncoder.encode(newPass));
return new ResponseEntity<>(HttpStatus.OK);
}
use of co.yixiang.modules.system.service.dto.UserDto in project yshopmall by guchengwuyue.
the class MenuController method buildMenus.
@ApiOperation("获取前端所需菜单")
@GetMapping(value = "/build")
public ResponseEntity<Object> buildMenus() {
UserDto user = userService.findByName(SecurityUtils.getUsername());
List<MenuDto> menuDtoList = menuService.findByRoles(roleService.findByUsersId(user.getId()));
List<MenuDto> menuDtos = (List<MenuDto>) menuService.buildTree(menuDtoList).get("content");
return new ResponseEntity<>(menuService.buildMenus(menuDtos), HttpStatus.OK);
}
use of co.yixiang.modules.system.service.dto.UserDto in project yshopmall by guchengwuyue.
the class SysUserController method center.
@ForbidSubmit
@Log("修改用户:个人中心")
@ApiOperation("修改用户:个人中心")
@PutMapping(value = "center")
public ResponseEntity<Object> center(@Validated(User.Update.class) @RequestBody User resources) {
UserDto userDto = userService.findByName(SecurityUtils.getUsername());
if (!resources.getId().equals(userDto.getId())) {
throw new BadRequestException("不能修改他人资料");
}
userService.saveOrUpdate(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
Aggregations