示例#1
0
  /** 图片上传 */
  public void upload() {
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setContentType("text/html;charset=UTF-8");

    // 目前path临时用fpageimage
    FileOperate fileOp = new FileOperate();
    String rootPath = systemProp.getFpageLocalUrl() + File.separator + "event";
    if (!new File(rootPath).exists()) {
      fileOp.newFolder(rootPath);
    }

    String currentDate = DateUtil.format(new Date(), "yyyyMMdd");
    String path = rootPath + File.separator + currentDate;
    if (!new File(path).exists()) {
      fileOp.newFolder(path);
    }
    String newImgFileName =
        System.currentTimeMillis()
            + imgFileName.substring(imgFileName.lastIndexOf(".")).toLowerCase();
    String newImgFilePath = path + File.separator + newImgFileName;

    fileOp.moveFile(img.getAbsolutePath(), newImgFilePath);

    ImageUtil.smallerByRatio(newImgFilePath, path + File.separator + "0.7_" + newImgFileName, 0.7f);
    ImageUtil.smallerTag(newImgFilePath, path + File.separator + "68_" + newImgFileName, 68, 68, 3);

    Integer imgWidth = ImageUtil.getWidth(newImgFilePath);
    Integer imgHeight = ImageUtil.getHeight(newImgFilePath);
    //
    //        //        FpageInfo fpageInfo = new FpageInfo();
    //        //        fpageInfo.setId(Long.parseLong(uploadFileId));
    //        //        fpageInfo.setImgFile(newImgFileName);
    //        //        this.fpageInfoService.update(fpageInfo);
    //
    // 改版后,图片尺寸不限制 20120704
    try {
      //            if ((imgWidth != 200 && imgWidth != 436) || (imgHeight != 200 && imgHeight !=
      // 436)) {
      //                response.getWriter().print("{success:'false',msg:'您上传的图片大小不符合规格,请重新上传'}");
      //            } else {
      fpageEvent.setWidth((float) imgWidth);
      fpageEvent.setHeight((float) imgHeight);
      response
          .getWriter()
          .print(
              "{success:'true',newImgFileName:'"
                  + ("/" + currentDate + "/" + newImgFileName)
                  + "', width: "
                  + imgWidth
                  + ", height: "
                  + imgHeight
                  + "}");
      //            }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
示例#2
0
 /** 首页管理:失效 */
 public void invalid() {
   String[] ids_arr = ids.split(",");
   for (String id : ids_arr) {
     FpageEvent fpageEvent = new FpageEvent();
     fpageEvent.setId(Long.parseLong(id.toString()));
     fpageEvent.setStatus(PojoConstant.FPAGE.STATUS_INVALID);
     this.fpageEventService.update(fpageEvent);
   }
 }
示例#3
0
  public String addJson() {
    try {
      ActionContext ctx = ActionContext.getContext();
      HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
      BufferedInputStream inputStream = new BufferedInputStream(request.getInputStream());

      FpageEvent fpageEvent = new FpageEvent();
      fpageEvent.setIssueId(issueId);
      // fpageEvent.setPublicationId(issueService.queryById(issueId).getPublicationId());
      fpageEvent.setPageNo(start);
      fpageEvent.setEndPageNo(end);
      fpageEvent.setDescription(description);
      fpageEvent.setTitle(title);
      if (description != null) {
        fpageEvent.setDescription(java.net.URLDecoder.decode(description));
      }
      if (title != null) {
        fpageEvent.setTitle(java.net.URLDecoder.decode(title));
      }
      fpageEvent.setWidth(width);
      fpageEvent.setHeight(height);
      fpageEvent.setAdId(adId);
      System.out.println("--->:" + tagStr);
      String[] arr = null;
      if (StringUtil.isNotBlank(tagStr)) { // 添加标签(事件)
        tagStr = java.net.URLDecoder.decode(tagStr);
        arr = tagStr.split(";");
      }

      this.jsonResult =
          fpageEventService.addJson(
              fpageEvent,
              inputStream,
              (Admin) ctx.getSession().get(WebConstant.SESSION.ADMIN),
              arr);

    } catch (Exception e) {
      e.printStackTrace();
      this.generateJsonResult(JsonResult.CODE.EXCEPTION, "服务器内部错误");
    }
    return JSON;
  }