Examples of AjaxResult


Examples of net.baguajie.vo.AjaxResult

      activity.setTargetSpot(target.getId());
      activity.setType(ActivityType.TRACK);
      activity.setBy(sessionUtil.getBy(session));
      activityRepository.save(activity);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      ts.setUpdatedAt(new Date());
      userRepository.inc(signInUser.getId(), "trackCount", -1);
      spotRepository.inc(target.getId(), "trackedCount", -1);
      trackShipRepository.save(ts);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      throw new ResourceNotFoundException();
    }
    if (sessionUtil.getSignInUser(session) != null) {
      Calendar c = Calendar.getInstance();
      c.setTimeZone(TimeZone.getTimeZone("UTC"));
      return new AjaxResult(AjaxResultCode.SUCCESS, c.getTimeInMillis());
    } else {
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      Model model, HttpServletRequest request, HttpSession session){
    if(!ajaxUtil.isAjaxRequest(request)){
      throw new ResourceNotFoundException();
    }
    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    Activity activity = activityRepository.findOne(bean.getActId());
    if(activity==null){
      throw new RuntimeException("Invalid activity id:" + bean.getActId());
    }
    if(activity.getTargetSpot() == null ||
        (ActivityType.SPOT != activity.getType() &&
          ActivityType.FORWARD != activity.getType())){
      throw new RuntimeException("Invalid activity type:" + activity.getType());
    }
    Spot target = spotRepository.findOne(activity.getTargetSpot());
 
    // save forward as comment
    Forward fwd = Forward.from(bean, signInUser);
    fwd.setAct(activity);
    fwd = forwardRepository.save(fwd);
   
    // incr forwarded count of original activity
    activityRepository.inc(activity.getId(), "forwardedCount", 1);
   
    // save forward activity
    activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(target.getId());
    activity.setContent(bean.getContent());
    activity.setType(ActivityType.FORWARD);
    activity.setBasedOn(bean.getActId());
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    // incr forwarded count of target spot
    spotRepository.inc(target.getId(), "forwardedCount", 1);
   
    // incr forward count of sign in user
    userRepository.inc(signInUser.getId(), "forwardCount", 1);
   
    return new AjaxResult(AjaxResultCode.SUCCESS, fwd);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

    }
    imageFile.transferTo(file);
    BufferedImage orgImg = ImageIO.read(file);
    float h = orgImg.getHeight();
    float w = orgImg.getWidth();
    AjaxResult result = new AjaxResult(AjaxResultCode.SUCCESS);
    if (h < 200 || w < 200) {
      result.setResultCode(AjaxResultCode.EXCEPTION);
      result.setExceptionMsg("头像尺寸不小于200x200");
    } else {
      if (w > 350) {
        w = 350;
        h = h / (orgImg.getWidth() / w);
        int rw = Math.round(w);
        int rh = Math.round(h);
        BufferedImage newImg = new BufferedImage(rw, rh,
            BufferedImage.TYPE_INT_RGB);
        // 创建Graphics2D对象,用于在BufferedImage对象上绘图。
        Graphics2D g = newImg.createGraphics();
        // 设置图形上下文的当前颜色为白色。
        g.setColor(Color.WHITE);
        // 用图形上下文的当前颜色填充指定的矩形区域。
        g.fillRect(0, 0, rw, rh);
        // 按照缩放的大小在BufferedImage对象上绘制原始图像。
        g.drawImage(orgImg, 0, 0, rw, rh, null);
        // 释放图形上下文使用的系统资源。
        g.dispose();
        // 刷新此 Image 对象正在使用的所有可重构的资源.
        orgImg.flush();
        newName = new StringBuilder()
            .append(System.currentTimeMillis()).append(ext)
            .toString();
        file = res.getFile();
        if (file.isDirectory()) {
          file = new File(file.getPath() + File.separator + newName);
        }
        ImageIO.write(newImg, ext.substring(1), file);
      }
      result.setResultData(ApplicationConfig.base
          + ApplicationConfig.uploadTempRefer + "/" + newName);
    }
    response.setContentType("application/json;charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    return result;
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      session.setAttribute(ApplicationConstants.SESSION_SELECTED_CITY_META,
        cityMeta);
    }else{
      cityMeta = sessionUtil.getGeoCityMeta(session);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS, cityMeta);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      Model model, HttpServletRequest request, HttpSession session){
    if(!ajaxUtil.isAjaxRequest(request)){
      throw new ResourceNotFoundException();
    }
    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    Activity activity = activityRepository.findOne(bean.getActId());
    if(activity==null){
      throw new RuntimeException("Invalid activity id:" + bean.getActId());
    }
    // save comment
    Comment cmt = Comment.from(bean, signInUser);
    cmt.setAct(activity);
    cmt = commentRepository.save(cmt);
   
    // incr commented count of orignal activity
    activityRepository.inc(activity.getId(), "commentedCount", 1);
   
    // incr comment count of sign in user
    userRepository.inc(signInUser.getId(), "commentCount", 1);
   
    if(activity.getTargetSpot()!=null){
      Spot spot = spotRepository.findOne(activity.getTargetSpot());
      // incr commented count of target spot
      spotRepository.inc(spot.getId(), "commentedCount", 1);
    }
   
    // save cmt activity
    activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(activity.getTargetSpot());
    activity.setTargetUser(activity.getOwner());
    activity.setContent(bean.getContent());
    activity.setType(ActivityType.COMMENT);
    activity.setBasedOn(bean.getActId());
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    return new AjaxResult(AjaxResultCode.SUCCESS, cmt);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      ModelAndView mav, HttpSession session){
    if(!ajaxUtil.isAjaxRequest(request)){
      throw new ResourceNotFoundException();
    }
    CityMeta city = sessionUtil.getGeoCityMeta(session);
    return city != null ? new AjaxResult(AjaxResultCode.SUCCESS, city) :
      meta(null, request, mav, session);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

    CityMeta cityMeta = cityMetaRepository.getByPinyin(py);
    if(cityMeta == null){
      cityMeta = cityMetaRepository
          .getByPinyin(ApplicationConfig.defaultCityPinyin);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS, cityMeta);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

      activity.setTargetUser(target.getId());
      activity.setType(ActivityType.FOLLOW);
      activity.setBy(sessionUtil.getBy(session));
      activityRepository.save(activity);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.