Package com.skyline.user.model

Examples of com.skyline.user.model.User


  }

  @RequestMapping(value = "category/add", method = RequestMethod.POST)
  public ModelAndView addCategory(String categoryName) {

    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    ModelAndView mav = new ModelAndView();
    if (user != null) {
      //FIXME 不要使用redirect
      categoryService.createCategory(user.getId(), user.getPortrait(), user.getNickname(), categoryName, Activity.NORMAL);
      mav.setViewName("redirect:" + "manage" + URL_SUFFIX);
    } else {
      mav.addObject("REQUEST_FROM", requestFrom);
      mav.setViewName(ViewPaths.USER_LOGIN);
    }
View Full Code Here


//  String loginView;

  @RequestMapping("/complete")
  //FIXME 不要返回String
  public String completePersonInfoRequest() {
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    user = personalInfoService.getPersonInfoByUserID(user.getId());

    WebHelper.initRequest(null).setAttribute("personalInfo", user);
    WebHelper.initRequest(null).setAttribute("personalInfo_sex_name", user.getSex().name());
    return ViewPaths.USER_COMPLETEPERSONALINFO;
  }
View Full Code Here

  }

  @RequestMapping(value = "category/ajaxadd")
  public @ResponseBody
  List<Category> ajaxAddCategory(String categoryName) {
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    if (user != null
        && categoryService.createCategory(user.getId(), user.getPortrait(), user.getNickname(), categoryName, Activity.NORMAL)) {
      return categoryService.getCategoryByOwnerId(user.getId());
    } else {
      return null;
    }
  }
