From 187990e3fedc3c2f01309672d9eefcc15793f795 Mon Sep 17 00:00:00 2001 From: mclub4 Date: Fri, 27 Dec 2024 17:42:00 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20QClass=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pofo/api/controller/ProjectController.kt | 2 +- .../org/pofo/api/service/ProjectService.kt | 14 +++- .../main/resources/graphql/project.graphqls | 4 +- .../api/controller/ProjectControllerTest.kt | 1 + .../graphql-test/updateProject.graphql | 2 + .../domain/rds/domain/project/QProject.java | 71 ------------------- .../pofo/domain/rds/domain/user/QUser.java | 43 ----------- .../rds/domain/user/QUserSocialAccount.java | 55 -------------- 8 files changed, 18 insertions(+), 174 deletions(-) delete mode 100644 pofo-domain/src/main/generated/org/pofo/domain/rds/domain/project/QProject.java delete mode 100644 pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUser.java delete mode 100644 pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUserSocialAccount.java diff --git a/pofo-api/src/main/kotlin/org/pofo/api/controller/ProjectController.kt b/pofo-api/src/main/kotlin/org/pofo/api/controller/ProjectController.kt index e6564f3..77b39b7 100644 --- a/pofo-api/src/main/kotlin/org/pofo/api/controller/ProjectController.kt +++ b/pofo-api/src/main/kotlin/org/pofo/api/controller/ProjectController.kt @@ -63,7 +63,7 @@ class ProjectController( @Argument title: String?, @Argument bio: String?, @Argument urls: List?, - @Argument keyImageIndex: Int?, + @Argument keyImageIndex: Int, @Argument imageUrls: List?, @Argument content: String?, @Argument category: ProjectCategory?, diff --git a/pofo-api/src/main/kotlin/org/pofo/api/service/ProjectService.kt b/pofo-api/src/main/kotlin/org/pofo/api/service/ProjectService.kt index ff1af1d..0388e2d 100644 --- a/pofo-api/src/main/kotlin/org/pofo/api/service/ProjectService.kt +++ b/pofo-api/src/main/kotlin/org/pofo/api/service/ProjectService.kt @@ -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) @@ -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) diff --git a/pofo-api/src/main/resources/graphql/project.graphqls b/pofo-api/src/main/resources/graphql/project.graphqls index 7b3f619..d48c211 100644 --- a/pofo-api/src/main/resources/graphql/project.graphqls +++ b/pofo-api/src/main/resources/graphql/project.graphqls @@ -1,5 +1,5 @@ type Project { - id: ID! + id: Int! title: String! bio: String urls: [String], @@ -36,7 +36,7 @@ type Mutation { createProject( title: String!, bio: String, - keyImageIndex: Int!, + keyImageIndex: Int, urls: [String], imageUrls: [String], content: String!, diff --git a/pofo-api/src/test/kotlin/org/pofo/api/controller/ProjectControllerTest.kt b/pofo-api/src/test/kotlin/org/pofo/api/controller/ProjectControllerTest.kt index 427e6cc..42eaa0a 100644 --- a/pofo-api/src/test/kotlin/org/pofo/api/controller/ProjectControllerTest.kt +++ b/pofo-api/src/test/kotlin/org/pofo/api/controller/ProjectControllerTest.kt @@ -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) diff --git a/pofo-api/src/test/resources/graphql-test/updateProject.graphql b/pofo-api/src/test/resources/graphql-test/updateProject.graphql index 9783cea..31349e4 100644 --- a/pofo-api/src/test/resources/graphql-test/updateProject.graphql +++ b/pofo-api/src/test/resources/graphql-test/updateProject.graphql @@ -3,6 +3,7 @@ mutation updateProject( $title: String, $bio: String, $urls: [String], + $keyImageIndex: Int!, $imageUrls: [String], $content: String, $category: ProjectCategory @@ -12,6 +13,7 @@ mutation updateProject( title: $title, bio: $bio, urls: $urls, + keyImageIndex: $keyImageIndex, imageUrls: $imageUrls, content: $content, category: $category diff --git a/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/project/QProject.java b/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/project/QProject.java deleted file mode 100644 index 53077a2..0000000 --- a/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/project/QProject.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.pofo.domain.rds.domain.project; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QProject is a Querydsl query type for Project - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QProject extends EntityPathBase { - - private static final long serialVersionUID = 1416526933L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QProject project = new QProject("project"); - - public final org.pofo.domain.rds.domain.user.QUser author; - - public final StringPath Bio = createString("Bio"); - - public final EnumPath category = createEnum("category", ProjectCategory.class); - - public final StringPath content = createString("content"); - - public final NumberPath id = createNumber("id", Long.class); - - public final ListPath imageUrls = this.createList("imageUrls", String.class, StringPath.class, PathInits.DIRECT2); - - public final BooleanPath isApproved = createBoolean("isApproved"); - - public final NumberPath keyImageIndex = createNumber("keyImageIndex", Integer.class); - - public final NumberPath likes = createNumber("likes", Long.class); - - public final ListPath> stacks = this.>createList("stacks", ProjectStack.class, EnumPath.class, PathInits.DIRECT2); - - public final StringPath title = createString("title"); - - public final ListPath urls = this.createList("urls", String.class, StringPath.class, PathInits.DIRECT2); - - public QProject(String variable) { - this(Project.class, forVariable(variable), INITS); - } - - public QProject(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QProject(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QProject(PathMetadata metadata, PathInits inits) { - this(Project.class, metadata, inits); - } - - public QProject(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.author = inits.isInitialized("author") ? new org.pofo.domain.rds.domain.user.QUser(forProperty("author")) : null; - } - -} - diff --git a/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUser.java b/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUser.java deleted file mode 100644 index 5938647..0000000 --- a/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUser.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.pofo.domain.rds.domain.user; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; - - -/** - * QUser is a Querydsl query type for User - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QUser extends EntityPathBase { - - private static final long serialVersionUID = -141741025L; - - public static final QUser user = new QUser("user"); - - public final StringPath email = createString("email"); - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath password = createString("password"); - - public final EnumPath role = createEnum("role", UserRole.class); - - public QUser(String variable) { - super(User.class, forVariable(variable)); - } - - public QUser(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QUser(PathMetadata metadata) { - super(User.class, metadata); - } - -} - diff --git a/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUserSocialAccount.java b/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUserSocialAccount.java deleted file mode 100644 index 207f128..0000000 --- a/pofo-domain/src/main/generated/org/pofo/domain/rds/domain/user/QUserSocialAccount.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.pofo.domain.rds.domain.user; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QUserSocialAccount is a Querydsl query type for UserSocialAccount - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QUserSocialAccount extends EntityPathBase { - - private static final long serialVersionUID = 1802382369L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QUserSocialAccount userSocialAccount = new QUserSocialAccount("userSocialAccount"); - - public final StringPath accessToken = createString("accessToken"); - - public final StringPath socialAccountId = createString("socialAccountId"); - - public final EnumPath socialType = createEnum("socialType", UserSocialType.class); - - public final QUser user; - - public QUserSocialAccount(String variable) { - this(UserSocialAccount.class, forVariable(variable), INITS); - } - - public QUserSocialAccount(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QUserSocialAccount(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QUserSocialAccount(PathMetadata metadata, PathInits inits) { - this(UserSocialAccount.class, metadata, inits); - } - - public QUserSocialAccount(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.user = inits.isInitialized("user") ? new QUser(forProperty("user")) : null; - } - -} -