-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-141][FN-142][FN-143] 플래시 카드셋 상세/목록 조회 및 수정 기능 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fb204a7
Feat: 카드셋 목록 조회(검색) 기능
dungbik 9d554c3
Feat: 비공개 카드셋은 검색되지 않도록 수정
dungbik b0e4495
Feat: 카드셋 검색 쿼리문 수정
dungbik 0570489
Feat: 카드셋 상세 조회 기능
dungbik 1fca7bc
Feat: 카드셋 수정 기능
dungbik 2c7d5c0
Refactor: 그룹 초대 관련 검증 메서드 리팩토링
dungbik c7363b2
Fix: 코드 리뷰 내용 반영
dungbik da0ea91
Chore: 환경변수 뎁스 꼬인 부분 수정
dungbik c93ace0
Feat: 비회원 그룹 초대 이메일 전송 기능
dungbik 7701867
Feat: 회원가입시 비회원 그룹 초대 회원으로 변환 기능
dungbik a213ddd
Chore: Rename CursorPageRequest to CursorPagingRequest
dungbik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
30 changes: 13 additions & 17 deletions
30
src/main/java/project/flipnote/cardset/controller/CardSetController.java
This file contains hidden or 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,36 +1,32 @@ | ||
| package project.flipnote.cardset.controller; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.ModelAttribute; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import project.flipnote.cardset.model.CreateCardSetRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetResponse; | ||
| import project.flipnote.cardset.controller.docs.CardSetControllerDocs; | ||
| import project.flipnote.cardset.model.CardSetSearchRequest; | ||
| import project.flipnote.cardset.model.CardSetSummaryResponse; | ||
| import project.flipnote.cardset.service.CardSetService; | ||
| import project.flipnote.common.security.dto.AuthPrinciple; | ||
| import project.flipnote.common.model.response.PagingResponse; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/v1/groups/{groupId}/card-sets") | ||
| public class CardSetController { | ||
| @RequestMapping("/v1/card-sets") | ||
| public class CardSetController implements CardSetControllerDocs { | ||
|
|
||
| private final CardSetService cardSetService; | ||
|
|
||
| @PostMapping("") | ||
| public ResponseEntity<CreateCardSetResponse> createCardSet( | ||
| @AuthenticationPrincipal AuthPrinciple authPrinciple, | ||
| @PathVariable("groupId") Long groupId, | ||
| @RequestBody @Valid CreateCardSetRequest req | ||
| @GetMapping | ||
| public ResponseEntity<PagingResponse<CardSetSummaryResponse>> getCardSets( | ||
| @Valid @ModelAttribute CardSetSearchRequest req | ||
| ) { | ||
| CreateCardSetResponse res = cardSetService.createCardSet(groupId, authPrinciple, req); | ||
| PagingResponse<CardSetSummaryResponse> res = cardSetService.getCardSets(req); | ||
|
|
||
| return ResponseEntity.status(HttpStatus.CREATED).body(res); | ||
| return ResponseEntity.ok(res); | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
src/main/java/project/flipnote/cardset/controller/GroupCardSetController.java
This file contains hidden or 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,65 @@ | ||
| package project.flipnote.cardset.controller; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| 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.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import project.flipnote.cardset.controller.docs.GroupCardSetControllerDocs; | ||
| import project.flipnote.cardset.model.CardSetDetailResponse; | ||
| import project.flipnote.cardset.model.CardSetUpdateRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetResponse; | ||
| import project.flipnote.cardset.service.CardSetService; | ||
| import project.flipnote.common.security.dto.AuthPrinciple; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/v1/groups/{groupId}/card-sets") | ||
| public class GroupCardSetController implements GroupCardSetControllerDocs { | ||
|
|
||
| private final CardSetService cardSetService; | ||
|
|
||
| @PostMapping("") | ||
| public ResponseEntity<CreateCardSetResponse> createCardSet( | ||
| @AuthenticationPrincipal AuthPrinciple authPrinciple, | ||
| @PathVariable("groupId") Long groupId, | ||
| @RequestBody @Valid CreateCardSetRequest req | ||
| ) { | ||
| CreateCardSetResponse res = cardSetService.createCardSet(groupId, authPrinciple, req); | ||
|
|
||
| return ResponseEntity.status(HttpStatus.CREATED).body(res); | ||
| } | ||
|
|
||
| @GetMapping("/{cardSetId}") | ||
| public ResponseEntity<CardSetDetailResponse> getCardSet( | ||
| @PathVariable("groupId") Long groupId, | ||
| @PathVariable("cardSetId") Long cardSetId, | ||
| @AuthenticationPrincipal AuthPrinciple authPrinciple | ||
| ) { | ||
| CardSetDetailResponse res = cardSetService.getCardSet(authPrinciple.userId(), groupId, cardSetId); | ||
|
|
||
| return ResponseEntity.ok(res); | ||
| } | ||
|
|
||
| @PutMapping("/{cardSetId}") | ||
| public ResponseEntity<CardSetDetailResponse> updateCardSet( | ||
| @PathVariable("groupId") Long groupId, | ||
| @PathVariable("cardSetId") Long cardSetId, | ||
| @Valid @RequestBody CardSetUpdateRequest req, | ||
| @AuthenticationPrincipal AuthPrinciple authPrinciple | ||
| ) { | ||
| CardSetDetailResponse res = cardSetService.updateCardSet(authPrinciple.userId(), groupId, cardSetId, req); | ||
|
|
||
| return ResponseEntity.ok(res); | ||
| } | ||
|
|
||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/java/project/flipnote/cardset/controller/docs/CardSetControllerDocs.java
This file contains hidden or 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 project.flipnote.cardset.controller.docs; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import project.flipnote.cardset.model.CardSetSearchRequest; | ||
| import project.flipnote.cardset.model.CardSetSummaryResponse; | ||
| import project.flipnote.common.model.response.PagingResponse; | ||
|
|
||
| @Tag(name = "CardSet", description = "CardSet API") | ||
| public interface CardSetControllerDocs { | ||
|
|
||
| @Operation(summary = "카드셋 목록 조회(검색)", security = {@SecurityRequirement(name = "access-token")}) | ||
| ResponseEntity<PagingResponse<CardSetSummaryResponse>> getCardSets( | ||
| CardSetSearchRequest req | ||
| ); | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/project/flipnote/cardset/controller/docs/GroupCardSetControllerDocs.java
This file contains hidden or 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 project.flipnote.cardset.controller.docs; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import project.flipnote.cardset.model.CardSetDetailResponse; | ||
| import project.flipnote.cardset.model.CardSetUpdateRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetRequest; | ||
| import project.flipnote.cardset.model.CreateCardSetResponse; | ||
| import project.flipnote.common.security.dto.AuthPrinciple; | ||
|
|
||
| @Tag(name = "CardSet", description = "CardSet API") | ||
| public interface GroupCardSetControllerDocs { | ||
|
|
||
| @Operation(summary = "카드셋 생성", security = {@SecurityRequirement(name = "access-token")}) | ||
| ResponseEntity<CreateCardSetResponse> createCardSet( | ||
| AuthPrinciple authPrinciple, Long groupId, CreateCardSetRequest req | ||
| ); | ||
|
|
||
| @Operation(summary = "카드셋 상세 조회", security = {@SecurityRequirement(name = "access-token")}) | ||
| ResponseEntity<CardSetDetailResponse> getCardSet(Long groupId, Long cardSetId, AuthPrinciple authPrinciple); | ||
|
|
||
| @Operation(summary = "카드셋 수정", security = {@SecurityRequirement(name = "access-token")}) | ||
| ResponseEntity<CardSetDetailResponse> updateCardSet( | ||
| Long groupId, | ||
| Long cardSetId, | ||
| CardSetUpdateRequest req, | ||
| AuthPrinciple authPrinciple | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
src/main/java/project/flipnote/cardset/model/CardSetDetailResponse.java
This file contains hidden or 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,38 @@ | ||
| package project.flipnote.cardset.model; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
|
||
| import project.flipnote.cardset.entity.CardSet; | ||
|
|
||
| public record CardSetDetailResponse( | ||
| Long cardSetId, | ||
| Long groupId, | ||
| String name, | ||
| String category, | ||
| String hashtag, | ||
| String imageUrl, | ||
| boolean publicVisible, | ||
|
|
||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| LocalDateTime createdAt, | ||
|
|
||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| LocalDateTime modifiedAt | ||
| ) { | ||
|
|
||
| public static CardSetDetailResponse from(CardSet cardSet) { | ||
| return new CardSetDetailResponse( | ||
| cardSet.getId(), | ||
| cardSet.getGroup().getId(), | ||
| cardSet.getName(), | ||
| cardSet.getCategory().name(), | ||
| cardSet.getHashtag(), | ||
| cardSet.getImageUrl(), | ||
| cardSet.getPublicVisible(), | ||
| cardSet.getCreatedAt(), | ||
| cardSet.getModifiedAt() | ||
| ); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/project/flipnote/cardset/model/CardSetSearchRequest.java
This file contains hidden or 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,35 @@ | ||
| package project.flipnote.cardset.model; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Sort; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
| import project.flipnote.common.model.request.PagingRequest; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class CardSetSearchRequest extends PagingRequest { | ||
|
|
||
| private static final Set<String> ALLOWED_SORT_FIELDS = Set.of("id"); | ||
|
|
||
| private String keyword; | ||
| private String category; | ||
|
|
||
| @Override | ||
| public PageRequest getPageRequest() { | ||
| String sortBy = this.getSortBy(); | ||
| String effectiveSortBy = (sortBy != null && ALLOWED_SORT_FIELDS.contains(sortBy)) ? sortBy : "id"; | ||
|
|
||
| Sort.Direction direction; | ||
| try { | ||
| direction = Sort.Direction.fromString(this.getOrder()); | ||
| } catch (IllegalArgumentException e) { | ||
| direction = Sort.Direction.DESC; | ||
| } | ||
|
|
||
| return PageRequest.of(getPage() - 1, getSize() + 1, Sort.by(direction, effectiveSortBy)); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/project/flipnote/cardset/model/CardSetSummaryResponse.java
This file contains hidden or 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 project.flipnote.cardset.model; | ||
|
|
||
| import project.flipnote.cardset.entity.CardSet; | ||
|
|
||
| public record CardSetSummaryResponse( | ||
| Long cardSetId, | ||
| Long groupId, | ||
| String name, | ||
| String category, | ||
| String hashtag, | ||
| String imageUrl | ||
| ) { | ||
|
|
||
| public static CardSetSummaryResponse from(CardSet cardSet) { | ||
| return new CardSetSummaryResponse( | ||
| cardSet.getId(), | ||
| cardSet.getGroup().getId(), | ||
| cardSet.getName(), | ||
| cardSet.getCategory().name(), | ||
| cardSet.getHashtag(), | ||
| cardSet.getImageUrl() | ||
| ); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/project/flipnote/cardset/model/CardSetUpdatePayload.java
This file contains hidden or 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,22 @@ | ||
| package project.flipnote.cardset.model; | ||
|
|
||
| import project.flipnote.group.entity.Category; | ||
|
|
||
| public record CardSetUpdatePayload( | ||
| String name, | ||
| Boolean publicVisible, | ||
| Category category, | ||
| String hashtag, | ||
| String imageUrl | ||
| ) { | ||
|
|
||
| public static CardSetUpdatePayload from(CardSetUpdateRequest req) { | ||
| return new CardSetUpdatePayload( | ||
| req.name(), | ||
| req.publicVisible(), | ||
| req.category(), | ||
| req.getHashTag(), | ||
| req.image() | ||
| ); | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
src/main/java/project/flipnote/cardset/model/CardSetUpdateRequest.java
This file contains hidden or 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,36 @@ | ||
| package project.flipnote.cardset.model; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.hibernate.validator.constraints.URL; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
| import project.flipnote.group.entity.Category; | ||
|
|
||
| public record CardSetUpdateRequest( | ||
|
|
||
| @NotBlank | ||
| @Size(max = 50) | ||
| String name, | ||
|
|
||
| @NotNull | ||
| Boolean publicVisible, | ||
|
|
||
| @NotNull | ||
| Category category, | ||
|
|
||
| @NotNull | ||
| List<String> hashtag, | ||
|
|
||
| @URL | ||
| String image | ||
| ) { | ||
|
|
||
| @Schema(hidden = true) | ||
| public String getHashTag() { | ||
| return hashtag != null && !hashtag.isEmpty() ? String.join(",", hashtag) : null; | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.