View Full Code Here

  }

  @RequestMapping(value = "/updateinfo", method = RequestMethod.GET)
  public ModelAndView updatePersonInfoRequest() {
    ModelAndView v = new ModelAndView();
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    try {
      user = personalInfoService.getPersonInfoByUserID(user.getId());
      WebHelper.initRequest(null).setAttribute("personalInfo", user);
      v.setViewName(ViewPaths.USER_UPDATEPERSONALINFO);
      return v;
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  public ModelAndView updatePersonInfo(String name, String nickname, Sex sex,
      String graduateshool, String job, String msn, String qq, String mobilephone,
      String country, String province, String city, String birthday) {
    ModelAndView v = new ModelAndView();
    // String ip = httpServletRequest.getRemoteAddr();
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);

    String countryName = country.split("-")[0];
    String provinceName = province.split("-")[0];
    String cityName = city.split("-")[0];
    String siteId = city.split("-")[1];

    try {
      // Date updateTime = new Date();
      Date dDate = null;
      try {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        dDate = format.parse(birthday);
        // return dDate;
      } catch (Exception e) {
        // Date now = new Date();
        dDate = new Date();
        // return now;
      }
      personalInfoService.modifyBasicInfo(user.getId(), name, nickname, dDate, sex,
          provinceName, cityName, countryName, siteId, job, graduateshool);
      personalInfoService.modifyCommunicationInfo(user.getId(), mobilephone, msn, qq);
      user = personalInfoService.getPersonInfoByUserID(user.getId());
      WebHelper.initRequest(null).setAttribute("personalInfo", user);
      // httpServletRequest.setAttribute("personalInfo_sex_name",
      // user.getSex().name());
      v.setViewName(ViewPaths.USER_UPDATEPERSONALINFO);
      return v;
View Full Code Here

  }

  @RequestMapping(value = "category/modify", method = RequestMethod.POST)
  public ModelAndView modifyCategory(Long id, String categoryName) {

    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    ModelAndView mav = new ModelAndView();
    Category category = categoryService.getCategoryById(id);
    if (user != null && category != null && user.getId().equals(category.getOwnerId())) {
      //FIXME 不要使用redirect
      categoryService.modifyCategory(id, categoryName, user.getId());
      mav.setViewName("redirect:" + "manage" + URL_SUFFIX);
    } else {
      mav.addObject("REQUEST_FROM", requestFrom);
      mav.setViewName(ViewPaths.USER_LOGIN);
    }
View Full Code Here

    }
  }

  @RequestMapping(value = "/photoupload", method = RequestMethod.GET)
  public ModelAndView photoUploadRequest() {
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    if (user == null) {
      throw new NotLoginException("上传头像必须登录");
    }

    long ownerId = user.getId();
    Album portraitAlbum = albumService.getUserPortraitAlbum(ownerId);
    Photo portraitPhoto = albumService.getCurrentPortraitPhotoFromAlbum(portraitAlbum);

    ModelAndView view = new ModelAndView();
    view.addObject("portraitAlbum", portraitAlbum);
View Full Code Here

    return mav;
  }

  @RequestMapping(value = "category/delete/{id}", method = RequestMethod.GET)
  public ModelAndView deleteCategory(@PathVariable Long id) {
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    // TODO:获取对该分类的访问权限;
    Integer authority = Authority.PRIVATE;
    ModelAndView mav = new ModelAndView();
    Category category = categoryService.getCategoryById(id);
    if (user != null && category != null && user.getId().equals(category.getOwnerId())) {
      // categoryService.modifyCategory(id, authority,
      //FIXME 不要使用redirect
      categoryService.deleteCategory(id, user.getId(), authority);
      mav.setViewName("redirect:" + "../manage" + URL_SUFFIX);
    } else {
      mav.addObject("REQUEST_FROM", requestFrom);
      mav.setViewName(ViewPaths.USER_LOGIN);
    }
View Full Code Here

    return view;
  }

  @RequestMapping(value = "/photoupload", method = RequestMethod.POST)
  public ModelAndView photoUploadOk(Integer x, Integer y, Integer size, String submitToken) {
    User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
    if (user == null) {
      throw new NotLoginException("上传头像必须登录");
    }

    String errMsg = this.validateForm("portraitUploadForm", submitToken);
    if (errMsg != null) {
      return processValidationErrors("errMsg", errMsg, photoUploadRequest());
    }

    long ownerId = user.getId();
    Photo portrait = albumService.getUserCurrentPortraitPhoto(ownerId);
    if (portrait == null) {
      throw new OperateFailedException("不存在当前图片,无法剪切");
    }
    long albumId = portrait.getAlbumId();

    String smallFile = portrait.getSmallFile();
    String ext = portrait.getExt();
    String remoteFileKey = smallFile + '.' + ext;

    SkylineImageCropTask cropTask = new SkylineImageCropTask(remoteFileKey, portraitSize);
    cropTask.setAlbumId(albumId);
    cropTask.setUserId(ownerId);
    cropTask.setOffsetX(x);
    cropTask.setOffsetY(y);
    cropTask.setCropSize(size);
    ImageCropResult cropResult;
    try {
      cropResult = crop.processImage(basePath, cropTask);
    } catch (IOException e) {
      throw new OperateFailedException("无法剪切图片");
    }
    if (cropResult == null || cropResult.getResultState() != ResultState.SUCCESS) {
      throw new OperateFailedException("无法剪切图片,原因:"
          + (cropResult == null ? null : cropResult.getResultState()));
    }
    String portraitFile = cropResult.getFileKey();

    personalInfoService.changeUserPortrait(ownerId, portraitFile);
    user.setPortrait(portraitFile);
    WebHelper.setSessionAttribute(null, Constant.SESSION_USER, user);

    String url = buildRecirectPath("/wo/myWo");
    ModelAndView view = new ModelAndView(new RedirectView(url));
    return view;
View Full Code Here

  Boolean modifyPassword(@RequestParam("oldPassword") String oldPassword,
      @RequestParam("password") String password,
      @RequestParam("passwordConfirm") String passwordConfirm) {
    // String ip = httpServletRequest.getRemoteAddr();
    try {
      User user = (User) WebHelper.getSessionAttribute(null, Constant.SESSION_USER);
      // Date updateTime = new Date();
      if (personalInfoService.checkPassword(user.getId(), oldPassword)) {
        personalInfoService.updatePassword(user.getId(), passwordConfirm);
      }
      return personalInfoService.checkPassword(user.getId(), password);
    } catch (Exception e) {
      LOGGER.warn("修改密码失败",e);
      return false;
    }
  }
View Full Code Here

TOP

Related Classes of com.skyline.user.model.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.