Merge remote-tracking branch 'origin/feat/dev_251201' into feat/dev_251201

# Conflicts:
#	src/main/java/com/kamco/cd/kamcoback/mapsheet/dto/FileDto.java
#	src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java
#	src/main/java/com/kamco/cd/kamcoback/postgres/entity/CommonCodeEntity.java
This commit is contained in:
2025-12-03 18:50:34 +09:00
13 changed files with 366 additions and 95 deletions

View File

@@ -10,6 +10,7 @@ import jakarta.persistence.EntityNotFoundException;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@@ -34,16 +35,21 @@ public class CommonCodeCoreService
new EntityNotFoundException(
"parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
Long existsCount = commonCodeRepository.findByParentIdCodeExists(req.getParentId(), req.getCode());
if (existsCount > 0) {
throw new DuplicateKeyException("이미 등록되어 있습니다.");
}
CommonCodeEntity entity =
new CommonCodeEntity(
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed());
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed(), req.getProps1(), req.getProps2(), req.getProps3());
entity.addParent(parentCommonCodeEntity);
return commonCodeRepository.save(entity).toDto();
}
CommonCodeEntity entity =
new CommonCodeEntity(
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed());
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed(), req.getProps1(), req.getProps2(), req.getProps3());
return commonCodeRepository.save(entity).toDto();
}
@@ -53,14 +59,25 @@ public class CommonCodeCoreService
.findByCodeId(id)
.orElseThrow(() -> new EntityNotFoundException("common code 를 찾을 수 없습니다. id : " + id));
Long parentId = found.getParent() == null ? null : found.getParent().getId();
Long existsCount = commonCodeRepository.findByParentIdCodeExiststoUpdate(id, parentId, req.getCode());
if (existsCount > 0) {
throw new DuplicateKeyException("이미 등록되어 있습니다.");
}
CommonCodeEntity entity =
new CommonCodeEntity(
id,
req.getCode(),
req.getName(),
req.getDescription(),
req.getOrder(),
req.isUsed(),
found.getDeleted());
found.getDeleted(),
req.getProps1(),
req.getProps2(),
req.getProps3()
);
return commonCodeRepository.save(entity).toDto();
}

View File

@@ -61,37 +61,60 @@ public class CommonCodeEntity extends CommonDateEntity {
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<CommonCodeEntity> children = new ArrayList<>();
@Size(max = 255)
@Column(name = "props1")
private String props1;
@Size(max = 255)
@Column(name = "props2")
private String props2;
@Size(max = 255)
@Column(name = "props3")
private String props3;
public CommonCodeEntity(
String code, String name, String description, Integer order, Boolean used) {
String code, String name, String description, Integer order, Boolean used, String props1, String props2, String props3) {
this.code = code;
this.name = name;
this.description = description;
this.order = order;
this.used = used;
this.props1 = props1;
this.props2 = props2;
this.props3 = props3;
}
public CommonCodeEntity(
Long id, String name, String description, Integer order, Boolean used, Boolean deleted) {
Long id, String code, String name, String description, Integer order, Boolean used, Boolean deleted, String props1, String props2, String props3) {
this.id = id;
this.code = code;
this.name = name;
this.description = description;
this.order = order;
this.used = used;
this.deleted = deleted;
this.props1 = props1;
this.props2 = props2;
this.props3 = props3;
}
public CommonCodeDto.Basic toDto() {
return new CommonCodeDto.Basic(
this.id,
this.code,
this.description,
this.name,
this.order,
this.used,
this.deleted,
this.children.stream().map(CommonCodeEntity::toDto).toList(),
super.getCreatedDate(),
super.getModifiedDate());
this.id,
this.code,
this.description,
this.name,
this.order,
this.used,
this.deleted,
this.children.stream().map(CommonCodeEntity::toDto).toList(),
super.getCreatedDate(),
super.getModifiedDate(),
this.props1,
this.props2,
this.props3
);
}
public void addParent(CommonCodeEntity parent) {

View File

@@ -2,7 +2,10 @@ package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
@@ -20,6 +23,11 @@ import org.hibernate.type.SqlTypes;
public class MapSheetLearnDataEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_map_sheet_learn_data_id_gen")
@SequenceGenerator(
name = "tb_map_sheet_learn_data_id_gen",
sequenceName = "tb_map_sheet_learn_data_data_uid",
allocationSize = 1)
@Column(name = "data_uid", nullable = false)
private Long id;

View File

@@ -2,7 +2,10 @@ package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
@@ -17,6 +20,13 @@ import org.locationtech.jts.geom.Geometry;
public class MapSheetLearnDataGeomEntity {
@Id
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "tb_map_sheet_learn_data_geom_id_gen")
@SequenceGenerator(
name = "tb_map_sheet_learn_data_geom_id_gen",
sequenceName = "tb_map_sheet_learn_data_geom_geom_uid",
allocationSize = 1)
@Column(name = "geo_uid", nullable = false)
private Long id;

View File

@@ -2,6 +2,8 @@ package com.kamco.cd.kamcoback.postgres.repository.code;
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Optional;
@@ -15,4 +17,8 @@ public interface CommonCodeRepositoryCustom {
void updateOrder(CommonCodeDto.OrderReq req);
Optional<String> getCode(String parentCodeCd, String childCodeCd);
Long findByParentIdCodeExists(Long parentId, @NotEmpty String code);
Long findByParentIdCodeExiststoUpdate(Long id, Long parentId, @NotEmpty String code);
}

View File

@@ -96,6 +96,31 @@ public class CommonCodeRepositoryImpl implements CommonCodeRepositoryCustom {
return Optional.ofNullable(result);
}
@Override
public Long findByParentIdCodeExists(Long parentId, String code) {
return queryFactory
.select(commonCodeEntity.code.count())
.from(commonCodeEntity)
.where(
commonCodeEntity.parent.id.eq(parentId),
commonCodeEntity.code.eq(code)
)
.fetchOne();
}
@Override
public Long findByParentIdCodeExiststoUpdate(Long id, Long parentId, String code) {
return queryFactory
.select(commonCodeEntity.code.count())
.from(commonCodeEntity)
.where(
commonCodeEntity.parent.id.eq(parentId),
commonCodeEntity.code.eq(code),
commonCodeEntity.id.ne(id)
)
.fetchOne();
}
private List<CommonCodeEntity> findAllByIds(Set<Long> ids) {
return queryFactory
.selectFrom(commonCodeEntity)