@Log(message="{0}用户{1}")
@RequiresPermissions("User:reset:User拥有的资源")
@RequestMapping(value="/reset/{type}/{userId}", method=RequestMethod.POST)
public @ResponseBody String reset(@PathVariable String type, @PathVariable Long userId) {
User user = userService.get(userId);
AjaxObject ajaxObject = new AjaxObject();
ajaxObject.setCallbackType("");
if (type.equals("password")) {
userService.resetPwd(user, "123456");
ajaxObject.setMessage("重置密码成功,默认为123456!");
} else if (type.equals("status")) {
if (user.getStatus().equals("enabled")) {
user.setStatus("disabled");
} else {
user.setStatus("enabled");
}
ajaxObject.setMessage("更新状态成功,当前为" + (user.getStatus().equals(User.STATUS_ENABLED)?"可用":"不可用"));
userService.saveOrUpdate(user);
}
LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{user.getUsername(), ajaxObject.getMessage()}));
return ajaxObject.toString();
}