Merge pull request '공통코드 저장 parent null인 경우 수정' (#36) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/36
This commit is contained in:
@@ -76,9 +76,11 @@ public class CommonCodeCoreService
|
|||||||
"parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
|
"parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
|
||||||
|
|
||||||
entity.addParent(parentCommonCodeEntity);
|
entity.addParent(parentCommonCodeEntity);
|
||||||
|
} else {
|
||||||
|
entity.addParent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
commonCodeRepository.save(entity).toDto();
|
commonCodeRepository.save(entity).toDto();
|
||||||
|
|
||||||
return new ResponseObj(ApiResponseCode.OK, "");
|
return new ResponseObj(ApiResponseCode.OK, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QCommonCodeEntity.commonCod
|
|||||||
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.QCommonCodeEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.QCommonCodeEntity;
|
||||||
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -106,10 +107,16 @@ public class CommonCodeRepositoryImpl implements CommonCodeRepositoryCustom {
|
|||||||
return queryFactory
|
return queryFactory
|
||||||
.select(commonCodeEntity.code.count())
|
.select(commonCodeEntity.code.count())
|
||||||
.from(commonCodeEntity)
|
.from(commonCodeEntity)
|
||||||
.where(commonCodeEntity.parent.id.eq(parentId), commonCodeEntity.code.eq(code))
|
.where(conditionParentId(parentId), commonCodeEntity.code.eq(code))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BooleanExpression conditionParentId(Long parentId) {
|
||||||
|
return parentId == null
|
||||||
|
? commonCodeEntity.parent.id.isNull()
|
||||||
|
: commonCodeEntity.parent.id.eq(parentId);
|
||||||
|
}
|
||||||
|
|
||||||
private List<CommonCodeEntity> findAllByIds(Set<Long> ids) {
|
private List<CommonCodeEntity> findAllByIds(Set<Long> ids) {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.selectFrom(commonCodeEntity)
|
.selectFrom(commonCodeEntity)
|
||||||
|
|||||||
Reference in New Issue
Block a user