Package com.ketayao.ketacustom.entity.main

Examples of com.ketayao.ketacustom.entity.main.User


  }
 
  @ModelAttribute("preloadUser")
  public User preload(@RequestParam(value = "id", required = false) Long id) {
    if (id != null) {
      User user = userService.get(id);
      user.setOrganization(null);
      return user;
    }
    return null;
  }
View Full Code Here


  }
 
  @RequiresPermissions("User:edit:User拥有的资源")
  @RequestMapping(value="/update/{id}", method=RequestMethod.GET)
  public String preUpdate(@PathVariable Long id, Map<String, Object> map) {
    User user = userService.get(id);
   
    map.put("user", user);
    return UPDATE;
  }
View Full Code Here

 
  @Log(message="删除了{0}用户。")
  @RequiresPermissions("User:delete:User拥有的资源")
  @RequestMapping(value="/delete/{id}", method=RequestMethod.POST)
  public @ResponseBody String delete(@PathVariable Long id) {
    User user = null;
    try {
      user = userService.get(id);
      userService.delete(user.getId());
    } catch (ServiceException e) {
      return AjaxObject.newError("删除用户失败:" + e.getMessage()).setCallbackType("").toString();
    }
   
    LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{user.getUsername()}));
    return AjaxObject.newOk("删除用户成功!").setCallbackType("").toString();
  }
View Full Code Here

  @RequestMapping(value="/delete", method=RequestMethod.POST)
  public @ResponseBody String deleteMany(Long[] ids) {
    String[] usernames = new String[ids.length];
    try {
      for (int i = 0; i < ids.length; i++) {
        User user = userService.get(ids[i]);
        userService.delete(user.getId());
       
        usernames[i] = user.getUsername();
      }
    } catch (ServiceException e) {
      return AjaxObject.newError("删除用户失败:" + e.getMessage()).setCallbackType("").toString();
    }
   
View Full Code Here

 
  @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();
  }
View Full Code Here

  @RequiresPermissions("User:assign")
  @RequestMapping(value="/create/userRole", method={RequestMethod.POST})
  public @ResponseBody void assignRole(UserRole userRole) {
    userRoleService.saveOrUpdate(userRole);
   
    User user = userService.get(userRole.getUser().getId());
    Role role = roleService.get(userRole.getRole().getId());
    LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{user.getUsername(), role.getName()}));
  }
View Full Code Here

  @Log(message="{0}修改了密码。")
  @RequiresUser
  @RequestMapping(value="/updatePwd", method=RequestMethod.POST)
  public @ResponseBody String updatePassword(ServletRequest request, String plainPassword,
      String newPassword, String rPassword) {
    User user = SecurityUtils.getLoginUser();
   
    if (newPassword != null && newPassword.equals(rPassword)) {
      user.setPlainPassword(plainPassword);
      try {
        userService.updatePwd(user, newPassword);
      } catch (ServiceException e) {
        LogUitls.putArgs(LogMessageObject.newIgnore());//忽略日志
        return AjaxObject.newError(e.getMessage()).setCallbackType("").toString();
      }
      LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{user.getUsername()}));
      return AjaxObject.newOk("修改密码成功!").toString();
    }
   
    return AjaxObject.newError("修改密码失败!").setCallbackType("").toString();
  }
View Full Code Here

 
  @Log(message="{0}修改了详细信息。")
  @RequiresUser
  @RequestMapping(value="/updateBase", method=RequestMethod.POST)
  public @ResponseBody String updateBase(User user, ServletRequest request) {
    User loginUser = SecurityUtils.getLoginUser();
   
    loginUser.setPhone(user.getPhone());
    loginUser.setEmail(user.getEmail());

    userService.saveOrUpdate(loginUser);
   
    LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{user.getUsername()}));
    return AjaxObject.newOk("修改详细信息成功!").toString();
View Full Code Here

    if (isSupervisor(id)) {
      logger.warn("操作员{},尝试删除超级管理员用户", SecurityUtils.getSubject()
          .getPrincipal() + "。");
      throw new NotDeletedException("不能删除超级管理员用户。");
    }
    User user = userDAO.findOne(id);
    userDAO.delete(user.getId());
   
    // TODO 从shiro中注销
    shiroRealm.clearCachedAuthorizationInfo(user.getUsername());
  }
View Full Code Here

        throw new IncorrectCaptchaException("验证码错误!");
      }
    }
   
    UsernamePasswordToken token = (UsernamePasswordToken)authcToken;
    User user = userService.getByUsername(token.getUsername());
    if (user != null) {
      if (user.getStatus().equals(User.STATUS_DISABLED)) {
        throw new DisabledAccountException();
      }
     
      byte[] salt = Encodes.decodeHex(user.getSalt());
     
      ShiroUser shiroUser = new ShiroUser(user.getId(), user.getUsername());
     
      // 这里可以缓存认证
      return new SimpleAuthenticationInfo(shiroUser, user.getPassword(),
          ByteSource.Util.bytes(salt), getName());
    } else {
      return null;
    }
   
View Full Code Here

TOP

Related Classes of com.ketayao.ketacustom.entity.main.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.