Package net.baguajie.domains

Examples of net.baguajie.domains.User


  @RequestMapping(value = "/setting/changepwd/validate", method = RequestMethod.POST)
  public @ResponseBody
  Object[] validateChangePwd(@Valid UserPwdChangeFormBean formBean,
      BindingResult result, ModelAndView mav, HttpSession session) {
    User signInUser = sessionUtil.getSignInUser(session);
    if (formBean.getOldPwd() != null
        && !formBean.getOldPwd().equals(signInUser.getPassword())) {
      result.addError(new FieldError("formBean", "oldPwd", "密码不正确"));
    }
    if (result.hasErrors()) {
      return ValidationEngineError.normalize(ValidationEngineError
          .from(result));
View Full Code Here


  @RequestMapping(value = "/setting/avatar", method = RequestMethod.POST)
  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

            spot.getImage().getOrgSize()[1]));
      }
     
    }
    if(spot.getCreatedBy()!=null){
      User user = spot.getCreatedBy();
      vo.setCreatedById(user.getId());
      vo.setCreatedByName(user.getName());
      vo.setCreatedByAvatarUrl(
        DomainObjectUtil.getAvatarUrl(user.getAvatar(),
          user.getGender()));
    }
    if(cmts != null){
      List<Comment> comments = new ArrayList<Comment>();
      for(Comment cmt : cmts){
        comments.add(cmt);
View Full Code Here

 
  @RemotingInclude
  public ROResult signIn(String email, String pwd) {
    ROResult result = new ROResult();
    try {
      User existed = null;
      if (email != null && pwd != null) {
        existed = userRepository.getByEmail(email);
      } else {
        throw new RuntimeException("登陆邮箱或密码不能为空");
      }
      if (existed == null) {
        throw new RuntimeException("登陆邮箱\"" + email + "\"不存在");
      } else if (!pwd.equals(existed.getPassword())) {
        throw new RuntimeException("登陆密码错误");
      }
//      else if (Role.ADMIN != existed.getRole()) {
//        throw new RuntimeException("该用户无此权限");
//      }
View Full Code Here

  @RemotingInclude
  public ROResult updateUser(User u) {
    ROResult result = new ROResult();
    try {
      User user = userRepository.findOne(u.getId());
      if (user != null) {
        user.setStatus(u.getStatus());
        user.setRole(u.getRole());
        user.setUpdatedAt(new Date());
        userRepository.save(user);
        result.setResult(user);
      } else {
        throw new RuntimeException("Could not find user with id \""
            + u.getId() + "\"");
View Full Code Here

 
  @RequestMapping(value="/{id}/spots/{no}", method=RequestMethod.GET)
  public String spots(@PathVariable String id,
      @PathVariable int no, Model model,
      HttpServletRequest request, HttpSession session){
    User user = userRepository.findOne(id);
    model.addAttribute("user", user);
    Pageable pageable = new PageRequest(no >= 0 ? no : 0,
        ApplicationConfig.masonryPageSize,
        new Sort(new Order(Direction.DESC, "createdAt")));
    Iterable<Spot> spots = spotRepository.findByCreatedBy(id, pageable);
View Full Code Here

 
  @RequestMapping(value="/{id}/tracks/{no}", method=RequestMethod.GET)
  public String tracks(@PathVariable String id,
      @PathVariable int no, Model model,
      HttpServletRequest request, HttpSession session){
    User user = userRepository.findOne(id);
    model.addAttribute("user", user);
    Pageable pageable = new PageRequest(no >= 0 ? no : 0,
        ApplicationConfig.masonryPageSize,
        new Sort(new Order(Direction.DESC, "createdAt")));
    Iterable<TrackShip> tss = trackShipRepository.findByTrackedAndStatus(id, 0, pageable);
View Full Code Here

  }
 
  @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,
View Full Code Here

  }
 
  @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);
View Full Code Here

  SessionUtil sessionUtil;
 
  @RequestMapping(value="/dashboard", method=RequestMethod.GET)
  public String get(Model model,
      HttpServletRequest request, HttpSession session){
    User user = sessionUtil.getSignInUser(session);
    if(user == null){
      return "forward:/signin";
    }
    model.addAttribute("user", user);
    return "dashboard";
View Full Code Here

TOP

Related Classes of net.baguajie.domains.User

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.