-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from lotteon2/dev-user-mypage
Dev user mypage
- Loading branch information
Showing
32 changed files
with
398 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/bit/lotte/flower/user/social/dto/UserPhoneNumberDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.bit.lotte.flower.user.social.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
@NoArgsConstructor | ||
public class UserPhoneNumberDto { | ||
|
||
private String phoneNumber; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/bit/lotte/flower/user/social/dto/command/UpdateUserInfoCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bit.lotte.flower.user.social.dto.command; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class | ||
UpdateUserInfoCommand { | ||
@Nullable | ||
private String nickname; | ||
@Nullable | ||
private String email; | ||
@Nullable | ||
private String phoneNumber; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/bit/lotte/flower/user/social/dto/response/UserDataDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bit.lotte.flower.user.social.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class UserDataDto { | ||
|
||
private String nickname; | ||
private String phoneNumber; | ||
private String email; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/bit/lotte/flower/user/social/dto/response/UserMypageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.bit.lotte.flower.user.social.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@Getter | ||
@NoArgsConstructor | ||
public class UserMypageResponse<T extends UserDataDto> { | ||
Long couponCnt; | ||
Long likesCnt; | ||
T data; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 54 additions & 5 deletions
59
src/main/java/com/bit/lotte/flower/user/social/http/controller/SocialUserRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,74 @@ | ||
package com.bit.lotte.flower.user.social.http.controller; | ||
|
||
|
||
import com.bit.lotte.flower.user.social.dto.response.UserDataResponse; | ||
import bloomingblooms.response.CommonResponse; | ||
import com.bit.lotte.flower.user.social.dto.UserPhoneNumberDto; | ||
import com.bit.lotte.flower.user.social.dto.command.UpdateUserInfoCommand; | ||
import com.bit.lotte.flower.user.social.dto.command.UserLoginCommand; | ||
import com.bit.lotte.flower.user.social.dto.response.UserLoginDataResponse; | ||
import com.bit.lotte.flower.user.social.dto.response.UserDataDto; | ||
import com.bit.lotte.flower.user.social.dto.response.UserMypageResponse; | ||
import com.bit.lotte.flower.user.social.http.message.GetUserCouponCntRequest; | ||
import com.bit.lotte.flower.user.social.http.message.GetUserLikesCntRequest; | ||
import com.bit.lotte.flower.user.social.service.GetUserInfoService; | ||
import com.bit.lotte.flower.user.social.service.SocialUserLoginManager; | ||
import com.bit.lotte.flower.user.social.service.SocialUpdateUserService; | ||
import javax.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class SocialUserRestController { | ||
|
||
private final GetUserLikesCntRequest getUserLikesCntRequest; | ||
private final GetUserCouponCntRequest getUserCouponCntRequest; | ||
private final GetUserInfoService getUserInfoService; | ||
private final SocialUserLoginManager socialUserLoginManager; | ||
private final SocialUpdateUserService socialUserService; | ||
|
||
@PostMapping("/users/social") | ||
public ResponseEntity<UserDataResponse> userLogin(@RequestBody UserLoginCommand userLoginCommand){ | ||
UserDataResponse response = socialUserLoginManager.process(userLoginCommand); | ||
return ResponseEntity.ok(response); | ||
@PostMapping("/social") | ||
public ResponseEntity<UserLoginDataResponse> userLogin( | ||
@RequestBody UserLoginCommand userLoginCommand) { | ||
UserLoginDataResponse response = socialUserLoginManager.process(userLoginCommand); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
@PutMapping("/social/phone-number") | ||
public CommonResponse<String> userPhoneNumberUpdate( | ||
@RequestBody UserPhoneNumberDto phoneNumberDto, @RequestHeader Long userId) { | ||
socialUserService.updatePhoneNumber(userId, phoneNumberDto.getPhoneNumber()); | ||
return CommonResponse.success("성공"); | ||
} | ||
|
||
@GetMapping("/social") | ||
public CommonResponse<UserMypageResponse<UserDataDto>> getUserData(@RequestHeader Long userId) { | ||
UserDataDto userDataDto = getUserInfoService.getUserdata(userId); | ||
Long userLikesCnt = getUserLikesCntRequest.request(userId); | ||
Long userCouponCnt = getUserCouponCntRequest.request(userId); | ||
return CommonResponse.success(getUserMypageResponse(userDataDto, userLikesCnt, userCouponCnt)); | ||
} | ||
|
||
@PutMapping("/social") | ||
public CommonResponse<String> updateUserData(@RequestHeader Long userId, | ||
@Valid @RequestBody UpdateUserInfoCommand command) { | ||
socialUserService.updateUserInfo(userId, command.getNickname(), command.getEmail(), | ||
command.getPhoneNumber()); | ||
return CommonResponse.success("업데이트 성공"); | ||
|
||
} | ||
|
||
private UserMypageResponse<UserDataDto> getUserMypageResponse(UserDataDto userDataDto, Long likesCnt, | ||
Long couponCnt) { | ||
return UserMypageResponse.builder().data(userDataDto).couponCnt(couponCnt) | ||
.likesCnt(likesCnt).build(); | ||
} | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/bit/lotte/flower/user/social/http/feign/UserLikesFeignRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.bit.lotte.flower.user.social.http.feign; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
|
||
@FeignClient(name = "get-user-likes-cnt", value = "${service.likes.domain}") | ||
public interface UserLikesFeignRequest { | ||
|
||
@GetMapping("/likes-cnt") | ||
ResponseEntity<Long> getUserLikesCnt(@RequestHeader Long userId); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...ain/java/com/bit/lotte/flower/user/social/http/feign/UserUsableCouponCntFeignRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.bit.lotte.flower.user.social.http.feign; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
@FeignClient(name = "get-user-usable-coupon-cnt", value = "${service.coupon.domain}") | ||
public interface UserUsableCouponCntFeignRequest { | ||
@GetMapping("/coupons/count") | ||
ResponseEntity<Long> getUsableUserCouponCnt(@RequestHeader Long userId); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/bit/lotte/flower/user/social/http/message/GetUserCouponCntRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.bit.lotte.flower.user.social.http.message; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public interface GetUserCouponCntRequest { | ||
public Long request(Long userId); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/bit/lotte/flower/user/social/http/message/GetUserCouponCntRequestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bit.lotte.flower.user.social.http.message; | ||
|
||
import com.bit.lotte.flower.user.social.http.feign.UserUsableCouponCntFeignRequest; | ||
import java.util.Objects; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class GetUserCouponCntRequestImpl implements | ||
GetUserCouponCntRequest { | ||
|
||
private final UserUsableCouponCntFeignRequest feignRequest; | ||
@Override | ||
public Long request(Long userId) { | ||
return feignRequest.getUsableUserCouponCnt(userId).getBody(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/bit/lotte/flower/user/social/http/message/GetUserLikesCntRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.bit.lotte.flower.user.social.http.message; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public interface GetUserLikesCntRequest { | ||
public Long request(Long userId); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/bit/lotte/flower/user/social/http/message/GetUserLikesCntRequestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.bit.lotte.flower.user.social.http.message; | ||
|
||
import com.bit.lotte.flower.user.social.http.feign.UserLikesFeignRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class GetUserLikesCntRequestImpl implements | ||
GetUserLikesCntRequest { | ||
|
||
private final UserLikesFeignRequest userLikesFeignRequest; | ||
@Override | ||
public Long request(Long userId) { | ||
return userLikesFeignRequest.getUserLikesCnt(userId).getBody(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/bit/lotte/flower/user/social/repository/FindSocialUserByLongIdService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bit.lotte.flower.user.social.repository; | ||
|
||
|
||
import com.bit.lotte.flower.user.social.entity.SocialUser; | ||
import com.bit.lotte.flower.user.social.exception.SocialUserDomainException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class FindSocialUserByLongIdService { | ||
|
||
private final SocialUserJpaRepository repository; | ||
|
||
public SocialUser findUserElseThrowError(Long id) { | ||
return repository.findById(id).orElseThrow(() -> { | ||
throw new SocialUserDomainException("존재하지 않는 회원입니다."); | ||
}); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/bit/lotte/flower/user/social/service/GetUserInfoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.bit.lotte.flower.user.social.service; | ||
|
||
import com.bit.lotte.flower.user.social.dto.response.UserDataDto; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public interface GetUserInfoService { | ||
UserDataDto getUserdata(Long id); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/bit/lotte/flower/user/social/service/GetUserInfoWithService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bit.lotte.flower.user.social.service; | ||
|
||
import com.bit.lotte.flower.user.social.dto.response.UserDataDto; | ||
import com.bit.lotte.flower.user.social.entity.SocialUser; | ||
import com.bit.lotte.flower.user.social.mapper.SocialUserMapper; | ||
import com.bit.lotte.flower.user.social.repository.FindSocialUserByLongIdService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
@RequiredArgsConstructor | ||
@Service | ||
public class GetUserInfoWithService implements | ||
GetUserInfoService { | ||
private final FindSocialUserByLongIdService findUserByIdService; | ||
@Override | ||
public UserDataDto getUserdata(Long id) { | ||
SocialUser socialUser = findUserByIdService.findUserElseThrowError(id); | ||
return SocialUserMapper.socialUserToUserMyPageDataResponse(socialUser); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/bit/lotte/flower/user/social/service/SocialUpdateUserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.bit.lotte.flower.user.social.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public interface SocialUpdateUserService { | ||
|
||
void updatePhoneNumber(Long userId ,String phoneNumber); | ||
|
||
void updateUserInfo(Long userId, String nickname, String email, String phoneNumber); | ||
} | ||
|
Oops, something went wrong.