-
Notifications
You must be signed in to change notification settings - Fork 1
Book 480 feature/#145 #146
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
base: develop
Are you sure you want to change the base?
Changes from all commits
49f5d27
b3c30f2
3a85de7
3b2914b
84b94c8
4045ca8
aa4cc4a
ee429a8
1b0caa4
900feed
28c7d82
ce821c6
8af8806
ff5b0b6
0cdf8d9
31d58a3
87b8b6c
ad44b1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.yapp.apis.emotion.controller | ||
|
|
||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
| import org.yapp.apis.emotion.dto.response.EmotionListResponse | ||
| import org.yapp.apis.emotion.service.EmotionService | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v2/emotions") | ||
| class EmotionController( | ||
| private val emotionService: EmotionService | ||
| ) : EmotionControllerApi { | ||
|
|
||
| @GetMapping | ||
| override fun getEmotions(): ResponseEntity<EmotionListResponse> { | ||
| val response = emotionService.getEmotionList() | ||
| return ResponseEntity.ok(response) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.yapp.apis.emotion.controller | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation | ||
| import io.swagger.v3.oas.annotations.media.Content | ||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses | ||
| import io.swagger.v3.oas.annotations.tags.Tag | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.yapp.apis.emotion.dto.response.EmotionListResponse | ||
|
|
||
| @Tag(name = "Emotions", description = "๊ฐ์ ๊ด๋ จ API") | ||
| @RequestMapping("/api/v2/emotions") | ||
| interface EmotionControllerApi { | ||
|
|
||
| @Operation( | ||
| summary = "๊ฐ์ ๋ชฉ๋ก ์กฐํ", | ||
| description = "๋๋ถ๋ฅ ๊ฐ์ ๊ณผ ์ธ๋ถ ๊ฐ์ ๋ชฉ๋ก์ ์กฐํํฉ๋๋ค." | ||
| ) | ||
| @ApiResponses( | ||
| value = [ | ||
| ApiResponse( | ||
| responseCode = "200", | ||
| description = "๊ฐ์ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต", | ||
| content = [Content(schema = Schema(implementation = EmotionListResponse::class))] | ||
| ) | ||
| ] | ||
| ) | ||
| @GetMapping | ||
| fun getEmotions(): ResponseEntity<EmotionListResponse> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package org.yapp.apis.emotion.dto.response | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import org.yapp.domain.detailtag.DetailTag | ||
| import org.yapp.domain.readingrecord.PrimaryEmotion | ||
| import java.util.UUID | ||
|
|
||
| @Schema(name = "EmotionListResponse", description = "๊ฐ์ ๋ชฉ๋ก ์๋ต") | ||
| data class EmotionListResponse( | ||
| @field:Schema(description = "๊ฐ์ ๊ทธ๋ฃน ๋ชฉ๋ก") | ||
| val emotions: List<EmotionGroupDto> | ||
| ) { | ||
| companion object { | ||
| fun from(detailTags: List<DetailTag>): EmotionListResponse { | ||
| val grouped = detailTags.groupBy { it.primaryEmotion } | ||
|
|
||
| val emotions = PrimaryEmotion.entries.map { primary -> | ||
| EmotionGroupDto( | ||
| code = primary.name, | ||
| displayName = primary.displayName, | ||
| detailEmotions = grouped[primary] | ||
| ?.sortedBy { it.displayOrder } | ||
| ?.map { EmotionDetailDto(id = it.id.value, name = it.name) } | ||
| ?: emptyList() | ||
| ) | ||
| } | ||
|
|
||
| return EmotionListResponse(emotions = emotions) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Schema(name = "EmotionGroupDto", description = "๊ฐ์ ๊ทธ๋ฃน (๋๋ถ๋ฅ + ์ธ๋ถ๊ฐ์ )") | ||
| data class EmotionGroupDto( | ||
| @field:Schema(description = "๋๋ถ๋ฅ ์ฝ๋", example = "JOY") | ||
| val code: String, | ||
|
|
||
| @field:Schema(description = "๋๋ถ๋ฅ ํ์ ์ด๋ฆ", example = "์ฆ๊ฑฐ์") | ||
| val displayName: String, | ||
|
|
||
| @field:Schema(description = "์ธ๋ถ ๊ฐ์ ๋ชฉ๋ก") | ||
| val detailEmotions: List<EmotionDetailDto> | ||
| ) | ||
|
|
||
| @Schema(name = "EmotionDetailDto", description = "์ธ๋ถ ๊ฐ์ ") | ||
| data class EmotionDetailDto( | ||
| @field:Schema(description = "์ธ๋ถ ๊ฐ์ ID", example = "123e4567-e89b-12d3-a456-426614174000") | ||
| val id: UUID, | ||
|
|
||
| @field:Schema(description = "์ธ๋ถ ๊ฐ์ ์ด๋ฆ", example = "์ค๋ ๋") | ||
| val name: String | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package org.yapp.apis.emotion.service | ||
|
|
||
| import org.yapp.apis.emotion.dto.response.EmotionListResponse | ||
| import org.yapp.domain.detailtag.DetailTagDomainService | ||
| import org.yapp.globalutils.annotation.ApplicationService | ||
|
|
||
| @ApplicationService | ||
| class EmotionService( | ||
| private val detailTagDomainService: DetailTagDomainService | ||
| ) { | ||
| fun getEmotionList(): EmotionListResponse { | ||
| val detailTags = detailTagDomainService.findAll() | ||
| return EmotionListResponse.from(detailTags) | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| package org.yapp.apis.readingrecord.controller | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation | ||
| import io.swagger.v3.oas.annotations.Parameter | ||
| import io.swagger.v3.oas.annotations.media.Content | ||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses | ||
| import io.swagger.v3.oas.annotations.tags.Tag | ||
| import jakarta.validation.Valid | ||
| import org.springframework.data.domain.Page | ||
| import org.springframework.data.domain.Pageable | ||
| import org.springframework.data.domain.Sort | ||
| import org.springframework.data.web.PageableDefault | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal | ||
| import org.springframework.web.bind.annotation.* | ||
| import org.yapp.apis.readingrecord.dto.request.CreateReadingRecordRequestV2 | ||
| import org.yapp.apis.readingrecord.dto.request.UpdateReadingRecordRequestV2 | ||
| import org.yapp.apis.readingrecord.dto.response.ReadingRecordResponseV2 | ||
| import org.yapp.domain.readingrecord.ReadingRecordSortType | ||
| import org.yapp.globalutils.exception.ErrorResponse | ||
| import java.util.* | ||
|
|
||
| @Tag(name = "Reading Records V2", description = "๋ ์ ๊ธฐ๋ก ๊ด๋ จ API (V2)") | ||
| @RequestMapping("/api/v2/reading-records") | ||
| interface ReadingRecordControllerApiV2 { | ||
|
|
||
| @Operation( | ||
| summary = "๋ ์ ๊ธฐ๋ก ์์ฑ (V2)", | ||
| description = "์ฌ์ฉ์์ ์ฑ ์ ๋ํ ๋ ์ ๊ธฐ๋ก์ ์์ฑํฉ๋๋ค. ๋๋ถ๋ฅ ๊ฐ์ ์ ํ์, ์ธ๋ถ ๊ฐ์ ์ ์ ํ์ ๋๋ค." | ||
| ) | ||
| @ApiResponses( | ||
| value = [ | ||
| ApiResponse( | ||
| responseCode = "201", | ||
| description = "๋ ์ ๊ธฐ๋ก ์์ฑ ์ฑ๊ณต", | ||
| content = [Content(schema = Schema(implementation = ReadingRecordResponseV2::class))] | ||
| ), | ||
| ApiResponse( | ||
| responseCode = "400", | ||
| description = "์๋ชป๋ ์์ฒญ", | ||
| content = [Content(schema = Schema(implementation = ErrorResponse::class))] | ||
| ), | ||
| ApiResponse( | ||
| responseCode = "404", | ||
| description = "์ฌ์ฉ์ ๋๋ ์ฑ ์ ์ฐพ์ ์ ์์", | ||
| content = [Content(schema = Schema(implementation = ErrorResponse::class))] | ||
| ) | ||
| ] | ||
| ) | ||
| @PostMapping("/{userBookId}") | ||
| fun createReadingRecord( | ||
| @AuthenticationPrincipal @Parameter(description = "์ธ์ฆ๋ ์ฌ์ฉ์ ID") userId: UUID, | ||
| @PathVariable @Parameter(description = "๋ ์ ๊ธฐ๋ก์ ์์ฑํ ์ฌ์ฉ์ ์ฑ ID") userBookId: UUID, | ||
| @Valid @RequestBody @Parameter(description = "๋ ์ ๊ธฐ๋ก ์์ฑ ์์ฒญ ๊ฐ์ฒด") request: CreateReadingRecordRequestV2 | ||
| ): ResponseEntity<ReadingRecordResponseV2> | ||
|
|
||
| @Operation( | ||
| summary = "๋ ์ ๊ธฐ๋ก ์์ธ ์กฐํ (V2)", | ||
| description = "๋ ์ ๊ธฐ๋ก ID๋ก ๋ ์ ๊ธฐ๋ก ์์ธ ์ ๋ณด๋ฅผ ์กฐํํฉ๋๋ค." | ||
| ) | ||
| @ApiResponses( | ||
| value = [ | ||
| ApiResponse( | ||
| responseCode = "200", | ||
| description = "๋ ์ ๊ธฐ๋ก ์์ธ ์กฐํ ์ฑ๊ณต", | ||
| content = [Content(schema = Schema(implementation = ReadingRecordResponseV2::class))] | ||
| ), | ||
| ApiResponse( | ||
| responseCode = "404", | ||
| description = "์ฌ์ฉ์ ๋๋ ๋ ์ ๊ธฐ๋ก์ ์ฐพ์ ์ ์์", | ||
| content = [Content(schema = Schema(implementation = ErrorResponse::class))] | ||
| ) | ||
| ] | ||
| ) | ||
| @GetMapping("/detail/{readingRecordId}") | ||
| fun getReadingRecordDetail( | ||
| @AuthenticationPrincipal @Parameter(description = "์ธ์ฆ๋ ์ฌ์ฉ์ ID") userId: UUID, | ||
| @PathVariable @Parameter(description = "์กฐํํ ๋ ์ ๊ธฐ๋ก ID") readingRecordId: UUID | ||
| ): ResponseEntity<ReadingRecordResponseV2> | ||
|
|
||
| @Operation( | ||
| summary = "๋ ์ ๊ธฐ๋ก ๋ชฉ๋ก ์กฐํ (V2)", | ||
| description = "์ฌ์ฉ์์ ์ฑ ์ ๋ํ ๋ ์ ๊ธฐ๋ก์ ํ์ด์งํ์ฌ ์กฐํํฉ๋๋ค." | ||
| ) | ||
| @ApiResponses( | ||
| value = [ | ||
| ApiResponse( | ||
| responseCode = "200", | ||
| description = "๋ ์ ๊ธฐ๋ก ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต" | ||
| ), | ||
| ApiResponse( | ||
| responseCode = "404", | ||
| description = "์ฌ์ฉ์ ๋๋ ์ฑ ์ ์ฐพ์ ์ ์์", | ||
| content = [Content(schema = Schema(implementation = ErrorResponse::class))] | ||
| ) | ||
| ] | ||
| ) | ||
| @GetMapping("/{userBookId}") | ||
| fun getReadingRecords( | ||
| @AuthenticationPrincipal @Parameter(description = "์ธ์ฆ๋ ์ฌ์ฉ์ ID") userId: UUID, | ||
| @PathVariable @Parameter(description = "๋ ์ ๊ธฐ๋ก์ ์กฐํํ ์ฌ์ฉ์ ์ฑ ID") userBookId: UUID, | ||
| @RequestParam(required = false) @Parameter(description = "์ ๋ ฌ ํ์ ") sort: ReadingRecordSortType?, | ||
| @PageableDefault(size = 10, sort = ["createdAt"], direction = Sort.Direction.DESC) | ||
| @Parameter(description = "ํ์ด์ง ์ ๋ณด") pageable: Pageable | ||
| ): ResponseEntity<Page<ReadingRecordResponseV2>> | ||
|
Comment on lines
+104
to
+107
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. ๐งน Nitpick | ๐ต Trivial ์ ๋ ฌ ํ๋ผ๋ฏธํฐ ์ค๋ณต ๊ฐ๋ฅ์ฑ ๊ฒํ ํ์
๐ค Prompt for AI Agents |
||
|
|
||
| @Operation( | ||
| summary = "๋ ์ ๊ธฐ๋ก ์์ (V2)", | ||
| description = "๋ ์ ๊ธฐ๋ก์ ์์ ํฉ๋๋ค. ๋๋ถ๋ฅ ๊ฐ์ ๊ณผ ์ธ๋ถ ๊ฐ์ ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค." | ||
| ) | ||
| @ApiResponses( | ||
| value = [ | ||
| ApiResponse( | ||
| responseCode = "200", | ||
| description = "๋ ์ ๊ธฐ๋ก ์์ ์ฑ๊ณต", | ||
| content = [Content(schema = Schema(implementation = ReadingRecordResponseV2::class))] | ||
| ), | ||
| ApiResponse( | ||
| responseCode = "404", | ||
| description = "๋ ์ ๊ธฐ๋ก์ ์ฐพ์ ์ ์์", | ||
| content = [Content(schema = Schema(implementation = ErrorResponse::class))] | ||
| ) | ||
| ] | ||
| ) | ||
| @PutMapping("/{readingRecordId}") | ||
| fun updateReadingRecord( | ||
| @AuthenticationPrincipal @Parameter(description = "์ธ์ฆ๋ ์ฌ์ฉ์ ID") userId: UUID, | ||
| @PathVariable @Parameter(description = "์์ ํ ๋ ์ ๊ธฐ๋ก ID") readingRecordId: UUID, | ||
| @Valid @RequestBody @Parameter(description = "๋ ์ ๊ธฐ๋ก ์์ ์์ฒญ ๊ฐ์ฒด") request: UpdateReadingRecordRequestV2 | ||
| ): ResponseEntity<ReadingRecordResponseV2> | ||
|
|
||
| @Operation( | ||
| summary = "๋ ์ ๊ธฐ๋ก ์ญ์ ", | ||
| description = "๋ ์ ๊ธฐ๋ก์ ์ญ์ ํฉ๋๋ค." | ||
| ) | ||
| @ApiResponses( | ||
| value = [ | ||
| ApiResponse(responseCode = "204", description = "๋ ์ ๊ธฐ๋ก ์ญ์ ์ฑ๊ณต"), | ||
| ApiResponse( | ||
| responseCode = "404", | ||
| description = "๋ ์ ๊ธฐ๋ก์ ์ฐพ์ ์ ์์", | ||
| content = [Content(schema = Schema(implementation = ErrorResponse::class))] | ||
| ) | ||
| ] | ||
| ) | ||
| @DeleteMapping("/{readingRecordId}") | ||
| fun deleteReadingRecord( | ||
| @AuthenticationPrincipal @Parameter(description = "์ธ์ฆ๋ ์ฌ์ฉ์ ID") userId: UUID, | ||
| @PathVariable @Parameter(description = "์ญ์ ํ ๋ ์ ๊ธฐ๋ก ID") readingRecordId: UUID | ||
| ): ResponseEntity<Void> | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package org.yapp.apis.readingrecord.controller | ||
|
|
||
| import jakarta.validation.Valid | ||
| import org.springframework.data.domain.Page | ||
| import org.springframework.data.domain.Pageable | ||
| import org.springframework.data.domain.Sort | ||
| import org.springframework.data.web.PageableDefault | ||
| import org.springframework.http.HttpStatus | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal | ||
| import org.springframework.web.bind.annotation.* | ||
| import org.yapp.apis.readingrecord.dto.request.CreateReadingRecordRequestV2 | ||
| import org.yapp.apis.readingrecord.dto.request.UpdateReadingRecordRequestV2 | ||
| import org.yapp.apis.readingrecord.dto.response.ReadingRecordResponseV2 | ||
| import org.yapp.apis.readingrecord.usecase.ReadingRecordUseCaseV2 | ||
| import org.yapp.domain.readingrecord.ReadingRecordSortType | ||
| import java.util.UUID | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v2/reading-records") | ||
| class ReadingRecordControllerV2( | ||
| private val readingRecordUseCaseV2: ReadingRecordUseCaseV2 | ||
| ) : ReadingRecordControllerApiV2 { | ||
|
|
||
| @PostMapping("/{userBookId}") | ||
| override fun createReadingRecord( | ||
| @AuthenticationPrincipal userId: UUID, | ||
| @PathVariable userBookId: UUID, | ||
| @Valid @RequestBody request: CreateReadingRecordRequestV2 | ||
| ): ResponseEntity<ReadingRecordResponseV2> { | ||
| val response = readingRecordUseCaseV2.createReadingRecord( | ||
| userId = userId, | ||
| userBookId = userBookId, | ||
| request = request | ||
| ) | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(response) | ||
| } | ||
|
|
||
| @GetMapping("/detail/{readingRecordId}") | ||
| override fun getReadingRecordDetail( | ||
| @AuthenticationPrincipal userId: UUID, | ||
| @PathVariable readingRecordId: UUID | ||
| ): ResponseEntity<ReadingRecordResponseV2> { | ||
| val response = readingRecordUseCaseV2.getReadingRecordDetail( | ||
| userId = userId, | ||
| readingRecordId = readingRecordId | ||
| ) | ||
| return ResponseEntity.ok(response) | ||
| } | ||
|
|
||
| @GetMapping("/{userBookId}") | ||
| override fun getReadingRecords( | ||
| @AuthenticationPrincipal userId: UUID, | ||
| @PathVariable userBookId: UUID, | ||
| @RequestParam(required = false) sort: ReadingRecordSortType?, | ||
| @PageableDefault(size = 10, sort = ["createdAt"], direction = Sort.Direction.DESC) | ||
| pageable: Pageable | ||
| ): ResponseEntity<Page<ReadingRecordResponseV2>> { | ||
| val response = readingRecordUseCaseV2.getReadingRecordsByUserBookId( | ||
| userId = userId, | ||
| userBookId = userBookId, | ||
| sort = sort, | ||
| pageable = pageable | ||
| ) | ||
| return ResponseEntity.ok(response) | ||
| } | ||
|
|
||
| @PutMapping("/{readingRecordId}") | ||
| override fun updateReadingRecord( | ||
| @AuthenticationPrincipal userId: UUID, | ||
| @PathVariable readingRecordId: UUID, | ||
| @Valid @RequestBody request: UpdateReadingRecordRequestV2 | ||
| ): ResponseEntity<ReadingRecordResponseV2> { | ||
| val response = readingRecordUseCaseV2.updateReadingRecord( | ||
| userId = userId, | ||
| readingRecordId = readingRecordId, | ||
| request = request | ||
| ) | ||
| return ResponseEntity.ok(response) | ||
| } | ||
|
|
||
| @DeleteMapping("/{readingRecordId}") | ||
| override fun deleteReadingRecord( | ||
| @AuthenticationPrincipal userId: UUID, | ||
| @PathVariable readingRecordId: UUID | ||
| ): ResponseEntity<Void> { | ||
| readingRecordUseCaseV2.deleteReadingRecord(userId, readingRecordId) | ||
| return ResponseEntity.noContent().build() | ||
| } | ||
| } |
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.
private construct ์๋ถ์ด์๋ dtoํด๋์ค๋ค์ด ๋ช๋ช๊ฐ ๋ณด์ฌ์ ํ์ธ ๋ถํ๋๋ฆด๊ฒ์ !!