-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: #10 로그인 회원가입 request 방식 수정, User 관련 API 구현
* Feat: 회원가입/로그인 토큰 입력 Header->body로 변경, User 관련 api 제작 * Feat: User 엔티티 Wrapper Class로 수정, WebConfig 추가 * Feat: User 클래스 Getter 어노테이션 추가
- Loading branch information
Showing
13 changed files
with
247 additions
and
22 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
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
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
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
53 changes: 52 additions & 1 deletion
53
src/main/java/com/example/nzgeneration/domain/user/UserController.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,21 +1,72 @@ | ||
package com.example.nzgeneration.domain.user; | ||
|
||
|
||
import com.example.nzgeneration.domain.user.dto.UserResponseDto.UserEditingPageDetailInfo; | ||
import com.example.nzgeneration.domain.user.dto.UserResponseDto.UserMyPageDetailInfo; | ||
import com.example.nzgeneration.domain.user.dto.UserResponseDto.UserSigningSimpleInfo; | ||
import com.example.nzgeneration.global.common.response.ApiResponse; | ||
import com.example.nzgeneration.global.security.CurrentUser; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/user") | ||
public class UserController { | ||
private final UserService userService; | ||
|
||
@PostMapping("member/stamp") | ||
@PostMapping("/stamp") | ||
public ApiResponse<String> addStamp(@CurrentUser User user) { | ||
userService.addStamp(user); | ||
return ApiResponse.onSuccess("스탬프 찍기 성공"); | ||
} | ||
@GetMapping("/check-nickname/{nickName}") | ||
@Operation(summary = "닉네임 중복 확인", description = "true : 사용가능한 닉네임, false : 사용 불가능한 닉네임") | ||
public ApiResponse<Boolean> checkNickName(@PathVariable String nickName){ | ||
boolean status = userService.checkNickNameDuplicate(nickName); | ||
return ApiResponse.onSuccess(status); | ||
} | ||
@PatchMapping("/nickname/{nickName}") | ||
public ApiResponse<String> updateNickName(@CurrentUser User user, @PathVariable String nickName){ | ||
userService.updateNickName(user, nickName); | ||
return ApiResponse.onSuccess("닉네임 수정 완료"); | ||
|
||
} | ||
@PatchMapping("/wallet-address/{walletAddress}") | ||
public ApiResponse<String> updateWalletAddress(@CurrentUser User user, @PathVariable String walletAddress){ | ||
userService.updateWalletAddress(user, walletAddress); | ||
return ApiResponse.onSuccess("지갑 주소 수정 완료"); | ||
} | ||
@PatchMapping("/profile-image") | ||
public ApiResponse<String> updateProfileImg(@CurrentUser User user, @RequestPart MultipartFile image){ | ||
userService.updateUserProfileImage(user, image); | ||
return ApiResponse.onSuccess("프로필 사진 수정 완료"); | ||
} | ||
@GetMapping("/days-signing") | ||
public ApiResponse<UserSigningSimpleInfo> getDaysSigning(@CurrentUser User user){ | ||
return ApiResponse.onSuccess(userService.getDaysSigning(user)); | ||
} | ||
|
||
@GetMapping("/my-page") | ||
public ApiResponse<UserMyPageDetailInfo> getMyPageInfo(@CurrentUser User user){ | ||
return ApiResponse.onSuccess(userService.getMyPageInfo(user)); | ||
} | ||
|
||
@GetMapping("/edit-page") | ||
public ApiResponse<UserEditingPageDetailInfo> getEditPage(@CurrentUser User user){ | ||
return ApiResponse.onSuccess(userService.getEditPageInfo(user)); | ||
} | ||
|
||
|
||
|
||
|
||
} |
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
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
66 changes: 66 additions & 0 deletions
66
src/main/java/com/example/nzgeneration/domain/user/dto/UserResponseDto.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,66 @@ | ||
package com.example.nzgeneration.domain.user.dto; | ||
|
||
import com.example.nzgeneration.domain.user.User; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class UserResponseDto { | ||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class UserSigningSimpleInfo{ | ||
private String nickName; | ||
private long howManyDays; | ||
|
||
public static UserSigningSimpleInfo toDTO(User user, long days){ | ||
return UserSigningSimpleInfo.builder() | ||
.nickName(user.getNickname()) | ||
.howManyDays(days) | ||
.build(); | ||
|
||
} | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class UserMyPageDetailInfo{ | ||
private String nickName; | ||
private Integer currentPoint; | ||
private Integer badgeCount; | ||
private Integer nftCount; | ||
|
||
public static UserMyPageDetailInfo toDTO(User user){ | ||
return UserMyPageDetailInfo.builder() | ||
.nickName(user.getNickname()) | ||
.badgeCount(user.getBadgeCount()) | ||
.currentPoint(user.getCurrentPoint()) | ||
.nftCount(user.getNftCount()) | ||
.build(); | ||
} | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class UserEditingPageDetailInfo{ | ||
private String profileImgUrl; | ||
private String nickName; | ||
private String walletAddress; | ||
|
||
public static UserEditingPageDetailInfo toDTO(User user){ | ||
return UserEditingPageDetailInfo.builder() | ||
.profileImgUrl(user.getProfileImageUrl()) | ||
.nickName(user.getNickname()) | ||
.walletAddress(user.getWalletAddress()) | ||
.build(); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.