Package net.baguajie.domains

Examples of net.baguajie.domains.Spot


      @ModelAttribute(ApplicationConstants.SESSION_SIGNIN_USER) User signInUser,
      Model model, HttpServletRequest request, HttpSession session){
    if(!ajaxUtil.isAjaxRequest(request)){
      throw new ResourceNotFoundException();
    }
    Spot target = spotRepository.findOne(targetId);
    if(target==null){
      throw new RuntimeException("Invalid spot id : " + targetId);
    }
    TrackShip ts = trackShipRepository.getByTargetAndTracked(targetId, signInUser.getId());
    boolean tracked = false;
    if(ts!=null && ts.getStatus() == ApplicationConstants.TRACKSHIP_DISABLED){
      tracked = true;
      ts.setStatus(ApplicationConstants.TRACKSHIP_NORMAL);
      ts.setUpdatedAt(new Date());
      userRepository.inc(signInUser.getId(), "trackCount", 1);
      spotRepository.inc(target.getId(), "trackedCount", 1);
      trackShipRepository.save(ts);
    }else if(ts==null){
      tracked = true;
      ts = new TrackShip();
      ts.setCreatedAt(new Date());
      ts.setUpdatedAt(ts.getCreatedAt());
      ts.setTarget(target);
      ts.setTracked(signInUser);
      ts.setStatus(ApplicationConstants.FOLLOWSHIP_NORMAL);
      userRepository.inc(signInUser.getId(), "trackCount", 1);
      spotRepository.inc(target.getId(), "trackedCount", 1);
      trackShipRepository.save(ts);
    }
    if(tracked){
      trackShipRepository.save(ts);
      // save activity
      Activity activity = new Activity();
      activity.setOwner(signInUser.getId());
      activity.setCreatedAt(new Date());
      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


      Model model, HttpServletRequest request,
      HttpSession session){
    if(!ajaxUtil.isAjaxRequest(request)){
      throw new ResourceNotFoundException();
    }
    Spot target = spotRepository.findOne(targetId);
    if(target==null){
      throw new RuntimeException("Invalid spot id : " + targetId);
    }
    TrackShip ts = trackShipRepository.getByTargetAndTracked(targetId, signInUser.getId());
    if(ts!=null && ts.getStatus() == ApplicationConstants.TRACKSHIP_NORMAL){
      ts.setStatus(ApplicationConstants.TRACKSHIP_DISABLED);
      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

    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

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

      if(act.getOwner()!=null){
        User owner = userRepository.findOne(act.getOwner());
        vo.setOwner(owner);
      }
      if(act.getTargetSpot()!=null){
        Spot spot = spotRepository.findOne(act.getTargetSpot());
        vo.setTargetSpot(spot);
      }
      if(act.getTargetUser()!=null){
        User targetUser = userRepository.findOne(act.getTargetUser());
        vo.setTargetUser(targetUser);
View Full Code Here

 
  @RequestMapping(value="/{id}", method=RequestMethod.GET)
  public String view(@PathVariable String id, Model model,
      HttpServletRequest request, HttpSession session){
   
    Spot spot = spotRepository.findOne(id);
    model.addAttribute("spot", spot);
    return "spots/single";
  }
View Full Code Here

      if(act.getOwner()!=null){
        User owner = userRepository.findOne(act.getOwner());
        vo.setOwner(owner);
      }
      if(act.getTargetSpot()!=null){
        Spot spot = spotRepository.findOne(act.getTargetSpot());
        vo.setTargetSpot(spot);
      }
      if(act.getTargetUser()!=null){
        User targetUser = userRepository.findOne(act.getTargetUser());
        vo.setTargetUser(targetUser);
View Full Code Here

  @RemotingInclude
  public ROResult updateSpotStatus(String id, SpotStatus status) {
    ROResult result = new ROResult();
    try {
      Spot spot = spotRepository.findOne(id);
      if (spot != null) {
        spot.setStatus(status);
        spot.setUpdatedAt(new Date());
        spotRepository.save(spot);
        result.setResult(spot);
      } else {
        throw new RuntimeException("Could not find spot with id \""
            + id + "\"");
View Full Code Here

      pageable = new PageRequest(0,
          ApplicationConfig.pinCmtPageSize,
          new Sort(new Order(Direction.DESC, "createdAt")));
      for(TrackShip ts : tss){
        if(ts.getTarget()==null) continue;
        Spot spot = ts.getTarget();
        Activity act = activityRepository.getByOwnerAndTargetSpotAndType(
            spot.getCreatedBy().getId(), spot.getId(), ActivityType.SPOT.name());
        Page<Comment> cmts = null;
        if(act!=null){
           cmts = commentRepository.findByAct(
              act.getId(), pageable);
        }
        if(spot.getPlace()==null){
          pins.add(PinVo.from(spot,
              cityMetaRepository.getByPinyin(StringUtils.hasText(spot.getCity())?
                  spot.getCity():ApplicationConfig.defaultCityPinyin), act, cmts));
        }else{
          pins.add(PinVo.from(spot,null,act, cmts));
        }
      }
    }
View Full Code Here

    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    // save spot
    Spot spot = Spot.from(vo, signInUser);
    try {
      // get image
      ImageReadyVo ir = webImageUtil
          .prepareImageFromUrl(vo.getImageUrl());
      String resId = imageService.put(ir.getFile());
      Resource res = new Resource();
      res.setOrgSize(ir.getOrgSize());
      res.setResId(resId);
      res.setExt(ir.getExt());
      resourceRepository.save(res);
      spot.setImage(res);
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    if(StringUtils.hasText(vo.getPlaceId())){
      Place place = placeRepository.findOne(vo.getPlaceId());
      if(place!=null){
        CityMeta city = cityMetaRepository.getByName(place.getCity());
        if(city!=null){
          spot.setCity(city.getPinyin());
        }
        spot.setLngLat(place.getLngLat());
        spot.setPlace(place);
      }
    }else if(!StringUtils.hasText(spot.getCity())){
      spot.setCity(ApplicationConfig.defaultCityPinyin);
    }
    spot = spotRepository.save(spot);
    // increase spot count
    signInUser.setSpotCount(signInUser.getSpotCount()+1);
    userRepository.save(signInUser);
    // save activity
    Activity activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(spot.getId());
    activity.setType(ActivityType.SPOT);
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    return new AjaxResult(AjaxResultCode.SUCCESS);
View Full Code Here

TOP

Related Classes of net.baguajie.domains.Spot

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.