Skip to content

Commit

Permalink
fix: QClass 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
mclub4 committed Dec 27, 2024
1 parent 881b7df commit 187990e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ProjectController(
@Argument title: String?,
@Argument bio: String?,
@Argument urls: List<String>?,
@Argument keyImageIndex: Int?,
@Argument keyImageIndex: Int,
@Argument imageUrls: List<String>?,
@Argument content: String?,
@Argument category: ProjectCategory?,
Expand Down
14 changes: 12 additions & 2 deletions pofo-api/src/main/kotlin/org/pofo/api/service/ProjectService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ class ProjectService(
val author = entityManager.getReference(User::class.java, createProjectRequest.authorId)

val imageUrls = createProjectRequest.imageUrls ?: emptyList()
val keyImageIndex = createProjectRequest.keyImageIndex ?: -1
val keyImageIndex =
when {
imageUrls.isEmpty() -> -1
createProjectRequest.keyImageIndex == null -> 0
else -> createProjectRequest.keyImageIndex
}

if (keyImageIndex >= imageUrls.size || (imageUrls.isNotEmpty() && keyImageIndex < 0)) {
throw CustomException(ErrorCode.PROJECT_IMAGE_INDEX_ERROR)
Expand Down Expand Up @@ -62,7 +67,12 @@ class ProjectService(
?: throw CustomException(ErrorCode.PROJECT_NOT_FOUND)

val imageUrls = updateProjectRequest.imageUrls ?: emptyList()
val keyImageIndex = updateProjectRequest.keyImageIndex ?: -1
val keyImageIndex =
when {
imageUrls.isEmpty() -> -1
updateProjectRequest.keyImageIndex == null -> 0
else -> updateProjectRequest.keyImageIndex
}

if (keyImageIndex >= imageUrls.size || (imageUrls.isNotEmpty() && keyImageIndex <= 0)) {
throw CustomException(ErrorCode.PROJECT_IMAGE_INDEX_ERROR)
Expand Down
4 changes: 2 additions & 2 deletions pofo-api/src/main/resources/graphql/project.graphqls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Project {
id: ID!
id: Int!
title: String!
bio: String
urls: [String],
Expand Down Expand Up @@ -36,7 +36,7 @@ type Mutation {
createProject(
title: String!,
bio: String,
keyImageIndex: Int!,
keyImageIndex: Int,
urls: [String],
imageUrls: [String],
content: String!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ internal class ProjectControllerTest
.documentName("updateProject")
.variable("projectId", savedProject.id)
.variable("title", newTitle)
.variable("keyImageIndex", 0)
.execute()
.path("updateProject.title")
.entity(String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mutation updateProject(
$title: String,
$bio: String,
$urls: [String],
$keyImageIndex: Int!,
$imageUrls: [String],
$content: String,
$category: ProjectCategory
Expand All @@ -12,6 +13,7 @@ mutation updateProject(
title: $title,
bio: $bio,
urls: $urls,
keyImageIndex: $keyImageIndex,
imageUrls: $imageUrls,
content: $content,
category: $category
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 187990e

Please sign in to comment.