Examples of AjaxResult


Examples of net.baguajie.vo.AjaxResult

      fs.setUpdatedAt(new Date());
      userRepository.inc(signInUser.getId(), "followCount", -1);
      userRepository.inc(target.getId(), "fansCount", -1);
      followShipRepository.save(fs);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

        if(vo!=null){
          markers.add(MarkerVo.from(spot));
        }
      }
    }
    return new AjaxResult(AjaxResultCode.SUCCESS, markers);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

  public @ResponseBody
  AjaxResult submitBasic(@Valid UserBasicInfoFormBean formBean,
      BindingResult result, ModelAndView mav, HttpSession session) {
    User signInUser = sessionUtil.getSignInUser(session);
    if (signInUser == null) {
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
    if (result.hasErrors()) {
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    signInUser.setName(formBean.getName());
    signInUser.setCity(formBean.getCity());
    Gender gender = null;
    try {
      gender = Gender.valueOf(formBean.getGender());
    } catch (IllegalArgumentException iae) {
      logger.warn("Get illegal gender \"" + formBean.getGender()
          + "\" for user" + signInUser.getName());
    }
    signInUser.setGender(gender);
    signInUser.setSummary(formBean.getSummary());
    userRepository.save(signInUser);
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

  public @ResponseBody
  AjaxResult changePwd(@Valid UserPwdChangeFormBean formBean,
      BindingResult result, ModelAndView mav, HttpSession session) {
    User signInUser = sessionUtil.getSignInUser(session);
    if (signInUser == null) {
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
    if (formBean.getOldPwd() != null
        && !formBean.getOldPwd().equals(signInUser.getPassword())) {
      result.addError(new FieldError("formBean", "oldPwd", "密码不正确"));
    }
    if (result.hasErrors()) {
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    signInUser.setPassword(formBean.getNewPwd());
    userRepository.save(signInUser);
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

  public @ResponseBody
  AjaxResult changeAvatar(@Valid UserAvatarFormBean formBean,
      BindingResult result, ModelAndView mav, HttpSession session) {
    User signInUser = sessionUtil.getSignInUser(session);
    if (signInUser == null) {
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
    if (result.hasErrors()) {
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    try {
      int idx = formBean.getImageUrl().lastIndexOf("/");
      org.springframework.core.io.Resource resource = ac
          .getResource(ApplicationConfig.uploadTempRepository + "/"
              + formBean.getImageUrl().substring(idx + 1));
      File file = resource.getFile();
      String ext = null;
      if (file != null && ext == null) {
        ext = FilenameUtils.getExtension(file.getName());
      }
      BufferedImage orgImg = ImageIO.read(file);
      // save original avatar file
      String resId = imageService.put(file);
      Resource res = new Resource();
      res.setOrgSize(new Integer[]{ orgImg.getHeight(), orgImg.getWidth() });
      res.setResId(resId);
      res.setExt(ext);
      resourceRepository.save(res);
      signInUser.setAvatarOrg(res);
      // save avatar file
      BufferedImage avatarImg = orgImg.getSubimage(formBean.getX(),
          formBean.getY(), formBean.getW(), formBean.getH());
      ImageIO.write(avatarImg, ext, file);
      resId = imageService.put(file);
      res = new Resource();
      res.setOrgSize(new Integer[] { avatarImg.getHeight(), avatarImg.getWidth() });
      res.setResId(resId);
      res.setExt(ext);
      resourceRepository.save(res);
      signInUser.setAvatar(res);
      userRepository.save(signInUser);
    } catch (Exception e) {
      return new AjaxResult(AjaxResultCode.EXCEPTION, e.getMessage());
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

  @RequestMapping(value="/create", method=RequestMethod.POST)
  public @ResponseBody AjaxResult create(@Valid PlaceCreationVo vo,
      BindingResult result, ModelAndView mav, HttpSession session){
    User signInUser = sessionUtil.getSignInUser(session);
    if(signInUser==null){
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    Place place = placeRepository.save(Place.from(vo, signInUser));
    return new AjaxResult(AjaxResultCode.SUCCESS, place);
  }
View Full Code Here

Examples of net.baguajie.vo.AjaxResult

  @RequestMapping(value="/create", method=RequestMethod.POST)
  public @ResponseBody AjaxResult create(@Valid SpotCreationVo vo,
      BindingResult result, ModelAndView mav, HttpSession session){
    User signInUser = sessionUtil.getSignInUser(session);
    if(signInUser==null){
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
    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
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.