polishing
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.kamco.cd.kamcoback.common.enums;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
public class ApiConfigEnum {
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(of = "enumValue")
|
||||
public static class EnumDto<T> {
|
||||
|
||||
private final T enumValue;
|
||||
private final String id;
|
||||
private final String text;
|
||||
|
||||
public EnumDto(T enumValue, String id, String text) {
|
||||
this.enumValue = enumValue;
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kamco.cd.kamcoback.common.enums;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import java.util.Arrays;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Common usage status used across the system.
|
||||
*
|
||||
* <p>This enum represents whether a resource is active, excluded from processing, or inactive. It
|
||||
* is commonly used for filtering, business rules, and status management.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CommonUseStatus implements EnumType {
|
||||
|
||||
// @formatter:off
|
||||
USE("USE", "Active", 100)
|
||||
/** Actively used and available */
|
||||
,
|
||||
EXCEPT("EXCEPT", "Excluded", 200)
|
||||
/** Explicitly excluded from use or processing */
|
||||
,
|
||||
NOT_USE("NOT_USE", "Inactive", 999)
|
||||
/** Not used or disabled */
|
||||
;
|
||||
// @formatter:on
|
||||
|
||||
private String id;
|
||||
private String text;
|
||||
private int ordering;
|
||||
|
||||
public static CommonUseStatus getEnumById(String id) {
|
||||
return Arrays.stream(CommonUseStatus.values())
|
||||
.filter(x -> x.getId().equals(id))
|
||||
.findFirst()
|
||||
.orElse(CommonUseStatus.NOT_USE);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheet;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapInkx50kEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.scene.MapInkx50kRepository;
|
||||
@@ -10,12 +12,16 @@ import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.UseInferReq;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.locationtech.jts.geom.Polygon;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MapInkxMngCoreService {
|
||||
@@ -25,7 +31,7 @@ public class MapInkxMngCoreService {
|
||||
|
||||
// 목록
|
||||
public Page<MapInkxMngDto.MapList> findMapInkxMngList(
|
||||
MapInkxMngDto.searchReq searchReq, String useInference, String searchVal) {
|
||||
MapInkxMngDto.searchReq searchReq, CommonUseStatus useInference, String searchVal) {
|
||||
return mapInkx5kRepository.findMapInkxMngList(searchReq, useInference, searchVal);
|
||||
}
|
||||
|
||||
@@ -44,15 +50,14 @@ public class MapInkxMngCoreService {
|
||||
}
|
||||
|
||||
MapInkx5kEntity entity =
|
||||
new MapInkx5kEntity(
|
||||
req.getMapidcdNo(), req.getMapidNm(), map_polygon, mapInkx50k, "USE" // 기본은 USE로
|
||||
);
|
||||
new MapInkx5kEntity(req.getMapidcdNo(), req.getMapidNm(), map_polygon, mapInkx50k);
|
||||
|
||||
mapInkx5kRepository.save(entity);
|
||||
|
||||
return new ResponseObj(ApiResponseCode.OK, "");
|
||||
}
|
||||
|
||||
// 도엽의 사용여부를 변경한다.
|
||||
public ResponseObj updateUseInference(@Valid UseInferReq useInferReq) {
|
||||
Optional<MapInkx5kEntity> entity =
|
||||
Optional.ofNullable(
|
||||
@@ -63,4 +68,37 @@ public class MapInkxMngCoreService {
|
||||
entity.get().updateUseInference(useInferReq.getUseInference());
|
||||
return new ResponseObj(ApiResponseCode.OK, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the inference usage status of a given map sheet (도엽) based on the provided scene ID and
|
||||
* usage status. 도엽의 사용여부를 변경한다.
|
||||
*
|
||||
* @param sceneId5k the unique identifier for the map sheet whose usage status is being updated
|
||||
* @param useStatus the new usage status to be set for the specified map sheet
|
||||
* @return a ResponseObj indicating the outcome of the operation, including a response code and
|
||||
* message
|
||||
* @throws EntityNotFoundException if no map sheet is found for the provided scene ID
|
||||
*/
|
||||
@Transactional
|
||||
public MapSheet updateUseInference(
|
||||
@NotNull String sceneId5k, @NotNull CommonUseStatus useStatus) {
|
||||
|
||||
log.debug("[updateUseInference]CHANGE_SCENE STATUS start: {}", sceneId5k);
|
||||
|
||||
// 5k도엽 정보를 가져온다.
|
||||
MapInkx5kEntity getScene5k =
|
||||
mapInkx5kRepository
|
||||
.findByMapidCdNoInfo(sceneId5k)
|
||||
.orElseThrow(() -> new EntityNotFoundException("도엽정보를 찾을 수 없습니다."));
|
||||
|
||||
log.debug(
|
||||
"[updateUseInference]CHANGE_SCENE STATUS: {} |BEFORE {} |AFTER {}",
|
||||
sceneId5k,
|
||||
getScene5k.getUseInference(),
|
||||
useStatus);
|
||||
// 상태를 업데이트한다.
|
||||
getScene5k.updateUseInference(useStatus);
|
||||
|
||||
return getScene5k.toEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheet;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
@@ -46,23 +49,24 @@ public class MapInkx5kEntity extends CommonDateEntity {
|
||||
@JoinColumn(name = "fid_k50", referencedColumnName = "fid")
|
||||
private MapInkx50kEntity mapInkx50k;
|
||||
|
||||
// 사용상태 USE,
|
||||
@Column(name = "use_inference")
|
||||
private String useInference;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private CommonUseStatus useInference;
|
||||
|
||||
// Constructor
|
||||
public MapInkx5kEntity(
|
||||
String mapidcdNo,
|
||||
String mapidNm,
|
||||
Geometry geom,
|
||||
MapInkx50kEntity mapInkx50k,
|
||||
String useInference) {
|
||||
String mapidcdNo, String mapidNm, Geometry geom, MapInkx50kEntity mapInkx50k) {
|
||||
this.mapidcdNo = mapidcdNo;
|
||||
this.mapidNm = mapidNm;
|
||||
this.geom = geom;
|
||||
this.mapInkx50k = mapInkx50k;
|
||||
this.useInference = useInference;
|
||||
// 생성시 default 사용함 (사용,제외,사용안함)
|
||||
this.useInference = CommonUseStatus.USE;
|
||||
}
|
||||
|
||||
public void updateUseInference(String useInference) {
|
||||
// 변경 사용상태 (추론사용여부)
|
||||
public void updateUseInference(CommonUseStatus useInference) {
|
||||
this.useInference = useInference;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.scene;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.MapList;
|
||||
@@ -12,7 +13,7 @@ public interface MapInkx5kRepositoryCustom {
|
||||
List<MapInkx5kEntity> listGetScenes5k(List<String> codes);
|
||||
|
||||
Page<MapList> findMapInkxMngList(
|
||||
MapInkxMngDto.searchReq searchReq, String useInference, String searchVal);
|
||||
MapInkxMngDto.searchReq searchReq, CommonUseStatus useInference, String searchVal);
|
||||
|
||||
Long findByMapidCdNoExists(String mapidcdNo);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.postgres.repository.scene;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx50kEntity.mapInkx50kEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity.mapInkx5kEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QMapInkx5kEntity;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
|
||||
@@ -42,7 +43,7 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
|
||||
|
||||
@Override
|
||||
public Page<MapList> findMapInkxMngList(
|
||||
searchReq searchReq, String useInference, String searchVal) {
|
||||
searchReq searchReq, CommonUseStatus useInference, String searchVal) {
|
||||
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
List<MapInkxMngDto.MapList> foundContent =
|
||||
@@ -103,7 +104,7 @@ public class MapInkx5kRepositoryImpl extends QuerydslRepositorySupport
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
private BooleanExpression searchUseInference(String useInference) {
|
||||
private BooleanExpression searchUseInference(CommonUseStatus useInference) {
|
||||
if (Objects.isNull(useInference)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.scene;
|
||||
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ApiResponseCode;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
|
||||
import com.kamco.cd.kamcoback.scene.service.MapInkxMngService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -46,7 +49,7 @@ public class MapInkxMngApiController {
|
||||
public ApiResponseDto<Page<MapInkxMngDto.MapList>> findMapInkxMngList(
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@RequestParam(required = false) String useInference,
|
||||
@RequestParam(required = false) CommonUseStatus useInference,
|
||||
@RequestParam(required = false) String searchVal) {
|
||||
MapInkxMngDto.searchReq searchReq = new MapInkxMngDto.searchReq(page, size, "");
|
||||
return ApiResponseDto.ok(
|
||||
@@ -108,6 +111,7 @@ public class MapInkxMngApiController {
|
||||
@RequestBody
|
||||
@Valid
|
||||
MapInkxMngDto.UseInferReq useInferReq) {
|
||||
return ApiResponseDto.okObject(mapInkxMngService.updateUseInference(useInferReq));
|
||||
mapInkxMngService.updateUseInference(useInferReq);
|
||||
return ApiResponseDto.okObject(new ResponseObj(ApiResponseCode.OK, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.kamco.cd.kamcoback.scene.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -151,6 +153,18 @@ public class MapInkxMngDto {
|
||||
public static class UseInferReq {
|
||||
|
||||
private String mapidcdNo;
|
||||
private String useInference;
|
||||
private CommonUseStatus useInference; // 변경하고자하는 상태
|
||||
|
||||
public void valid() {
|
||||
if (mapidcdNo == null || mapidcdNo.isEmpty()) {
|
||||
throw new IllegalArgumentException("도엽번호는 필수 입력값입니다.");
|
||||
}
|
||||
// 공백제거
|
||||
mapidcdNo = mapidcdNo.trim();
|
||||
|
||||
if (!mapidcdNo.matches("^\\d{8}$")) {
|
||||
throw new EntityNotFoundException("도엽번호는 8자리 숫자로 구성되어야 합니다.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.scene.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheet;
|
||||
import com.kamco.cd.kamcoback.postgres.core.MapInkxMngCoreService;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto;
|
||||
import com.kamco.cd.kamcoback.scene.dto.MapInkxMngDto.MapList;
|
||||
@@ -15,6 +17,7 @@ import org.locationtech.jts.geom.LinearRing;
|
||||
import org.locationtech.jts.geom.PrecisionModel;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -23,7 +26,7 @@ public class MapInkxMngService {
|
||||
private final MapInkxMngCoreService mapInkxMngCoreService;
|
||||
|
||||
public Page<MapList> findMapInkxMngList(
|
||||
MapInkxMngDto.searchReq searchReq, String useInference, String searchVal) {
|
||||
MapInkxMngDto.searchReq searchReq, CommonUseStatus useInference, String searchVal) {
|
||||
return mapInkxMngCoreService.findMapInkxMngList(searchReq, useInference, searchVal);
|
||||
}
|
||||
|
||||
@@ -52,7 +55,10 @@ public class MapInkxMngService {
|
||||
return mapInkxMngCoreService.saveMapInkx5k(req, GEOMETRY_FACTORY.createPolygon(shell));
|
||||
}
|
||||
|
||||
public ResponseObj updateUseInference(@Valid UseInferReq useInferReq) {
|
||||
return mapInkxMngCoreService.updateUseInference(useInferReq);
|
||||
// 도엽의 상태를 업데이트한다.
|
||||
@Transactional
|
||||
public MapSheet updateUseInference(@Valid UseInferReq useInferReq) {
|
||||
return mapInkxMngCoreService.updateUseInference(
|
||||
useInferReq.getMapidcdNo(), useInferReq.getUseInference());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user