Пример #1
0
  @LoginRequired
  @RequestMapping(value = "/profile/settings/nickname", method = RequestMethod.POST)
  @ResponseBody
  public Object updateNickname(@RequestBody UpdateNicknameForm updateNicknameForm)
      throws InvalidNicknameException, NickNameAlreadyExistException, NickNameIllegalException {
    long userId = HehuaRequestContext.getUserId();
    String result = userService.updateNickname(userId, updateNicknameForm.getNickname());

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("nickname", result);
    return ResponseRender.renderResponse(jsonObject);
  }
Пример #2
0
  @LoginRequired
  @RequestMapping(value = "/profile", method = RequestMethod.GET)
  @ResponseBody
  public JSONObject getProfile() {

    long userId = HehuaRequestContext.getUserId();
    User user = userManager.getUserById(userId);
    Baby baby = babyService.getBabyByUidxUid(userId);
    Address defaultAddress = addressService.getDefaultAddress(userId);

    Map<Integer, Integer> statuesMap = orderService.getStatusesMap(userId);
    int unpays = Objects.firstNonNull(statuesMap.get(OrdersModel.STATUS_NEW), 0);
    int unrececives = Objects.firstNonNull(statuesMap.get(OrdersModel.STATUS_DELIVERIED), 0);

    return ResponseRender.renderResponse(
        profileRender.renderProfile(user, baby, defaultAddress, unpays, unrececives));
  }