Merge pull request '중복파일경고메세지수정' (#80) from feat/dev_251201 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/80
This commit is contained in:
2025-12-19 14:04:33 +09:00
18 changed files with 483 additions and 219 deletions

View File

@@ -32,6 +32,8 @@ import org.geotools.gce.geotiff.GeoTiffReader;
public class FIleChecker {
static SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static boolean isValidFile(String pathStr) {
Path path = Paths.get(pathStr);
@@ -210,7 +212,7 @@ public class FIleChecker {
String line;
while ((line = reader.readLine()) != null) {
System.out.println("gdalinfo 출력: " + line);
// System.out.println("gdalinfo 출력: " + line);
if (line.contains("Driver: GTiff/GeoTIFF")) {
hasDriver = true;
break;
@@ -254,34 +256,127 @@ public class FIleChecker {
return hasDriver;
}
@Schema(name = "File Basic", description = "파일 기본 정보")
@Getter
public static class Basic {
private final String fileNm;
private final String parentFolderNm;
private final String parentPath;
private final String fullPath;
private final String extension;
private final long fileSize;
private final String lastModified;
public Basic(
String fileNm,
String parentFolderNm,
String parentPath,
String fullPath,
String extension,
long fileSize,
String lastModified) {
this.fileNm = fileNm;
this.parentFolderNm = parentFolderNm;
this.parentPath = parentPath;
this.fullPath = fullPath;
this.extension = extension;
this.fileSize = fileSize;
this.lastModified = lastModified;
public static boolean mkDir(String dirPath) {
Path uploadTargetPath = Paths.get(dirPath);
try {
Files.createDirectories(uploadTargetPath);
} catch (IOException e) {
return false;
}
return true;
}
public static List<Folder> getFolderAll(String dirPath, String sortType, int maxDepth) {
Path startPath = Paths.get(dirPath);
List<Folder> folderList = List.of();
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
folderList =
stream
.filter(Files::isDirectory)
.filter(p -> !p.toString().equals(dirPath))
.map(
path -> {
int depth = path.getNameCount();
String folderNm = path.getFileName().toString();
String parentFolderNm = path.getParent().getFileName().toString();
String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString();
boolean isValid =
!NameValidator.containsKorean(folderNm)
&& !NameValidator.containsWhitespaceRegex(folderNm);
File file = new File(fullPath);
int childCnt = getChildFolderCount(file);
String lastModified = getLastModified(file);
return new Folder(
folderNm,
parentFolderNm,
parentPath,
fullPath,
depth,
childCnt,
lastModified,
isValid);
})
.collect(Collectors.toList());
if (sortType.equals("name") || sortType.equals("name asc")) {
folderList.sort(
Comparator.comparing(
Folder::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
));
} else if (sortType.equals("name desc")) {
folderList.sort(
Comparator.comparing(
Folder::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
)
.reversed());
} else if (sortType.equals("dttm desc")) {
folderList.sort(
Comparator.comparing(
Folder::getLastModified, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
)
.reversed());
} else {
folderList.sort(
Comparator.comparing(
Folder::getLastModified, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return folderList;
}
public static List<Folder> getFolderAll(String dirPath) {
return getFolderAll(dirPath, "name", 1);
}
public static List<Folder> getFolderAll(String dirPath, String sortType) {
return getFolderAll(dirPath, sortType, 1);
}
public static int getChildFolderCount(String dirPath) {
File directory = new File(dirPath);
File[] childFolders = directory.listFiles(File::isDirectory);
int childCnt = 0;
if (childFolders != null) {
childCnt = childFolders.length;
}
return childCnt;
}
public static int getChildFolderCount(File directory) {
File[] childFolders = directory.listFiles(File::isDirectory);
int childCnt = 0;
if (childFolders != null) {
childCnt = childFolders.length;
}
return childCnt;
}
public static String getLastModified(String dirPath) {
File file = new File(dirPath);
return dttmFormat.format(new Date(file.lastModified()));
}
public static String getLastModified(File file) {
return dttmFormat.format(new Date(file.lastModified()));
}
public static List<Basic> getFilesFromAllDepth(
@@ -303,10 +398,7 @@ public class FIleChecker {
List<Basic> fileList = new ArrayList<>();
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// int fileTotCnt = 0;
// long fileTotSize = 0;
Predicate<Path> isTarget =
Predicate<Path> isTargetName =
p -> {
if (targetFileNm == null
|| targetFileNm.trim().isEmpty()
@@ -328,7 +420,7 @@ public class FIleChecker {
|| extension.equals("*")
|| targetExtensions.contains(extractExtension(p)))
.sorted(getFileComparator(sortType))
.filter(isTarget)
.filter(isTargetName)
.skip(startPos)
.limit(limit)
.map(
@@ -357,6 +449,12 @@ public class FIleChecker {
return fileList;
}
public static List<Basic> getFilesFromAllDepth(
String dir, String targetFileNm, String extension) {
return FIleChecker.getFilesFromAllDepth(dir, targetFileNm, extension, 100, "name", 0, 100);
}
public static Long getFileTotSize(List<FIleChecker.Basic> files) {
Long fileTotSize = 0L;
@@ -367,6 +465,16 @@ public class FIleChecker {
return fileTotSize;
}
public static boolean checkExtensions(String fileName, String ext) {
if (fileName == null) return false;
if (!fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase().equals(ext)) {
return false;
}
return true;
}
public static Set<String> createExtensionSet(String extensionString) {
if (extensionString == null || extensionString.isBlank()) {
return Set.of();
@@ -420,11 +528,6 @@ public class FIleChecker {
}
}
/**
* gdalinfo 실행 파일 경로를 찾습니다.
*
* @return gdalinfo 경로 (찾지 못하면 null)
*/
private static String findGdalinfoPath() {
// 일반적인 설치 경로 확인
String[] possiblePaths = {
@@ -443,12 +546,6 @@ public class FIleChecker {
return null;
}
/**
* 명령어가 사용 가능한지 확인합니다.
*
* @param command 명령어 경로
* @return 사용 가능 여부
*/
private static boolean isCommandAvailable(String command) {
try {
ProcessBuilder pb = new ProcessBuilder(command, "--version");
@@ -469,4 +566,66 @@ public class FIleChecker {
return false;
}
}
@Schema(name = "Folder", description = "폴더 정보")
@Getter
public static class Folder {
private final String folderNm;
private final String parentFolderNm;
private final String parentPath;
private final String fullPath;
private final int depth;
private final long childCnt;
private final String lastModified;
private final Boolean isValid;
public Folder(
String folderNm,
String parentFolderNm,
String parentPath,
String fullPath,
int depth,
long childCnt,
String lastModified,
Boolean isValid) {
this.folderNm = folderNm;
this.parentFolderNm = parentFolderNm;
this.parentPath = parentPath;
this.fullPath = fullPath;
this.depth = depth;
this.childCnt = childCnt;
this.lastModified = lastModified;
this.isValid = isValid;
}
}
@Schema(name = "File Basic", description = "파일 기본 정보")
@Getter
public static class Basic {
private final String fileNm;
private final String parentFolderNm;
private final String parentPath;
private final String fullPath;
private final String extension;
private final long fileSize;
private final String lastModified;
public Basic(
String fileNm,
String parentFolderNm,
String parentPath,
String fullPath,
String extension,
long fileSize,
String lastModified) {
this.fileNm = fileNm;
this.parentFolderNm = parentFolderNm;
this.parentPath = parentPath;
this.fullPath = fullPath;
this.extension = extension;
this.fileSize = fileSize;
this.lastModified = lastModified;
}
}
}

View File

@@ -19,7 +19,8 @@ public class UserUtil {
auth -> {
CustomUserDetails user = (CustomUserDetails) auth.getPrincipal();
MemberEntity m = user.getMember();
return new MembersDto.Member(m.getId(), m.getName(), m.getEmployeeNo());
return new MembersDto.Member(
m.getId(), m.getName(), m.getEmployeeNo(), m.getUserRole());
})
.orElse(null);
}
@@ -38,4 +39,9 @@ public class UserUtil {
MembersDto.Member user = getCurrentUser();
return user != null ? user.getEmployeeNo() : null;
}
public String getRole() {
MembersDto.Member user = getCurrentUser();
return user != null ? user.getRole() : null;
}
}

View File

@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
public class FileConfig {
// private String rootSyncDir = "D:\\app\\original-images\\";
// private String tmpSyncDir = rootSyncDir+"tmp\\";
// private String tmpSyncDir = rootSyncDir + "tmp\\";
private String rootSyncDir = "/app/original-images/";
private String tmpSyncDir = rootSyncDir + "tmp/";

View File

@@ -95,10 +95,10 @@ public class FileDto {
private final String dirPath;
private final int folderTotCnt;
private final int folderErrTotCnt;
private final List<FolderDto> folders;
private final List<FIleChecker.Folder> folders;
public FoldersDto(
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FIleChecker.Folder> folders) {
this.dirPath = dirPath;
this.folderTotCnt = folderTotCnt;

View File

@@ -234,6 +234,17 @@ public class MapSheetMngDto {
}
}
@Schema(name = "SyncCheckStateReqUpdateDto", description = "영상관리 오류처리 상태변경요청")
@Getter
@Setter
public static class SyncCheckStateReqUpdateDto {
private Long hstUid;
private String filePath;
private String syncCheckTfwFileName;
private String syncCheckTifFileName;
private String syncCheckState;
}
@Schema(name = "MngFIleDto", description = "관리파일정보")
@Getter
@Setter
@@ -293,26 +304,4 @@ public class MapSheetMngDto {
private Long hstUid;
private Long fileSize;
}
@Schema(name = "ReqUpdateErrorCheckStateDto", description = "영상관리 오류데이터 체크결과 수정요청")
@Getter
@Setter
public static class ReqUpdateErrorCheckStateDto {
private Long hstUid;
private String errorCheckState;
private String errorCheckTfwFileName;
private String errorCheckTifFileName;
/*
public reqErrorDataCheckStateDto(
Long hstUid,
String errorCheckState,
String errorCheckTfwFileName,
String errorCheckTifFileName) {
this.hstUid = hstUid;
this.errorCheckState = errorCheckState;
this.errorCheckTfwFileName = errorCheckTfwFileName;
this.errorCheckTifFileName = errorCheckTifFileName;
}*/
}
}

View File

@@ -5,10 +5,8 @@ import static java.lang.String.CASE_INSENSITIVE_ORDER;
import com.kamco.cd.kamcoback.common.exception.DuplicateFileException;
import com.kamco.cd.kamcoback.common.exception.ValidationException;
import com.kamco.cd.kamcoback.common.utils.FIleChecker;
import com.kamco.cd.kamcoback.common.utils.NameValidator;
import com.kamco.cd.kamcoback.config.FileConfig;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FolderDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FoldersDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDepthDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDto;
@@ -17,21 +15,17 @@ import com.kamco.cd.kamcoback.mapsheet.dto.ImageryDto;
import com.kamco.cd.kamcoback.postgres.core.MapSheetMngFileCheckerCoreService;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngFileEntity;
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngFileRepository;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
@@ -56,85 +50,16 @@ public class MapSheetMngFileCheckerService {
Path startPath = Paths.get(fileConfig.getRootSyncDir() + srchDto.getDirPath());
String dirPath = fileConfig.getRootSyncDir() + srchDto.getDirPath();
String sortType = "name desc";
// Path startPath = Paths.get(fileConfig.getRootSyncDir()+srchDto.getDirPath());
// String dirPath = fileConfig.getRootSyncDir()+srchDto.getDirPath();
List<FIleChecker.Folder> folderList = FIleChecker.getFolderAll(dirPath);
int maxDepth = 1;
int folderTotCnt = folderList.size();
int folderErrTotCnt =
(int)
folderList.stream().filter(dto -> dto.getIsValid().toString().equals("false")).count();
int folderTotCnt = 0;
int folderErrTotCnt = 0;
List<FolderDto> folderDtoList = List.of();
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
folderDtoList =
stream
// 1. 디렉토리만 필터링
.filter(Files::isDirectory)
.filter(p -> !p.toString().equals(dirPath))
.map(
path -> {
int depth = path.getNameCount();
String folderNm = path.getFileName().toString();
String parentFolderNm = path.getParent().getFileName().toString();
String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString();
boolean isValid =
!NameValidator.containsKorean(folderNm)
&& !NameValidator.containsWhitespaceRegex(folderNm);
File directory = new File(fullPath);
File[] childFolders = directory.listFiles(File::isDirectory);
long childCnt = 0;
if (childFolders != null) {
childCnt = childFolders.length;
}
FileTime time = null;
String lastModified = "";
try {
time = Files.getLastModifiedTime(path);
lastModified = dttmFormat.format(new Date(time.toMillis()));
} catch (IOException e) {
throw new RuntimeException(e);
}
return new FolderDto(
folderNm,
parentFolderNm,
parentPath,
fullPath,
depth,
childCnt,
lastModified,
isValid);
})
.collect(Collectors.toList());
folderDtoList.sort(
Comparator.comparing(
FolderDto::getFolderNm, CASE_INSENSITIVE_ORDER // 대소문자 구분 없이
)
.reversed());
folderTotCnt = folderDtoList.size();
folderErrTotCnt =
(int)
folderDtoList.stream()
.filter(dto -> dto.getIsValid().toString().equals("false"))
.count();
} catch (IOException e) {
throw new RuntimeException(e);
}
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderList);
}
public FilesDto getFilesAll(SrchFilesDto srchDto) {

View File

@@ -65,17 +65,6 @@ public class MapSheetMngService {
return mapSheetMngCoreService.mngDataSave(AddReq);
}
/*
public MapSheetMngDto.DmlReturn uploadFile(MultipartFile file, Long hstUid) {
return mapSheetMngCoreService.uploadFile(file, hstUid);
}
public MapSheetMngDto.DmlReturn deleteFile(MapSheetMngDto.DeleteFileReq req) {
return mapSheetMngCoreService.deleteFile(req);
}
*/
public DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
return mapSheetMngCoreService.uploadProcess(hstUidList);
}
@@ -85,15 +74,21 @@ public class MapSheetMngService {
}
@Transactional
public DmlReturn uploadPair(
MultipartFile tfwFile,
MultipartFile tifFile,
// String targetPath,
Long hstUid) {
public DmlReturn uploadPair(MultipartFile tfwFile, MultipartFile tifFile, Long hstUid) {
String rootPath = fileConfig.getRootSyncDir();
String tmpPath = fileConfig.getTmpSyncDir();
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
if (errDto == null) {
return new DmlReturn("fail", "NO hstUid Data");
}
// 파일검증용 임시저장 폴더 확인
if (!FIleChecker.mkDir(tmpPath)) {
return new DmlReturn("fail", "CREATE TEMP FOLDER ERROR");
}
// 파일 유효성 검증
if (tfwFile == null || tfwFile.isEmpty() || tfwFile.getSize() == 0) {
return new DmlReturn("fail", "TFW SIZE 오류");
@@ -101,35 +96,22 @@ public class MapSheetMngService {
return new DmlReturn("fail", "TIF SIZE 오류");
}
if (!tfwFile
.getOriginalFilename()
.substring(tfwFile.getOriginalFilename().lastIndexOf('.') + 1)
.toLowerCase()
.equals("tfw")) {
// 확장자명 체크
if (!FIleChecker.checkExtensions(tfwFile.getOriginalFilename(), "tfw")) {
return new DmlReturn("fail", "TFW FILENAME ERROR");
} else if (!tifFile
.getOriginalFilename()
.substring(tifFile.getOriginalFilename().lastIndexOf('.') + 1)
.toLowerCase()
.equals("tif")) {
} else if (!FIleChecker.checkExtensions(tifFile.getOriginalFilename(), "tif")) {
return new DmlReturn("fail", "TIF FILENAME ERROR");
}
ErrorDataDto errDto = mapSheetMngCoreService.findMapSheetError(hstUid);
if (errDto == null) {
return new DmlReturn("fail", "NO hstUid Data");
}
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
String targetYearDir = mngDto.getMngPath();
// 중복체크
List<FIleChecker.Basic> basicTfwList =
FIleChecker.getFilesFromAllDepth(
targetYearDir, tfwFile.getOriginalFilename(), "tfw", 100, "name", 0, 100);
FIleChecker.getFilesFromAllDepth(targetYearDir, tfwFile.getOriginalFilename(), "tfw");
List<FIleChecker.Basic> basicTifList =
FIleChecker.getFilesFromAllDepth(
targetYearDir, tifFile.getOriginalFilename(), "tif", 100, "name", 0, 100);
FIleChecker.getFilesFromAllDepth(targetYearDir, tifFile.getOriginalFilename(), "tif");
int tfwCnt =
(int)
@@ -144,11 +126,13 @@ public class MapSheetMngService {
.count();
if (tfwCnt > 0 || tifCnt > 0) {
String tfwMsg = "";
String tifMsg = "";
if (tfwCnt > 0) tfwMsg = tfwFile.getOriginalFilename();
if (tifCnt > 0) tifMsg = tifFile.getOriginalFilename();
return new DmlReturn("fail", tfwMsg + "," + tifMsg + " DUPLICATE ERROR");
String tfwtifMsg = "";
if (tfwCnt > 0) tfwtifMsg = tfwFile.getOriginalFilename();
if (tifCnt > 0) {
if (tfwCnt > 0) tfwtifMsg = "," + tifFile.getOriginalFilename();
else tfwtifMsg = tifFile.getOriginalFilename();
}
return new DmlReturn("duplicate", tfwtifMsg);
}
File directory = new File(tmpPath);
@@ -168,7 +152,7 @@ public class MapSheetMngService {
if (!FIleChecker.cmmndGdalInfo(tifTmpPath)) return new DmlReturn("fail", "TIF TYPE ERROR");
if (!FIleChecker.checkTfw(tfwTmpPath)) return new DmlReturn("fail", "TFW TYPE ERROR");
// 싱크파일목록 가저오기
// 싱크파일목록으로 업로드 경로 확인
List<MngFilesDto> mngFiles = mapSheetMngCoreService.findIdToMapSheetFileList(hstUid);
String uploadPath = "";
for (MngFilesDto dto : mngFiles) {
@@ -178,8 +162,8 @@ public class MapSheetMngService {
Path tfwTargetPath = null;
Path tifTargetPath = null;
Path uploadTargetPath = null;
// 파일이 존재하지 않을 경우(0개) 해당년도 다른 파일경로로 참조
if (uploadPath.isEmpty()) {
MngFilesDto filesDto =
mapSheetMngCoreService.findYyyyToMapSheetFilePathRefer(errDto.getMngYyyy());
@@ -189,11 +173,12 @@ public class MapSheetMngService {
tifTargetPath = Paths.get(uploadPath).resolve(tifFile.getOriginalFilename());
}
// String searchDir =
// 업로드 경로 확인(없으면 생성)
if (!FIleChecker.mkDir(uploadPath)) {
return new DmlReturn("fail", "CREATE FOLDER ERROR");
}
try {
uploadTargetPath = Paths.get(uploadPath);
Files.createDirectories(uploadTargetPath);
Files.move(tfwTmpSavePath, tfwTargetPath, StandardCopyOption.REPLACE_EXISTING);
Files.move(tifTmpSavePath, tifTargetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
@@ -201,8 +186,14 @@ public class MapSheetMngService {
}
// hst업데이트
mapSheetMngCoreService.updateMapSheetMngHstSyncCheckState(
hstUid, uploadPath, tfwFile.getOriginalFilename(), tifFile.getOriginalFilename());
MapSheetMngDto.SyncCheckStateReqUpdateDto updReqSyncCheckState =
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
updReqSyncCheckState.setHstUid(hstUid);
updReqSyncCheckState.setFilePath(uploadPath);
updReqSyncCheckState.setSyncCheckTfwFileName(tfwFile.getOriginalFilename());
updReqSyncCheckState.setSyncCheckTifFileName(tifFile.getOriginalFilename());
updReqSyncCheckState.setSyncCheckState("DONE");
mapSheetMngCoreService.updateMapSheetMngHstSyncCheckState(updReqSyncCheckState);
// 파일정보 업데이트
mapSheetMngCoreService.deleteByHstUidMngFile(hstUid);
@@ -233,8 +224,13 @@ public class MapSheetMngService {
@Transactional
public DmlReturn deleteByFileUidMngFile(List<Long> fileUids) {
long hstUid = 0;
// hstUid = 149049;
for (Long uid : fileUids) {
MapSheetMngDto.MngFilesDto dto = mapSheetMngCoreService.findIdToMapSheetFile(uid);
hstUid = dto.getHstUid();
String filePath = dto.getFilePath() + "/" + dto.getFileName();
Path path = Paths.get(filePath);
try {
@@ -250,6 +246,9 @@ public class MapSheetMngService {
DmlReturn dmlReturn = mapSheetMngCoreService.deleteByFileUidMngFile(uid);
}
// 중복제거 확인후 처리상태(DONE)변경
if (hstUid > 0) mapSheetMngCoreService.updateByHstUidSyncCheckState(hstUid);
return new DmlReturn("success", fileUids.size() + "개 파일이 삭제되었습니다.");
}
}

View File

@@ -179,5 +179,6 @@ public class MembersDto {
private Long id;
private String name;
private String employeeNo;
private String role;
}
}

View File

@@ -1,6 +1,7 @@
package com.kamco.cd.kamcoback.menu;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kamco.cd.kamcoback.common.utils.UserUtil;
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
@@ -68,4 +69,12 @@ public class MenuApiController {
return ApiResponseDto.ok(ApiLogFunction.getUriMenuInfo(result, apiUri));
}
@Operation(summary = "권한별 메뉴 조회", description = "권한별 메뉴 조")
@GetMapping("/auth")
public ApiResponseDto<String> getFindAllByRole() {
UserUtil userUtil = new UserUtil();
String role = userUtil.getRole();
return null; // ApiResponseDto.ok(menuService.getFindByRole(role));
}
}

View File

@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -61,4 +62,23 @@ public class MenuDto {
this.menuApiUrl = menuApiUrl;
}
}
@Getter
@AllArgsConstructor
public class RoleBasic {
private String menuUid;
private String parentMenuUid;
private String menuNm;
private String menuUrl;
private String description;
private Long menuOrder;
private Boolean isUse;
private Boolean deleted;
private Long createdUid;
private Long updatedUid;
private ZonedDateTime createdDttm;
private ZonedDateTime updatedDttm;
private String menuApiUrl;
}
}

View File

@@ -10,10 +10,21 @@ import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class MenuService {
private final MenuCoreService menuCoreService;
@Cacheable(value = "menuFindAll")
public List<MenuDto.Basic> getFindAll() {
return menuCoreService.getFindAll();
}
/**
* 권한별 메뉴 목록
*
* @param role
* @return
*/
// public List<MenuDto.MenuList> getFindByRole(String role) {
// return menuCoreService.getFindByRole(role);
// }
}

View File

@@ -60,10 +60,8 @@ public class MapSheetMngCoreService {
return new MapSheetMngDto.DmlReturn("success", "파일정보저장되었습니다.");
}
public void updateMapSheetMngHstSyncCheckState(
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName) {
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(
hstUid, uploadPath, syncCheckTfwFileName, syncCheckTifFileName);
public void updateMapSheetMngHstSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto) {
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(reqDto);
}
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
@@ -245,4 +243,29 @@ public class MapSheetMngCoreService {
return new MapSheetMngDto.DmlReturn("success", fileUid + " : 삭제되었습니다.");
}
public MapSheetMngDto.DmlReturn updateByHstUidSyncCheckState(Long hstUid) {
MapSheetMngDto.SyncCheckStateReqUpdateDto reqDto =
new MapSheetMngDto.SyncCheckStateReqUpdateDto();
reqDto.setHstUid(hstUid);
List<MapSheetMngDto.MngFilesDto> filesDto =
mapSheetMngRepository.findHstUidToMapSheetFileList(hstUid);
for (MapSheetMngDto.MngFilesDto dto : filesDto) {
if (dto.getFileExt().equals("tif")) reqDto.setSyncCheckTifFileName(dto.getFileName());
else if (dto.getFileExt().equals("tfw")) reqDto.setSyncCheckTfwFileName(dto.getFileName());
reqDto.setFilePath(dto.getFilePath());
}
String fileState = "DONE";
if (filesDto.size() > 2) fileState = "DONE";
reqDto.setSyncCheckState(fileState);
mapSheetMngRepository.updateMapSheetMngHstSyncCheckState(reqDto);
mapSheetMngRepository.updateByHstUidMngFileState(hstUid, fileState);
return new MapSheetMngDto.DmlReturn("success", hstUid + " : 상태변경되었습니다.");
}
}

View File

@@ -1,9 +1,12 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
import com.kamco.cd.kamcoback.menu.dto.MenuDto.RoleBasic;
import com.kamco.cd.kamcoback.postgres.entity.MenuEntity;
import com.kamco.cd.kamcoback.postgres.repository.menu.MenuRepository;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -16,4 +19,18 @@ public class MenuCoreService {
public List<MenuDto.Basic> getFindAll() {
return menuRepository.getFindAll().stream().map(MenuEntity::toDto).toList();
}
/**
* 권한별 메뉴 목록
*
* @param role
* @return
*/
public List<MenuDto.RoleBasic> getFindByRole(String role) {
Map<String, RoleBasic> map = new LinkedHashMap<>();
List<MenuDto.RoleBasic> rows = menuRepository.getFindByRole(role);
return menuRepository.getFindByRole(role);
}
}

View File

@@ -0,0 +1,47 @@
package com.kamco.cd.kamcoback.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_menu_mapp")
public class MenuMappEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_menu_mapp_id_gen")
@SequenceGenerator(
name = "tb_menu_mapp_id_gen",
sequenceName = "tb_menu_mapp_seq",
allocationSize = 1)
@Column(name = "mapp_uid", nullable = false)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "menu_uid", nullable = false)
private MenuEntity menuUid;
@NotNull
@ColumnDefault("false")
@Column(name = "deleted", nullable = false)
private Boolean deleted = false;
@Size(max = 50)
@Column(name = "role_code", length = 50)
private String roleCode;
}

View File

@@ -39,8 +39,9 @@ public interface MapSheetMngRepositoryCustom {
void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq);
void updateMapSheetMngHstSyncCheckState(
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName);
void updateMapSheetMngHstSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto updReq);
void updateByHstUidMngFileState(Long hstUid, String fileState);
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid ErrorSearchReq searchReq);

View File

@@ -547,19 +547,18 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
}
@Override
public void updateMapSheetMngHstSyncCheckState(
Long hstUid, String uploadPath, String syncCheckTfwFileName, String syncCheckTifFileName) {
public void updateMapSheetMngHstSyncCheckState(MapSheetMngDto.SyncCheckStateReqUpdateDto updReq) {
long execCount =
queryFactory
.update(mapSheetMngHstEntity)
.set(mapSheetMngHstEntity.syncCheckState, "DONE")
.set(mapSheetMngHstEntity.mapSheetPath, uploadPath)
.set(mapSheetMngHstEntity.syncCheckTfwFileName, syncCheckTfwFileName)
.set(mapSheetMngHstEntity.syncCheckTifFileName, syncCheckTifFileName)
.set(mapSheetMngHstEntity.syncCheckState, updReq.getSyncCheckState())
.set(mapSheetMngHstEntity.mapSheetPath, updReq.getFilePath())
.set(mapSheetMngHstEntity.syncCheckTfwFileName, updReq.getSyncCheckTfwFileName())
.set(mapSheetMngHstEntity.syncCheckTifFileName, updReq.getSyncCheckTifFileName())
.set(mapSheetMngHstEntity.syncCheckStrtDttm, ZonedDateTime.now())
.set(mapSheetMngHstEntity.syncCheckEndDttm, ZonedDateTime.now())
.where(mapSheetMngHstEntity.hstUid.eq(hstUid))
.where(mapSheetMngHstEntity.hstUid.eq(updReq.getHstUid()))
.execute();
}
@@ -633,6 +632,16 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.execute();
}
@Override
public void updateByHstUidMngFileState(Long hstUid, String fileState) {
long execCount =
queryFactory
.update(mapSheetMngFileEntity)
.set(mapSheetMngFileEntity.fileState, fileState)
.where(mapSheetMngFileEntity.hstUid.eq(hstUid))
.execute();
}
@Override
public void mngFileSave(@Valid MapSheetMngDto.MngFileAddReq addReq) {
long fileCount =

View File

@@ -1,9 +1,18 @@
package com.kamco.cd.kamcoback.postgres.repository.menu;
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
import com.kamco.cd.kamcoback.postgres.entity.MenuEntity;
import java.util.List;
public interface MenuRepositoryCustom {
List<MenuEntity> getFindAll();
/**
* 권한별 메뉴 목록
*
* @param role
* @return
*/
List<MenuDto.RoleBasic> getFindByRole(String role);
}

View File

@@ -1,26 +1,65 @@
package com.kamco.cd.kamcoback.postgres.repository.menu;
import static com.kamco.cd.kamcoback.postgres.entity.QMenuEntity.menuEntity;
import static com.kamco.cd.kamcoback.postgres.entity.QMenuMappEntity.menuMappEntity;
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
import com.kamco.cd.kamcoback.postgres.entity.MenuEntity;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.util.List;
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
public class MenuRepositoryImpl extends QuerydslRepositorySupport implements MenuRepositoryCustom {
@Repository
@RequiredArgsConstructor
public class MenuRepositoryImpl implements MenuRepositoryCustom {
private final JPAQueryFactory queryFactory;
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
public MenuRepositoryImpl(JPAQueryFactory queryFactory) {
super(MenuEntity.class);
this.queryFactory = queryFactory;
}
@Override
public List<MenuEntity> getFindAll() {
return queryFactory.selectFrom(menuEntity).where(menuEntity.deleted.isFalse()).fetch();
}
/**
* 권한별 메뉴 목록
*
* @return
*/
@Override
public List<MenuDto.RoleBasic> getFindByRole(String role) {
List<MenuDto.RoleBasic> content =
queryFactory
.select(
Projections.constructor(
MenuDto.RoleBasic.class,
menuEntity.menuUid,
menuEntity.parent.menuUid,
menuEntity.menuNm,
menuEntity.menuUrl,
menuEntity.description,
menuEntity.menuOrder,
menuEntity.isUse,
menuEntity.deleted,
menuEntity.createdUid,
menuEntity.updatedUid,
menuEntity.createdDate,
menuEntity.modifiedDate,
menuEntity.menuApiUri))
.from(menuMappEntity)
.join(menuMappEntity.menuUid, menuEntity)
.where(
menuMappEntity.roleCode.eq(role),
menuMappEntity.deleted.isFalse(),
menuEntity.deleted.isFalse(),
menuEntity.isUse.isTrue())
.orderBy(menuEntity.menuOrder.asc().nullsLast(), menuEntity.menuNm.asc())
.fetch();
return content;
}
}