-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcc2dc3
commit 2379a6b
Showing
24 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+3.08 KB
server/build/classes/java/main/com/example/hackathon/user/application/MypageService.class
Binary file not shown.
Binary file added
BIN
+2.38 KB
server/build/classes/java/main/com/example/hackathon/user/controller/MypageController.class
Binary file not shown.
Binary file modified
BIN
-2.08 KB
(17%)
server/build/classes/java/main/com/example/hackathon/user/controller/UserController.class
Binary file not shown.
Binary file added
BIN
+1.8 KB
...s/java/main/com/example/hackathon/user/dto/UserInfoResponse$UserInfoResponseBuilder.class
Binary file not shown.
Binary file added
BIN
+2.03 KB
server/build/classes/java/main/com/example/hackathon/user/dto/UserInfoResponse.class
Binary file not shown.
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
Binary file removed
BIN
-5.25 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/ContentController.class.uniqueId1
Binary file not shown.
Binary file removed
BIN
-2.1 KB
...uild/tmp/compileJava/compileTransaction/stash-dir/ContentDetailController.class.uniqueId2
Binary file not shown.
Binary file removed
BIN
-3.23 KB
...eTransaction/stash-dir/ContentDetailResponse$ContentDetailResponseBuilder.class.uniqueId3
Binary file not shown.
Binary file removed
BIN
-3.17 KB
.../build/tmp/compileJava/compileTransaction/stash-dir/ContentDetailResponse.class.uniqueId0
Binary file not shown.
Binary file removed
BIN
-17.3 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/ContentService.class.uniqueId4
Binary file not shown.
Binary file added
BIN
+2.11 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/MypageController.class.uniqueId0
Binary file not shown.
Binary file added
BIN
+595 Bytes
server/build/tmp/compileJava/compileTransaction/stash-dir/UserController.class.uniqueId1
Binary file not shown.
Binary file modified
BIN
+260 Bytes
(100%)
server/build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
32 changes: 32 additions & 0 deletions
32
server/src/main/java/com/example/hackathon/user/application/MypageService.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,32 @@ | ||
package com.example.hackathon.user.application; | ||
|
||
import com.example.hackathon.exception.BadRequestException; | ||
import com.example.hackathon.user.domain.User; | ||
import com.example.hackathon.user.dto.UserInfoResponse; | ||
import com.example.hackathon.user.repository.UserRepository; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
@AllArgsConstructor | ||
@Service | ||
public class MypageService { | ||
private final UserRepository userRepository; | ||
public UserInfoResponse getUserInfo(Long userId){ | ||
User user = userRepository.findById(userId) | ||
.orElseThrow(() -> new BadRequestException("유저 토큰 값을 다시 확인해주세요")); | ||
UserInfoResponse userInfoResponse = UserInfoResponse.builder() | ||
.email(user.getEmail()) | ||
.profileImage(user.getImageUrl()) | ||
.username(user.getName()) | ||
.build(); | ||
return userInfoResponse; | ||
} | ||
|
||
public String updateUserName(Long userId, String nickName){ | ||
User user = userRepository.findById(userId) | ||
.orElseThrow(() -> new BadRequestException("유저 토큰 값을 다시 확인해주세요")); | ||
user.setName(nickName); | ||
userRepository.save(user); | ||
return "success update nickname"; | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
server/src/main/java/com/example/hackathon/user/controller/MypageController.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,33 @@ | ||
package com.example.hackathon.user.controller; | ||
|
||
import com.example.hackathon.exception.ResourceNotFoundException; | ||
import com.example.hackathon.oauth.security.CurrentUser; | ||
import com.example.hackathon.user.application.MypageService; | ||
import com.example.hackathon.user.domain.User; | ||
import com.example.hackathon.user.dto.UserInfoResponse; | ||
import com.example.hackathon.user.repository.UserRepository; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
@RequestMapping("/api/mypage") | ||
public class MypageController { | ||
private final MypageService mypageService; | ||
@GetMapping("/info") | ||
@Operation(summary = "유저 정보를 가져옵니다." ,description = "userId를 파라미터로 넣어주세요") | ||
public ResponseEntity<UserInfoResponse> getUserInfo(@RequestParam Long userId) { | ||
return new ResponseEntity<>(mypageService.getUserInfo(userId), HttpStatus.OK); | ||
} | ||
|
||
@PutMapping("/update/nickname") | ||
@Operation(summary = "유저 닉네임 수정 입니다. " ,description = "userId, 수정할 닉네임을 파라미터로 넣어주세요") | ||
public ResponseEntity<String> updateUserInfo(@RequestParam Long userId, | ||
@RequestParam String nickname){ | ||
return new ResponseEntity<>(mypageService.updateUserName(userId,nickname), HttpStatus.OK); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
server/src/main/java/com/example/hackathon/user/dto/UserInfoResponse.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,11 @@ | ||
package com.example.hackathon.user.dto; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record UserInfoResponse( | ||
String username, | ||
String email, | ||
String profileImage | ||
) { | ||
} |