Package com.ketayao.ketacustom.util.dwz

Examples of com.ketayao.ketacustom.util.dwz.AjaxObject


 
  @Log(message="删除了{0}条资源。")
  @RequiresPermissions("Resource:delete")
  @RequestMapping(value="/delete", method=RequestMethod.POST)
  public @ResponseBody String deleteMany(Long[] ids, HttpServletRequest request) {
    AjaxObject ajaxObject = new AjaxObject("删除资源成功!");
    for (Long id : ids) {
      Resource resource = resourceService.get(id);
      if (resource.getStoreType().equals(StoreType.FILE)) {
        String storePath = getFileStorePath(request);
        String filePath = storePath + File.separator + resource.getRealStoreName();
        File file = new File(filePath);
        if (file.exists()) {
          try {
            org.apache.commons.io.FileUtils.forceDelete(file);
          } catch (IOException e) {
            //LOG.error("强制删除文件:" + resource.getName() + "失败。");
            return AjaxObject.newError(resource.getName() + "文件删除失败,请稍后再试。")
                .setCallbackType("").toString();
          }
        }
      }
     
      resourceService.delete(id);
    }
   
    LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{ids.length}));
    ajaxObject.setCallbackType("");
    return ajaxObject.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

  @RequestMapping(method = {RequestMethod.POST}, headers = "x-requested-with=XMLHttpRequest")
  public @ResponseBody String failDialog(ServletRequest request) {
    String msg = parseException(request);
   
    AjaxObject ajaxObject = new AjaxObject(msg);
    ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
    ajaxObject.setCallbackType("");

    return ajaxObject.toString();
  }
View Full Code Here

 
  @Log(message="删除了{0}条日志。")
  @RequiresPermissions("LogInfo:delete")
  @RequestMapping(value="/delete", method=RequestMethod.POST)
  public @ResponseBody String deleteMany(Long[] ids) {
    AjaxObject ajaxObject = new AjaxObject("删除日志成功!");
    for (Long id : ids) {
      logInfoService.delete(id);
    }
   
    LogUitls.putArgs(LogMessageObject.newWrite().setObjects(new Object[]{ids.length}));
    ajaxObject.setCallbackType("");
    return ajaxObject.toString();
  }
View Full Code Here

    for (String error : errorList) {
      msg.append(error + ",");
    }
   
    msg.setCharAt(msg.length() - 1, '。');
    AjaxObject ajaxObject = AjaxObject.newError(msg.toString());
    return new ResponseEntity<String>(ajaxObject.toString(), HttpStatus.OK);
  }
View Full Code Here

    }
   
    msg.setCharAt(msg.length() - 1, ',');
    msg.append("绑定错误。");
   
    AjaxObject ajaxObject = AjaxObject.newError(msg.toString());
    return new ResponseEntity<Object>(ajaxObject.toString(), HttpStatus.OK);
  }
View Full Code Here

TOP

Related Classes of com.ketayao.ketacustom.util.dwz.AjaxObject

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.