-
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.
- Loading branch information
Showing
13 changed files
with
194 additions
and
13 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
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
2 changes: 1 addition & 1 deletion
2
...m/mpnp/baechelin/util/AmazonS3Config.java → ...p/baechelin/config/s3/AmazonS3Config.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
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/mpnp/baechelin/user/controller/UserInfoController.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,28 @@ | ||
package com.mpnp.baechelin.user.controller; | ||
|
||
import com.mpnp.baechelin.user.dto.UserInfoResponseDto; | ||
import com.mpnp.baechelin.user.entity.user.User; | ||
import com.mpnp.baechelin.user.service.UserInfoService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/userinfo") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class UserInfoController { | ||
private final UserInfoService userInfoService; | ||
|
||
@GetMapping | ||
// Security 추가 후 변경할 예정 | ||
// public ResponseEntity<UserInfoResponseDto> getUserInfo(@AuthenticationPrincipal User user) { | ||
public ResponseEntity<UserInfoResponseDto> getUserInfo(@RequestParam Integer userId) { | ||
log.warn("USERID {} " , userId); | ||
// return new ResponseEntity<>(userInfoService.giveUserInfo(user), HttpStatus.OK); | ||
return new ResponseEntity<>(userInfoService.giveUserInfo(userId), HttpStatus.OK); | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
src/main/java/com/mpnp/baechelin/user/dto/UserInfoResponseDto.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,120 @@ | ||
package com.mpnp.baechelin.user.dto; | ||
|
||
|
||
import com.mpnp.baechelin.bookmark.domain.Bookmark; | ||
import com.mpnp.baechelin.bookmark.domain.Folder; | ||
import com.mpnp.baechelin.review.domain.Review; | ||
import com.mpnp.baechelin.tag.domain.Tag; | ||
import com.mpnp.baechelin.user.entity.user.User; | ||
import lombok.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class UserInfoResponseDto { | ||
// User info | ||
private String name; | ||
private List<ReviewResponseDto> reviewList; | ||
private List<BookmarkFolderResponseDto> bookmarkFolderList; | ||
|
||
public UserInfoResponseDto(User user) { | ||
this.name = user.getName(); | ||
this.reviewList = user.getReviewList().stream().map(ReviewResponseDto::new).collect(Collectors.toList()); | ||
this.bookmarkFolderList = user.getFolderList().stream().map(BookmarkFolderResponseDto::new).collect(Collectors.toList()); | ||
//folder | ||
|
||
} | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
static class BookmarkFolderResponseDto { | ||
private int userId; | ||
private List<BookmarkResponseDto> folders; // 폴더 여러 개 | ||
|
||
public BookmarkFolderResponseDto(Folder folder) { | ||
this.userId = folder.getUserId().getId(); | ||
this.folders = folder.getBookmarkList().stream().map(BookmarkResponseDto::new).collect(Collectors.toList()); | ||
} | ||
} | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
static class BookmarkResponseDto { | ||
private int folderId; | ||
private int storeId; | ||
|
||
public BookmarkResponseDto(Bookmark bookmark){ | ||
this.folderId = bookmark.getFolderId().getId(); | ||
this.storeId = bookmark.getStoreId().getId(); | ||
} | ||
} | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
static class ReviewResponseDto { | ||
int id; // storeId | ||
int review; // reviewId | ||
Double point; | ||
|
||
String comment; | ||
String reviewImageUrl; | ||
|
||
TagResponseDto tag; | ||
|
||
LocalDateTime createdAt; | ||
LocalDateTime modifiedAt; | ||
|
||
public ReviewResponseDto(Review review) { | ||
this.id = review.getStoreId().getId(); | ||
this.review = review.getId(); | ||
this.point = review.getPoint(); | ||
this.comment = review.getReview(); | ||
this.reviewImageUrl = review.getReviewImageUrl(); | ||
this.tag = new TagResponseDto(review.getTagId(), review); | ||
} | ||
} | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
static class TagResponseDto { | ||
int id; // 태그 아이디 | ||
int review; // 리뷰 아이디 | ||
|
||
@Builder.Default | ||
char bKiosk = 'N', bTable = 'N', bMenu = 'N', bWheelchair = 'N', bHelp = 'N', bAutoDoor = 'N'; | ||
@Builder.Default | ||
char fDelicious = 'N', fClean = 'N', fVibe = 'N', fQuantity = 'N', fPrice = 'N', fGoodToEat = 'N'; | ||
|
||
public TagResponseDto(Tag tag, Review review) { | ||
this.id = tag.getId(); | ||
this.review = review.getId(); | ||
this.bKiosk = tag.getBKiosk(); | ||
this.bTable = tag.getBTable(); | ||
this.bMenu = tag.getBMenu(); | ||
this.bWheelchair = tag.getBWheelchair(); | ||
this.bHelp = tag.getBHelp(); | ||
this.bAutoDoor = tag.getBAutoDoor(); | ||
this.fDelicious = tag.getFDelicious(); | ||
this.fClean = tag.getFClean(); | ||
this.fVibe = tag.getFVibe(); | ||
this.fQuantity = tag.getFQuantity(); | ||
this.fPrice = tag.getFPrice(); | ||
this.fGoodToEat = tag.getFGoodToEat(); | ||
} | ||
} | ||
|
||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/mpnp/baechelin/user/service/UserInfoService.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,24 @@ | ||
package com.mpnp.baechelin.user.service; | ||
|
||
import com.mpnp.baechelin.user.dto.UserInfoResponseDto; | ||
import com.mpnp.baechelin.user.entity.user.User; | ||
import com.mpnp.baechelin.user.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
@Transactional | ||
@Service | ||
@RequiredArgsConstructor | ||
public class UserInfoService { | ||
private final UserRepository userRepository; | ||
|
||
// TODO Security 추가 후 변경할 예정 | ||
// public UserInfoResponseDto giveUserInfo(User user){ | ||
public UserInfoResponseDto giveUserInfo(Integer userId) { | ||
User targetUser = userRepository.findById(userId).orElseThrow(() -> new IllegalArgumentException("test - no user")); | ||
return new UserInfoResponseDto(targetUser); | ||
// return new UserInfoResponseDto(user); | ||
} | ||
} |