예제 #1
0
 public void execute(
     Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
     throws TemplateException, IOException {
   Integer folderId = Integer.parseInt(params.get("folderId").toString());
   String basePath = HttpUtils.getBasePath(request);
   try {
     Folder folder = folderService.getFolderById(folderId);
     if (Boolean.getBoolean(PropertyUtils.getValue("shishuo.static"))) {
       env.getOut().write(basePath + "/html/folder/" + folder.getEname() + ".html");
     } else {
       env.getOut()
           .write(basePath + "/folder/" + folder.getEname() + ".htm?classifyId=" + folderId);
     }
   } catch (FolderNotFoundException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 /**
  * @author 进入修改目录资料页面
  * @throws Exception
  */
 @RequestMapping(value = "/photo.htm", method = RequestMethod.GET)
 public String photo(
     @RequestParam("folderId") long folderId,
     @RequestParam(value = "p", defaultValue = "1") int p,
     ModelMap modelMap,
     HttpServletRequest request)
     throws Exception {
   Folder folder = folderService.getFolderById(folderId);
   if (folder.getContent() == null) {
     folder.setContent("");
   }
   if (folder.getFatherId() == 0) {
     modelMap.put("fatherFolderName", "未分类");
   } else {
     Folder fatherFolder = folderService.getFolderById(folder.getFatherId());
     modelMap.put("fatherFolderName", fatherFolder.getName());
   }
   PageVo<AttachmentVo> pageVo =
       attachmentService.getAttachmentPageByKindId(
           folderId, AttachmentConstant.Kind.folder, 12, p);
   pageVo.getArgs().put("folderId", folderId + "");
   modelMap.put("folder", folder);
   modelMap.put("folderAll", folderService.getAllFolderList(0, null));
   modelMap.put("JSESSIONID", request.getSession().getId());
   modelMap.put("attachmentPage", pageVo);
   return "system/folder/photo";
 }
예제 #3
0
 /** @author 添加新的目录 */
 @ResponseBody
 @RequestMapping(value = "/add.json", method = RequestMethod.POST)
 public JsonVo<String> add(
     @RequestParam(value = "fatherId", defaultValue = "0") long fatherId,
     @RequestParam(value = "folderName") String folderName,
     @RequestParam(value = "folderEname") String folderEname,
     @RequestParam(value = "status") FolderConstant.Status status,
     ModelMap modelMap) {
   JsonVo<String> json = new JsonVo<String>();
   // FIXME 检查目录的ename不能用循环遍历检查
   List<FolderVo> list = folderService.getAllFolderList(0, null);
   try {
     if (StringUtils.isBlank(folderName)) {
       json.getErrors().put("folderName", "目录名称不能为空");
     }
     if (StringUtils.isBlank(folderEname)) {
       json.getErrors().put("folderEname", "英文名称不能为空");
     } else if (!RegexUtils.isAlphaUnderline(folderEname)) {
       json.getErrors().put("folderEname", "只能是英文字母,数字和下划线");
     } else {
       for (Folder folder : list) {
         if (folderEname.equals(folder.getEname())) {
           json.getErrors().put("folderEname", "英文名称不能重复");
         }
       }
     }
     // 检测校验结果
     validate(json);
     folderService.addFolder(
         fatherId,
         folderName,
         status,
         folderEname.toLowerCase(),
         FolderConstant.Rank.everyone,
         FolderConstant.Type.folder);
     json.setResult(true);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
     json.setResult(false);
     json.setMsg(e.getMessage());
   }
   return json;
 }
예제 #4
0
 /**
  * @author 进入目录列表
  * @throws FolderNotFoundException
  */
 @RequestMapping(value = "/page.htm", method = RequestMethod.GET)
 public String page(
     @RequestParam(value = "folderId", defaultValue = "0") long folderId, ModelMap modelMap)
     throws FolderNotFoundException {
   List<FolderVo> list = folderService.getFolderListByFatherId(folderId, null);
   List<Folder> pathList = folderService.getFolderPathListByFolderId(folderId);
   Folder folder = new Folder();
   if (folderId == 0) {
     folder.setFolderId(0);
     folder.setName("Home");
   } else {
     folder = folderService.getFolderById(folderId);
   }
   modelMap.put("folder", folder);
   modelMap.put("list", list);
   modelMap.put("pathList", pathList);
   modelMap.put("folderAll", folderService.getAllFolderList(0, null));
   return "system/folder/page";
 }
예제 #5
0
  /** @author 修改目录资料 */
  @ResponseBody
  @RequestMapping(value = "/update.json", method = RequestMethod.POST)
  public JsonVo<String> updateFolder(
      @RequestParam(value = "folderId") long folderId,
      @RequestParam(value = "name") String name,
      @RequestParam(value = "ename") String ename,
      @RequestParam(value = "content", required = false) String content) {

    JsonVo<String> json = new JsonVo<String>();
    // FIXME 检查目录的ename不能用循环遍历检查
    List<FolderVo> list = folderService.getAllFolderList(0, null);
    try {
      if (name.equals("")) {
        json.getErrors().put("name", "目录名称不能为空");
      }
      if (ename.equals("")) {
        json.getErrors().put("ename", "英文名称不能为空");
      } else {
        for (Folder folder : list) {
          if (folderId != folder.getFolderId()) {
            if (ename.equals(folder.getEname())) {
              json.getErrors().put("folderEname", "英文名称不能重复");
            }
          }
        }
      }

      // 检测校验结果
      validate(json);
      String newEname = ename.toLowerCase();
      folderService.updateFolderById(folderId, newEname, name, content);

      json.setResult(true);
    } catch (Exception e) {
      json.setResult(false);
      json.setMsg(e.getMessage());
    }
    return json;
  }