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()));
|
||||
|
||||
entity.addParent(parentCommonCodeEntity);
|
||||
} else {
|
||||
entity.addParent(null);
|
||||
}
|
||||
|
||||
commonCodeRepository.save(entity).toDto();
|
||||
|
||||
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.QCommonCodeEntity;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -106,10 +107,16 @@ public class CommonCodeRepositoryImpl implements CommonCodeRepositoryCustom {
|
||||
return queryFactory
|
||||
.select(commonCodeEntity.code.count())
|
||||
.from(commonCodeEntity)
|
||||
.where(commonCodeEntity.parent.id.eq(parentId), commonCodeEntity.code.eq(code))
|
||||
.where(conditionParentId(parentId), commonCodeEntity.code.eq(code))
|
||||
.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) {
|
||||
return queryFactory
|
||||
.selectFrom(commonCodeEntity)
|
||||
|
||||
Reference in New Issue
Block a user