config: 미사용 모듈 정리
parent
09d9e55aff
commit
76870854e8
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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<T>
|
||||
* @return PageImpl<T>
|
||||
*/
|
||||
fun <T> getPageImpl(pageable: Pageable, query: JPQLQuery<T>): PageImpl<T> {
|
||||
return if (query.metadata.groupBy.size > 0) {
|
||||
getPageImplIfGroupBy(pageable, query)
|
||||
} else {
|
||||
getPageImplIfNotGroupBy(pageable, query)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GroupBy절을 사용하는 Query
|
||||
* @param pageable Pageable
|
||||
* @param query JPQLQuery<T>
|
||||
* @return PageImpl<T>
|
||||
*/
|
||||
private fun <T> getPageImplIfGroupBy(pageable: Pageable, query: JPQLQuery<T>): PageImpl<T> {
|
||||
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<T>
|
||||
* @return PageImpl<T>
|
||||
*/
|
||||
private fun <T> getPageImplIfNotGroupBy(pageable: Pageable, query: JPQLQuery<T>): PageImpl<T> {
|
||||
val totalCount = query.fetchCount()
|
||||
|
||||
val results = getQuerydsl()
|
||||
.applyPagination(pageable, query)
|
||||
.fetch()
|
||||
|
||||
return PageImpl(results, pageable, totalCount)
|
||||
}
|
||||
}
|
@ -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!
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
schema {
|
||||
query: Query,
|
||||
mutation: Mutation
|
||||
}
|
Loading…
Reference in New Issue