-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor : 버전 별 파일 분리 * feat : 포킷 생성/수정 api Ver2 * feat : Category 공개여부, 포킷 키워드 필드 추가 * feat : 필드 추가에 따른 기존 로직 수정
- Loading branch information
1 parent
6b0b1da
commit 317a3e4
Showing
18 changed files
with
136 additions
and
25 deletions.
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
.../com/pokit/category/CategoryController.kt → ...m/pokit/category/v1/CategoryController.kt
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
6 changes: 3 additions & 3 deletions
6
...pokit/category/CategoryShareController.kt → ...it/category/v1/CategoryShareController.kt
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
...gory/dto/request/CreateCategoryRequest.kt → ...y/v1/dto/request/CreateCategoryRequest.kt
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
...y/dto/request/DuplicateCategoryRequest.kt → ...1/dto/request/DuplicateCategoryRequest.kt
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
...gory/dto/request/UpdateCategoryRequest.kt → ...y/v1/dto/request/UpdateCategoryRequest.kt
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
...category/dto/response/CategoryResponse.kt → ...egory/v1/dto/response/CategoryResponse.kt
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
...ry/dto/response/SharedContentsResponse.kt → ...v1/dto/response/SharedContentsResponse.kt
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
50 changes: 50 additions & 0 deletions
50
adapters/in-web/src/main/kotlin/com/pokit/category/v2/CategoryControllerV2.kt
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,50 @@ | ||
package com.pokit.category.v2 | ||
|
||
import com.pokit.auth.config.ErrorOperation | ||
import com.pokit.auth.model.PrincipalUser | ||
import com.pokit.category.exception.CategoryErrorCode | ||
import com.pokit.category.port.`in`.CategoryUseCase | ||
import com.pokit.category.v1.dto.response.CategoryResponse | ||
import com.pokit.category.v1.dto.response.toResponse | ||
import com.pokit.category.v2.dto.request.CreateCategoryRequestV2 | ||
import com.pokit.category.v2.dto.request.toDto | ||
import com.pokit.common.wrapper.ResponseWrapper.wrapOk | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import jakarta.validation.Valid | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@Tag(name = "Category API Ver2") | ||
@RestController | ||
@RequestMapping("/api/v2/category") | ||
class CategoryControllerV2( | ||
private val categoryUseCase: CategoryUseCase | ||
) { | ||
@Operation(summary = "포킷 생성 API Ver2") | ||
@ErrorOperation(CategoryErrorCode::class) | ||
@PostMapping | ||
fun createCategory( | ||
@AuthenticationPrincipal user: PrincipalUser, | ||
@Valid @RequestBody request: CreateCategoryRequestV2 | ||
): ResponseEntity<CategoryResponse> { | ||
return categoryUseCase.create(request.toDto(), user.id) | ||
.toResponse() | ||
.wrapOk() | ||
} | ||
|
||
@Operation(summary = "포킷 추가 API Ver2") | ||
@ErrorOperation(CategoryErrorCode::class) | ||
@PatchMapping("/{categoryId}") | ||
fun updateCategory( | ||
@AuthenticationPrincipal user: PrincipalUser, | ||
@Valid @RequestBody request: CreateCategoryRequestV2, | ||
@PathVariable categoryId: Long, | ||
): ResponseEntity<CategoryResponse> { | ||
return categoryUseCase.update(request.toDto(), user.id, categoryId) | ||
.toResponse() | ||
.wrapOk() | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
adapters/in-web/src/main/kotlin/com/pokit/category/v2/dto/request/CreateCategoryRequestV2.kt
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,23 @@ | ||
package com.pokit.category.v2.dto.request | ||
|
||
import com.pokit.category.dto.CategoryCommand | ||
import com.pokit.category.model.OpenType | ||
import com.pokit.user.model.InterestType | ||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.Size | ||
|
||
data class CreateCategoryRequestV2( | ||
@field:NotBlank(message = "포킷 명은 필수 값입니다.") | ||
@field:Size(min = 1, max = 10, message = "최대 10자까지 입력 가능합니다.") | ||
val categoryName: String, | ||
val categoryImageId: Int, | ||
val openType: String, | ||
val keywordType: String, | ||
) | ||
|
||
internal fun CreateCategoryRequestV2.toDto() = CategoryCommand( | ||
categoryName = this.categoryName, | ||
categoryImageId = this.categoryImageId, | ||
openType = OpenType.of(this.openType), | ||
keywordType = InterestType.of(this.keywordType) | ||
) |
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
7 changes: 6 additions & 1 deletion
7
domain/src/main/kotlin/com/pokit/category/dto/CategoryCommand.kt
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
package com.pokit.category.dto | ||
|
||
data class CategoryCommand ( | ||
import com.pokit.category.model.OpenType | ||
import com.pokit.user.model.InterestType | ||
|
||
data class CategoryCommand( | ||
val categoryName: String, | ||
val categoryImageId: Int, | ||
val openType: OpenType = OpenType.PRIVATE, | ||
val keywordType: InterestType = InterestType.DEFAULT, | ||
) |
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
14 changes: 13 additions & 1 deletion
14
domain/src/main/kotlin/com/pokit/category/model/OpenType.kt
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 |
---|---|---|
@@ -1,6 +1,18 @@ | ||
package com.pokit.category.model | ||
|
||
import com.pokit.category.exception.CategoryErrorCode | ||
import com.pokit.common.exception.ClientValidationException | ||
|
||
enum class OpenType { | ||
PUBLIC, | ||
PRIVATE, | ||
PRIVATE | ||
; | ||
|
||
companion object { | ||
fun of(input: String): OpenType { | ||
return OpenType.entries | ||
.firstOrNull { it.toString() == input } | ||
?: throw ClientValidationException(CategoryErrorCode.INVALID_OPENTYPE) | ||
} | ||
} | ||
} |
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