Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Tentennball committed Aug 2, 2024
2 parents 6feec6f + 23e85ad commit 2c558fe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/main/java/gible/domain/post/api/PostApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ public interface PostApi {
ResponseEntity<?> savePost(@Valid @RequestBody PostReq postReq,
@AuthenticationPrincipal SecurityUserDetails userDetails);

@Operation(summary = "사용자 정보 불러오기", description = "사용자의 정보를 불러오기 위한 API")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "사용자 정보 불러오기 성공",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(value = """
{
"name": "홍길동",
"phoneNumber": "010-1234-5678"
}
""")
})
)
})
ResponseEntity<?> getUserInfo(@AuthenticationPrincipal SecurityUserDetails userDetails);

@Operation(summary = "게시글 리스트 가져오기", description = "게시글 리스트를 조회하기 위한 API")
@ApiResponses({
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/gible/domain/post/controller/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gible.domain.post.dto.PostReq;
import gible.domain.post.service.PostService;
import gible.domain.security.common.SecurityUserDetails;
import gible.domain.user.service.UserService;
import gible.global.common.response.SuccessRes;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +23,7 @@
@RestController
public class PostController implements PostApi {

private final UserService userService;
private final PostService postService;

/* 게시글 업로드 */
Expand All @@ -34,6 +36,14 @@ public ResponseEntity<?> savePost(@Valid @RequestBody PostReq postReq,
return ResponseEntity.status(HttpStatus.CREATED).body(SuccessRes.from("게시글 업로드 완료."));
}

/* 게시글에 필요한 정보 불러오기 */
@Override
@GetMapping("/user-info")
public ResponseEntity<?> getUserInfo(@AuthenticationPrincipal SecurityUserDetails userDetails) {

return ResponseEntity.ok().body(userService.getUserInfo(userDetails.getId()));
}

/* 게시글 목록 조회 + 검색 조회 */
@Override
@GetMapping
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/gible/domain/user/dto/UserInfoRes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gible.domain.user.dto;

public record UserInfoRes(
String name,
String phoneNumber
) {
public static UserInfoRes of(final String name, final String phoneNumber) {
return new UserInfoRes(name, phoneNumber);
}
}
12 changes: 6 additions & 6 deletions src/main/java/gible/domain/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gible.domain.user.dto.MyPageRes;
import gible.domain.user.dto.SignUpReq;
import gible.domain.user.dto.UserInfoRes;
import gible.domain.user.entity.User;
import gible.domain.user.repository.UserRepository;
import gible.exception.CustomException;
Expand Down Expand Up @@ -33,12 +34,11 @@ public MyPageRes getMyPage(UUID userId) {
return MyPageRes.of(user.getEmail(), user.getNickname());
}

// @Transactional(readOnly = true)
// public List<EventSummaryRes> getParticipationEvents(UUID userId) {
// return participateRepository.findByUser_Id(userId)
// .stream().map(Participate::getEvent).toList()
// .stream().map(EventSummaryRes::fromEntity).toList();
// }
@Transactional
public UserInfoRes getUserInfo(UUID userId) {
User user = findById(userId);
return UserInfoRes.of(user.getName(), user.getPhoneNumber());
}

@Transactional
public void deleteById(UUID userId) {
Expand Down

0 comments on commit 2c558fe

Please sign in to comment.