use of com.yh.weatherpush.entity.Admin in project weather-push by yangh124.
the class AdminController method info.
@ApiOperation("获取用户信息")
@GetMapping("/info")
public Result<JSONObject> info(Principal principal) {
if (principal == null) {
return Result.unauthorized(null);
}
String username = principal.getName();
Admin admin = adminService.getAdminByUsername(username);
JSONObject result = new JSONObject();
result.put("name", admin.getNickName());
result.put("avatar", admin.getAvatar());
return Result.success(result);
}
use of com.yh.weatherpush.entity.Admin in project weather-push by yangh124.
the class AdminServiceImpl method updatePassword.
@CacheEvict(value = "admin", key = "#updPwdParam.username")
@Override
public void updatePassword(UpdPwdParam updPwdParam) {
Admin admin = getAdminByUsername(updPwdParam.getUsername());
boolean matches = passwordEncoder.matches(updPwdParam.getOldPassword(), admin.getPassword());
if (!matches) {
throw new ApiException("原密码错误");
}
String newPassword = updPwdParam.getNewPassword();
String confirmPassword = updPwdParam.getConfirmPassword();
if (!newPassword.equals(confirmPassword)) {
throw new ApiException("确认密码与新密码不一致!");
}
String pwd = passwordEncoder.encode(newPassword);
LambdaUpdateWrapper<Admin> updateWrapper = new UpdateWrapper<Admin>().lambda().set(Admin::getPassword, pwd).eq(Admin::getId, admin.getId());
update(updateWrapper);
}
Aggregations