Merge remote-tracking branch 'origin/feat/dev_251201' into feat/dev_251201
This commit is contained in:
@@ -43,7 +43,7 @@ public class CommonCodeCoreService
|
|||||||
@CacheEvict(value = "commonCodes", allEntries = true)
|
@CacheEvict(value = "commonCodes", allEntries = true)
|
||||||
public ResponseObj save(CommonCodeDto.AddReq req) {
|
public ResponseObj save(CommonCodeDto.AddReq req) {
|
||||||
|
|
||||||
String regex = "^([A-Z]+|[0-9]+|[A-Z0-9]+(_[A-Z0-9]+)+)$";
|
String regex = "^[A-Z0-9]+(_[A-Z0-9]+)*$";
|
||||||
boolean isValid = req.getCode().matches(regex);
|
boolean isValid = req.getCode().matches(regex);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return new ResponseObj(ApiResponseCode.CONFLICT, "공통코드에 영문 대문자, 숫자, 언더바(_)만 입력 가능합니다.");
|
return new ResponseObj(ApiResponseCode.CONFLICT, "공통코드에 영문 대문자, 숫자, 언더바(_)만 입력 가능합니다.");
|
||||||
@@ -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, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +204,7 @@ public class CommonCodeCoreService
|
|||||||
public ResponseObj getCodeCheckDuplicate(Long parentId, String code) {
|
public ResponseObj getCodeCheckDuplicate(Long parentId, String code) {
|
||||||
Long existsCount = commonCodeRepository.findByParentIdCodeExists(parentId, code);
|
Long existsCount = commonCodeRepository.findByParentIdCodeExists(parentId, code);
|
||||||
|
|
||||||
String regex = "^([A-Z]+|[0-9]+|[A-Z0-9]+(_[A-Z0-9]+)+)$";
|
String regex = "^[A-Z0-9]+(_[A-Z0-9]+)*$";
|
||||||
boolean isValid = code.matches(regex);
|
boolean isValid = code.matches(regex);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return new ResponseObj(ApiResponseCode.CONFLICT, "공통코드에 영문 대문자, 숫자, 언더바(_)만 입력 가능합니다.");
|
return new ResponseObj(ApiResponseCode.CONFLICT, "공통코드에 영문 대문자, 숫자, 언더바(_)만 입력 가능합니다.");
|
||||||
|
|||||||
@@ -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