-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/#42 발행 관련 api 추가 #43
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
6 commits
Select commit
Hold shift + click to select a range
9834a0e
[feat/#42] 발행 생성, 연월별 조회, 삭제 api 구현
seokbeom00 d990fcd
[feat/#42] 문항세트 조회 시 발행날짜 필드 추가
seokbeom00 5e1e097
[feat/#42] 문항세트 컨펌 시 유효하지 않은 문항id 에러메시지에 포함
seokbeom00 2ba6044
[fix/#42] 발행날짜 유효성검사 도메인으로 이동
seokbeom00 909bf4f
[fix/42] 발행 조회 쿼리 개선
seokbeom00 757b6a0
[feat/#42] 발행용 컨펌된 문항세트 검색 api 추가
seokbeom00 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
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
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
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 |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ | |
|
|
||
| import static com.moplus.moplus_server.domain.concept.domain.QConceptTag.conceptTag; | ||
| import static com.moplus.moplus_server.domain.problem.domain.problem.QProblem.problem; | ||
| import static com.moplus.moplus_server.domain.problemset.domain.ProblemSetConfirmStatus.CONFIRMED; | ||
| import static com.moplus.moplus_server.domain.problemset.domain.QProblemSet.problemSet; | ||
| import static com.moplus.moplus_server.domain.publish.domain.QPublish.publish; | ||
|
|
||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemSetSearchGetResponse; | ||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemThumbnailResponse; | ||
|
|
@@ -25,6 +27,7 @@ public List<ProblemSetSearchGetResponse> search(String problemSetTitle, String p | |
| .from(problemSet) | ||
| .leftJoin(problem).on(problem.id.in(problemSet.problemIds)) // 문제 세트 내 포함된 문항과 조인 | ||
| .leftJoin(conceptTag).on(conceptTag.id.in(problem.conceptTagIds)) // 문제의 개념 태그 조인 | ||
| .leftJoin(publish).on(publish.problemSetId.eq(problemSet.id)) // 문제 세트와 발행 데이터 조인 | ||
| .where( | ||
| containsProblemSetTitle(problemSetTitle), | ||
| containsProblemTitle(problemTitle), | ||
|
|
@@ -34,6 +37,35 @@ public List<ProblemSetSearchGetResponse> search(String problemSetTitle, String p | |
| .transform(GroupBy.groupBy(problemSet.id).list( | ||
| Projections.constructor(ProblemSetSearchGetResponse.class, | ||
| problemSet.title.value, | ||
| problemSet.confirmStatus, | ||
| publish.publishedDate, // 발행되지 않은 경우 null 반환 | ||
| GroupBy.list( | ||
| Projections.constructor(ProblemThumbnailResponse.class, | ||
| problem.mainProblemImageUrl | ||
| ) | ||
| ) | ||
| ) | ||
| )); | ||
| } | ||
|
|
||
| public List<ProblemSetSearchGetResponse> confirmSearch(String problemSetTitle, String problemTitle, List<String> conceptTagNames) { | ||
| return queryFactory | ||
| .from(problemSet) | ||
| .leftJoin(problem).on(problem.id.in(problemSet.problemIds)) // 문제 세트 내 포함된 문항과 조인 | ||
| .leftJoin(conceptTag).on(conceptTag.id.in(problem.conceptTagIds)) // 문제의 개념 태그 조인 | ||
| .leftJoin(publish).on(publish.problemSetId.eq(problemSet.id)) // 문제 세트와 발행 데이터 조인 | ||
| .where( | ||
| problemSet.confirmStatus.eq(CONFIRMED), | ||
| containsProblemSetTitle(problemSetTitle), | ||
| containsProblemTitle(problemTitle), | ||
| containsConceptTagNames(conceptTagNames) | ||
| ) | ||
| .distinct() | ||
| .transform(GroupBy.groupBy(problemSet.id).list( | ||
| Projections.constructor(ProblemSetSearchGetResponse.class, | ||
| problemSet.title.value, | ||
| problemSet.confirmStatus, | ||
| publish.publishedDate, // 발행되지 않은 경우 null 반환 | ||
| GroupBy.list( | ||
| Projections.constructor(ProblemThumbnailResponse.class, | ||
| problem.mainProblemImageUrl | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 문항 타이틀이랑, 문항 메모도 필요하지 않나요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다지인 변경을 반영안했네요! 바로 반영하겠습니다 |
||
|
|
||
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
54 changes: 54 additions & 0 deletions
54
src/main/java/com/moplus/moplus_server/domain/publish/controller/PublishController.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,54 @@ | ||
| package com.moplus.moplus_server.domain.publish.controller; | ||
|
|
||
| import com.moplus.moplus_server.domain.publish.dto.request.PublishPostRequest; | ||
| import com.moplus.moplus_server.domain.publish.dto.response.PublishMonthGetResponse; | ||
| import com.moplus.moplus_server.domain.publish.service.PublishDeleteService; | ||
| import com.moplus.moplus_server.domain.publish.service.PublishGetService; | ||
| import com.moplus.moplus_server.domain.publish.service.PublishSaveService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 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.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/publish") | ||
| @RequiredArgsConstructor | ||
| public class PublishController { | ||
|
|
||
| private final PublishGetService publishGetService; | ||
| private final PublishSaveService publishSaveService; | ||
| private final PublishDeleteService publishDeleteService; | ||
|
|
||
| @GetMapping("/{year}/{month}") | ||
| @Operation(summary = "연월별 발행 조회", description = "연월별로 발행된 세트들을 조회합니다.") | ||
| public ResponseEntity<List<PublishMonthGetResponse>> getPublishMonth( | ||
| @PathVariable int year, | ||
| @PathVariable int month | ||
| ) { | ||
| return ResponseEntity.ok(publishGetService.getPublishMonth(year, month)); | ||
| } | ||
|
|
||
| @PostMapping("") | ||
| @Operation(summary = "발행 생성하기", description = "특정 날짜에 문항세트를 발행합니다.") | ||
| public ResponseEntity<Long> postPublish( | ||
| @RequestBody PublishPostRequest request | ||
| ) { | ||
| return ResponseEntity.ok(publishSaveService.createPublish(request)); | ||
| } | ||
|
|
||
| @DeleteMapping("/{publishId}") | ||
| @Operation(summary = "발행 삭제", description = "발행을 삭제합니다.") | ||
| public ResponseEntity<Void> deleteProblemSet( | ||
| @PathVariable Long publishId | ||
| ) { | ||
| publishDeleteService.deletePublish(publishId); | ||
| return ResponseEntity.noContent().build(); | ||
| } | ||
| } |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/moplus/moplus_server/domain/publish/dto/request/PublishPostRequest.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,16 @@ | ||
| package com.moplus.moplus_server.domain.publish.dto.request; | ||
|
|
||
| import com.moplus.moplus_server.domain.publish.domain.Publish; | ||
| import java.time.LocalDate; | ||
|
|
||
| public record PublishPostRequest( | ||
| LocalDate publishedDate, | ||
| Long problemSetId | ||
| ) { | ||
| public Publish toEntity() { | ||
| return Publish.builder() | ||
| .publishedDate(this.publishedDate) | ||
| .problemSetId(this.problemSetId) | ||
| .build(); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
...in/java/com/moplus/moplus_server/domain/publish/dto/response/PublishMonthGetResponse.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,17 @@ | ||
| package com.moplus.moplus_server.domain.publish.dto.response; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record PublishMonthGetResponse( | ||
| int day, | ||
| PublishProblemSetResponse problemSetInfo | ||
| ) { | ||
| public static PublishMonthGetResponse of(int day, PublishProblemSetResponse problemSetInfos) { | ||
|
|
||
| return PublishMonthGetResponse.builder() | ||
| .day(day) | ||
| .problemSetInfo(problemSetInfos) | ||
| .build(); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
.../java/com/moplus/moplus_server/domain/publish/dto/response/PublishProblemSetResponse.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,18 @@ | ||
| package com.moplus.moplus_server.domain.publish.dto.response; | ||
|
|
||
| import com.moplus.moplus_server.domain.problemset.domain.ProblemSet; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record PublishProblemSetResponse( | ||
| Long id, | ||
| String title | ||
| ) { | ||
| public static PublishProblemSetResponse of(ProblemSet problemSet) { | ||
|
|
||
| return PublishProblemSetResponse.builder() | ||
| .id(problemSet.getId()) | ||
| .title(problemSet.getTitle().getValue()) | ||
| .build(); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/moplus/moplus_server/domain/publish/repository/PublishRepository.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 com.moplus.moplus_server.domain.publish.repository; | ||
|
|
||
| import com.moplus.moplus_server.domain.publish.domain.Publish; | ||
| import com.moplus.moplus_server.global.error.exception.ErrorCode; | ||
| import com.moplus.moplus_server.global.error.exception.NotFoundException; | ||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface PublishRepository extends JpaRepository<Publish, Long> { | ||
| List<Publish> findByPublishedDateBetween(LocalDate startDate, LocalDate endDate); | ||
|
|
||
| default Publish findByIdElseThrow(Long publishId) { | ||
| return findById(publishId).orElseThrow(() -> new NotFoundException(ErrorCode.PUBLISH_NOT_FOUND)); | ||
| } | ||
|
|
||
| Optional<Publish> findByProblemSetId(Long problemSetId); | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/moplus/moplus_server/domain/publish/service/PublishDeleteService.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,20 @@ | ||
| package com.moplus.moplus_server.domain.publish.service; | ||
|
|
||
| import com.moplus.moplus_server.domain.publish.domain.Publish; | ||
| import com.moplus.moplus_server.domain.publish.repository.PublishRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class PublishDeleteService { | ||
|
|
||
| private final PublishRepository publishRepository; | ||
|
|
||
| @Transactional | ||
| public void deletePublish(Long publishId) { | ||
| Publish publish = publishRepository.findByIdElseThrow(publishId); | ||
| publishRepository.delete(publish); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
발행 쪽의 문항세트 검색에는 컨펌안된 애들은 안뜨는 api가 추가로 필요할것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추가하겠습니다!