Skip to content

Commit

Permalink
Merge pull request #186 from Kek-i/feature/184-users-mypage
Browse files Browse the repository at this point in the history
  • Loading branch information
sojungpp authored Mar 17, 2023
2 parents c06b35b + 6ea4075 commit 6ff9b71
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public GetOrderHistoryRes getOrderHistory(Long userIdx, GetOrderHistoryReq order
}

// 주문 상태 별 주문 수
private NumOfOrder getCountByOrderStatus(User user) throws BaseException{
public NumOfOrder getCountByOrderStatus(User user) throws BaseException{
NumOfOrder numOfOrder = new NumOfOrder();
if (getRoleByName(user.getRole()) == CUSTOMER) {
numOfOrder.setOrderWaiting(orderRepository.countByUserAndOrderStatusEquals(user, ORDER_WAITING));
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/codepatissier/keki/user/dto/GetProfileRes.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.codepatissier.keki.user.dto;


import com.codepatissier.keki.order.dto.NumOfOrder;
import com.codepatissier.keki.user.entity.User;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

@Data
Expand All @@ -10,11 +13,16 @@ public class GetProfileRes {
private String email;
private String nickname;
private String profileImg;
private int orderWaiting;
private int progressing;
private int pickupWaiting;


public GetProfileRes(String email, String nickname, String profileImg) {
this.email = email;
this.nickname = nickname;
this.profileImg = profileImg;
public GetProfileRes(User user, NumOfOrder numOfOrder) {
this.email = user.getEmail();
this.nickname = user.getNickname();
this.profileImg = user.getProfileImg();
this.orderWaiting = numOfOrder.getOrderWaiting();
this.progressing = numOfOrder.getProgressing();
this.pickupWaiting = numOfOrder.getPickupWaiting();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.codepatissier.keki.common.BaseResponseStatus;
import com.codepatissier.keki.common.Constant;
import com.codepatissier.keki.common.Role;
import com.codepatissier.keki.order.dto.NumOfOrder;
import com.codepatissier.keki.order.service.OrderService;
import com.codepatissier.keki.user.dto.*;
import com.codepatissier.keki.user.entity.Provider;
import com.codepatissier.keki.user.entity.User;
Expand All @@ -22,6 +24,7 @@
public class UserService {
private final UserRepository userRepository;
private final AuthService authService;
private final OrderService orderService;

// 로그인
public PostUserRes login(String email, String provider) throws BaseException{
Expand Down Expand Up @@ -84,7 +87,9 @@ public void checkNickname(PostNicknameReq postNicknameReq) throws BaseException{
public GetProfileRes getProfile() throws BaseException {
Long userIdx = authService.getUserIdx();
User user = userRepository.findByUserIdxAndStatusEquals(userIdx, ACTIVE_STATUS).orElseThrow(() -> new BaseException(INVALID_USER_IDX));
return new GetProfileRes(user.getEmail(), user.getNickname(), user.getProfileImg());}
NumOfOrder numOfOrder = orderService.getCountByOrderStatus(user);
return new GetProfileRes(user, numOfOrder);
}

// 구매자 프로필 수정
@Transactional
Expand Down

0 comments on commit 6ff9b71

Please sign in to comment.