From 76870854e827d8b09244dc883f626881b3a1ce04 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Sun, 3 Apr 2022 19:35:33 +0900 Subject: [PATCH] =?UTF-8?q?config:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 13 --- src/main/java/com/xit/Application.java | 4 +- .../xit/biz/cmm/resolver/CmmUserMutation.java | 25 ------ .../xit/biz/cmm/resolver/CmmUserQuery.java | 29 ------- .../controller/CtgyFileMgtController.java | 1 - .../jpa/QuerydslPageAndSortRepository.java | 69 ---------------- .../jpa/QuerydslPageAndSortRepositoy1.kt | 81 ------------------- src/main/resources/graphql/cmmuser.graphqls | 50 ------------ src/main/resources/graphql/root.graphqls | 4 - 9 files changed, 2 insertions(+), 274 deletions(-) delete mode 100644 src/main/java/com/xit/biz/cmm/resolver/CmmUserMutation.java delete mode 100644 src/main/java/com/xit/biz/cmm/resolver/CmmUserQuery.java delete mode 100644 src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepository.java delete mode 100644 src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepositoy1.kt delete mode 100644 src/main/resources/graphql/cmmuser.graphqls delete mode 100644 src/main/resources/graphql/root.graphqls diff --git a/build.gradle b/build.gradle index d29ca65..30e1fd2 100644 --- a/build.gradle +++ b/build.gradle @@ -78,19 +78,6 @@ dependencies { // spring-boot 2.3 까지는 아래 lib 사용 //implementation 'org.hibernate:hibernate-validator:5.2.4.Final' - // graphql - implementation 'com.graphql-java-kickstart:graphql-spring-boot-starter:12.0.0' - implementation 'com.graphql-java-kickstart:graphql-java-tools:12.0.1' -// implementation 'com.graphql-java-kickstart:graphiql-spring-boot-starter:12.0.0' -// implementation 'io.projectreactor:reactor-core:3.4.14' // react - - //implementation 'com.graphql-java:graphql-spring-boot-starter:5.0.2' - //implementation 'com.graphql-java:graphql-java:17.3' - //implementation 'com.graphql-java:graphql-java-tools:5.2.4' - //implementation 'com.graphql-java:graphiql-spring-boot-starter:5.0.2' - // graphql-like sql usual - implementation 'io.leangen.graphql:graphql-spqr-spring-boot-starter:0.0.6' - // jta module //implementation('org.springframework.boot:spring-boot-starter-jta-atomikos') diff --git a/src/main/java/com/xit/Application.java b/src/main/java/com/xit/Application.java index 1b9b947..c09cbd9 100644 --- a/src/main/java/com/xit/Application.java +++ b/src/main/java/com/xit/Application.java @@ -53,10 +53,10 @@ public class Application { //WebApplicationInitializer { * @throws IOException */ public static void main(String[] args) throws IOException { - log.info("xitApplication Application load start..."); + log.info("========== xitApplication Application load start ... :: -Dspring.profiles.active - {} ==========", System.getProperty("spring.profiles.active")); if(Checks.isEmpty(System.getProperty("spring.profiles.active"))) { log.error("===================================================================="); - log.error(">>>>>>>>>>>>>> Undefined start option <<<<<<<<<<<<<<"); + log.error(">>>>>>>>>>>>>> Undefined start VM option <<<<<<<<<<<<<<"); log.error(">>>>>>>>>>>>>> -Dspring.profiles.active=local|dev|prd <<<<<<<<<<<<<<"); log.error("============== xitApplication Application start fail ==============="); log.error("===================================================================="); diff --git a/src/main/java/com/xit/biz/cmm/resolver/CmmUserMutation.java b/src/main/java/com/xit/biz/cmm/resolver/CmmUserMutation.java deleted file mode 100644 index 49befb5..0000000 --- a/src/main/java/com/xit/biz/cmm/resolver/CmmUserMutation.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.xit.biz.cmm.resolver; - -import com.xit.biz.cmm.dto.CmmUserDto; -import com.xit.biz.cmm.dto.struct.CmmUserMapstruct; -import com.xit.biz.cmm.entity.CmmUser; -import com.xit.biz.cmm.repository.ICmmUserRepository; -import graphql.kickstart.tools.GraphQLMutationResolver; -import lombok.RequiredArgsConstructor; -import org.mapstruct.factory.Mappers; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -@RequiredArgsConstructor -@Transactional(rollbackFor = Exception.class) -public class CmmUserMutation implements GraphQLMutationResolver { - private final ICmmUserRepository cmmUserRepository; - private final CmmUserMapstruct cmmUserMapstruct = Mappers.getMapper(CmmUserMapstruct.class); - - public CmmUser createUser(final CmmUserDto cmmUserDto){ - CmmUser cmmUser = cmmUserRepository.save(cmmUserMapstruct.toEntity(cmmUserDto)); - //return cmmUserMapstruct.toDto(cmmUser); - return cmmUser; - } -} diff --git a/src/main/java/com/xit/biz/cmm/resolver/CmmUserQuery.java b/src/main/java/com/xit/biz/cmm/resolver/CmmUserQuery.java deleted file mode 100644 index 00a49c5..0000000 --- a/src/main/java/com/xit/biz/cmm/resolver/CmmUserQuery.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.xit.biz.cmm.resolver; - -import com.xit.biz.cmm.dto.CmmUserDto; -import com.xit.biz.cmm.dto.struct.CmmUserMapstruct; -import com.xit.biz.cmm.entity.CmmUser; -import com.xit.biz.cmm.repository.ICmmUserRepository; -import graphql.kickstart.tools.GraphQLQueryResolver; -import lombok.RequiredArgsConstructor; -import org.mapstruct.factory.Mappers; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.lang.annotation.Annotation; - -@Component -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class CmmUserQuery implements GraphQLQueryResolver { - private final ICmmUserRepository cmmUserRepository; - private final CmmUserMapstruct cmmUserMapstruct = Mappers.getMapper(CmmUserMapstruct.class); - - - - public CmmUser getUserByUserId(final String userId){ - CmmUser cmmUser = cmmUserRepository.findByUserId(userId).orElse(null); - //return cmmUserMapstruct.toDto(cmmUser); - return cmmUser; - } -} diff --git a/src/main/java/com/xit/biz/ctgy/controller/CtgyFileMgtController.java b/src/main/java/com/xit/biz/ctgy/controller/CtgyFileMgtController.java index 7d37f34..cd2ab30 100644 --- a/src/main/java/com/xit/biz/ctgy/controller/CtgyFileMgtController.java +++ b/src/main/java/com/xit/biz/ctgy/controller/CtgyFileMgtController.java @@ -32,7 +32,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; -import java.util.List; @Tag(name = "CtgyFileMgtController", description = "공지사항 / 게시판 관리") @RestController diff --git a/src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepository.java b/src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepository.java deleted file mode 100644 index b7183f3..0000000 --- a/src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepository.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.xit.core.support.jpa; - -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.PathBuilder; -import com.querydsl.core.types.dsl.PathBuilderFactory; -import com.querydsl.jpa.JPQLQuery; -import java.util.List; -import javax.persistence.EntityManager; -import kotlin.Metadata; -import kotlin.collections.CollectionsKt; -import kotlin.jvm.internal.Intrinsics; -import org.jetbrains.annotations.NotNull; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.support.Querydsl; - -@Metadata( - mv = {1, 6, 0}, - k = 1, - d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0016\u0018\u00002\u00020\u0001B\u0019\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\n\u0010\u0004\u001a\u0006\u0012\u0002\b\u00030\u0005¢\u0006\u0002\u0010\u0006J(\u0010\u0007\u001a\b\u0012\u0004\u0012\u0002H\t0\b\"\u0004\b\u0000\u0010\t2\u0006\u0010\n\u001a\u00020\u000b2\f\u0010\f\u001a\b\u0012\u0004\u0012\u0002H\t0\rJ*\u0010\u000e\u001a\b\u0012\u0004\u0012\u0002H\t0\b\"\u0004\b\u0000\u0010\t2\u0006\u0010\n\u001a\u00020\u000b2\f\u0010\f\u001a\b\u0012\u0004\u0012\u0002H\t0\rH\u0002J*\u0010\u000f\u001a\b\u0012\u0004\u0012\u0002H\t0\b\"\u0004\b\u0000\u0010\t2\u0006\u0010\n\u001a\u00020\u000b2\f\u0010\f\u001a\b\u0012\u0004\u0012\u0002H\t0\rH\u0002J\b\u0010\u0010\u001a\u00020\u0011H\u0002R\u0012\u0010\u0004\u001a\u0006\u0012\u0002\b\u00030\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0012"}, - d2 = {"Lcom/xit/core/support/jpa/QuerydslPageAndSortRepository;", "", "entityManager", "Ljavax/persistence/EntityManager;", "clazz", "Ljava/lang/Class;", "(Ljavax/persistence/EntityManager;Ljava/lang/Class;)V", "getPageImpl", "Lorg/springframework/data/domain/PageImpl;", "T", "pageable", "Lorg/springframework/data/domain/Pageable;", "query", "Lcom/querydsl/jpa/JPQLQuery;", "getPageImplIfGroupBy", "getPageImplIfNotGroupBy", "getQuerydsl", "Lorg/springframework/data/jpa/repository/support/Querydsl;", "xit-opst-bo.main"} -) -public class QuerydslPageAndSortRepository { - private final EntityManager entityManager; - private final Class clazz; - - public QuerydslPageAndSortRepository(@NotNull EntityManager entityManager, @NotNull Class clazz) { - Intrinsics.checkNotNullParameter(entityManager, "entityManager"); - Intrinsics.checkNotNullParameter(clazz, "clazz"); - this.entityManager = entityManager; - this.clazz = clazz; - } - - private final Querydsl getQuerydsl() { - PathBuilder builder = (new PathBuilderFactory()).create(this.clazz); - return new Querydsl(this.entityManager, builder); - } - - @NotNull - public final PageImpl getPageImpl(@NotNull Pageable pageable, @NotNull JPQLQuery query) { - Intrinsics.checkNotNullParameter(pageable, "pageable"); - Intrinsics.checkNotNullParameter(query, "query"); - QueryMetadata var10000 = query.getMetadata(); - Intrinsics.checkNotNullExpressionValue(var10000, "query.metadata"); - return var10000.getGroupBy().size() > 0 ? this.getPageImplIfGroupBy(pageable, query) : this.getPageImplIfNotGroupBy(pageable, query); - } - - private final PageImpl getPageImplIfGroupBy(Pageable pageable, JPQLQuery query) { - List queryResult = query.fetch(); - int totalCount = queryResult.size(); - long offset = pageable.getOffset(); - if (offset > (long)totalCount) { - return new PageImpl(CollectionsKt.emptyList(), pageable, (long)totalCount); - } else { - int limit = pageable.getPageSize() * (pageable.getPageNumber() + 1); - limit = limit > totalCount ? totalCount : limit; - List results = queryResult.subList((int)offset, limit); - return new PageImpl(results, pageable, (long)totalCount); - } - } - - private final PageImpl getPageImplIfNotGroupBy(Pageable pageable, JPQLQuery query) { - long totalCount = query.fetchCount(); - List results = this.getQuerydsl().applyPagination(pageable, query).fetch(); - return new PageImpl(results, pageable, totalCount); - } - - -} diff --git a/src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepositoy1.kt b/src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepositoy1.kt deleted file mode 100644 index c2c0ab4..0000000 --- a/src/main/java/com/xit/core/support/jpa/QuerydslPageAndSortRepositoy1.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.xit.core.support.jpa; - -import com.querydsl.core.types.dsl.PathBuilderFactory -import com.querydsl.jpa.JPQLQuery -import org.springframework.data.domain.PageImpl -import org.springframework.data.domain.Pageable -import org.springframework.data.jpa.repository.support.Querydsl -import javax.persistence.EntityManager - - open class QuerydslPageAndSortRepository1 ( - private val entityManager: EntityManager, - private val clazz: Class<*> -) { - - private fun getQuerydsl(): Querydsl { - val builder = PathBuilderFactory().create(clazz) - return Querydsl(entityManager, builder) - } - - /** - * Paging 처리 결과값 조회 - * - Query Paging 결과값 - * - Pageable 객체 - * - Query total Count - * @param pageable Pageable - * @param query JPQLQuery - * @return PageImpl - */ - fun getPageImpl(pageable: Pageable, query: JPQLQuery): PageImpl { - return if (query.metadata.groupBy.size > 0) { - getPageImplIfGroupBy(pageable, query) - } else { - getPageImplIfNotGroupBy(pageable, query) - } - } - - /** - * GroupBy절을 사용하는 Query - * @param pageable Pageable - * @param query JPQLQuery - * @return PageImpl - */ - private fun getPageImplIfGroupBy(pageable: Pageable, query: JPQLQuery): PageImpl { - val queryResult = query.fetch() - val totalCount = queryResult.size - - val offset = pageable.offset - - // totalCount 보다 큰 값이 들어온 경우 - if (offset > totalCount) { - return PageImpl(listOf(), pageable, totalCount.toLong()) - } - - // limit 설정 - var limit = pageable.pageSize * (pageable.pageNumber + 1) - limit = if (limit > totalCount) { - totalCount - } else { - limit - } - - val results = queryResult.subList(offset.toInt(), limit) - return PageImpl(results, pageable, totalCount.toLong()) - } - - /** - * GroupBy절을 사용안하는 Query - * @param pageable Pageable - * @param query JPQLQuery - * @return PageImpl - */ - private fun getPageImplIfNotGroupBy(pageable: Pageable, query: JPQLQuery): PageImpl { - val totalCount = query.fetchCount() - - val results = getQuerydsl() - .applyPagination(pageable, query) - .fetch() - - return PageImpl(results, pageable, totalCount) - } -} diff --git a/src/main/resources/graphql/cmmuser.graphqls b/src/main/resources/graphql/cmmuser.graphqls deleted file mode 100644 index 9c19210..0000000 --- a/src/main/resources/graphql/cmmuser.graphqls +++ /dev/null @@ -1,50 +0,0 @@ -type CmmUser { - cmmUserId: String - userId: String! - password: String! - userName: String! - email: String! - userMbl: String - providerType: String! - profileImageUrl: String - emailVerifiedYn: String! - roleType: RoleType - #created_by: String - #modified_by: String -} - -enum RoleType { - USER, - ADMIN, - GUEST -} - -input CmmUserDto { - cmmUserId: String - userId: String! - password: String! - userName: String! - email: String! - userMbl: String - providerType: String! - profileImageUrl: String - emailVerifiedYn: String! - roleType: RoleType - #createdBy: String - #modifiedBy: String -} - -# Root query -type Query { - getUserByUserId(userId: String!): CmmUser! -} - - - -# Root Mutation -type Mutation { - createUser(cmmUserDto: CmmUserDto!): CmmUser! -} - - - diff --git a/src/main/resources/graphql/root.graphqls b/src/main/resources/graphql/root.graphqls deleted file mode 100644 index 3dd8334..0000000 --- a/src/main/resources/graphql/root.graphqls +++ /dev/null @@ -1,4 +0,0 @@ -schema { - query: Query, - mutation: Mutation -} \ No newline at end of file