jwt 미적용으로 수정, spotlessApply 적용

This commit is contained in:
2025-12-04 10:20:34 +09:00
parent 44ad02f4fe
commit 345794ce69
13 changed files with 217 additions and 180 deletions

View File

@@ -103,8 +103,7 @@ public class CommonCodeDto {
ZonedDateTime updatedDttm, ZonedDateTime updatedDttm,
String props1, String props1,
String props2, String props2,
String props3 String props3) {
) {
this.id = id; this.id = id;
this.code = code; this.code = code;
this.description = description; this.description = description;

View File

@@ -11,7 +11,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
@@ -23,24 +22,30 @@ public class SecurityConfig {
@Bean @Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.csrf(csrf -> csrf.disable()) http.csrf(csrf -> csrf.disable()) // CSRF 보안 기능 비활성화
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .sessionManagement(
.formLogin(form -> form.disable()) sm ->
.httpBasic(basic -> basic.disable()) sm.sessionCreationPolicy(
.logout(logout -> logout.disable()) SessionCreationPolicy.STATELESS)) // 서버 세션 만들지 않음 요청은 JWT 인증
// 🔥 여기서 우리가 만든 CustomAuthenticationProvider 하나만 등록 .formLogin(form -> form.disable()) // react에서 로그인 요청 관리
.authenticationProvider(customAuthenticationProvider) .httpBasic(basic -> basic.disable()) // 기본 basic 인증 비활성화 JWT 인증사용
.authorizeHttpRequests( .logout(logout -> logout.disable()) // 기본 로그아웃 비활성화 JWT는 서버 상태가 없으므로 로그아웃 처리 필요 없음
auth -> .authenticationProvider(
auth.requestMatchers( customAuthenticationProvider) // 로그인 패스워드 비교방식 스프링 기본 Provider 사용안함 커스텀 사용
"/api/auth/signin", .authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
"/api/auth/refresh", // auth.requestMatchers(
"/swagger-ui/**", // "/api/auth/signin",
"/v3/api-docs/**") // "/api/auth/refresh",
.permitAll() // "/swagger-ui/**",
.anyRequest() // "/v3/api-docs/**") // 로그인 없이 접근가능 url
.authenticated()) // .permitAll()
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); // .anyRequest()
// .authenticated())
// .addFilterBefore(
// jwtAuthenticationFilter,
// UsernamePasswordAuthenticationFilter
// .class) // 요청 들어오면 먼저 JWT 토큰 검사 후 security context 에 사용자 정보 저장.
;
return http.build(); return http.build();
} }

View File

@@ -86,8 +86,6 @@ public class MapSheetMngApiController {
return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto)); return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto));
} }
/** /**
* 오류데이터 목록 조회 * 오류데이터 목록 조회
* *

View File

@@ -24,15 +24,24 @@ public class FileDto {
@AllArgsConstructor @AllArgsConstructor
public static class SrchFilesDto { public static class SrchFilesDto {
@Schema(description = "디렉토리경로", example = "/data") @Schema(description = "디렉토리경로", example = "/data")
@NotNull private String dirPath; @NotNull
private String dirPath;
@Schema(description = "전체(*), cpg,dbf,geojson등", example = "*") @Schema(description = "전체(*), cpg,dbf,geojson등", example = "*")
@NotNull private String extension; @NotNull
private String extension;
@Schema(description = "파일명(name), 최종수정일(date)", example = "name") @Schema(description = "파일명(name), 최종수정일(date)", example = "name")
@NotNull private String sortType; @NotNull
private String sortType;
@Schema(description = "파일시작위치", example = "1") @Schema(description = "파일시작위치", example = "1")
@NotNull private Integer startPos; @NotNull
private Integer startPos;
@Schema(description = "파일종료위치", example = "100") @Schema(description = "파일종료위치", example = "100")
@NotNull private Integer endPos; @NotNull
private Integer endPos;
} }
@Schema(name = "FolderDto", description = "폴더 정보") @Schema(name = "FolderDto", description = "폴더 정보")
@@ -75,7 +84,8 @@ public class FileDto {
private final int folderErrTotCnt; private final int folderErrTotCnt;
private final List<FolderDto> folders; private final List<FolderDto> folders;
public FoldersDto(String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) { public FoldersDto(
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
this.dirPath = dirPath; this.dirPath = dirPath;
this.folderTotCnt = folderTotCnt; this.folderTotCnt = folderTotCnt;
@@ -84,8 +94,6 @@ public class FileDto {
} }
} }
@Schema(name = "File Basic", description = "파일 기본 정보") @Schema(name = "File Basic", description = "파일 기본 정보")
@Getter @Getter
public static class Basic { public static class Basic {
@@ -99,7 +107,13 @@ public class FileDto {
private final String lastModified; private final String lastModified;
public Basic( public Basic(
String fileNm, String parentFolderNm, String parentPath, String fullPath, String extension, long fileSize, String lastModified) { String fileNm,
String parentFolderNm,
String parentPath,
String fullPath,
String extension,
long fileSize,
String lastModified) {
this.fileNm = fileNm; this.fileNm = fileNm;
this.parentFolderNm = parentFolderNm; this.parentFolderNm = parentFolderNm;
this.parentPath = parentPath; this.parentPath = parentPath;

View File

@@ -40,7 +40,6 @@ public class MapSheetMngService {
private final MapSheetMngCoreService mapSheetMngCoreService; private final MapSheetMngCoreService mapSheetMngCoreService;
public FoldersDto getFolderAll(SrchFoldersDto srchDto) { public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
Path startPath = Paths.get(srchDto.getDirPath()); Path startPath = Paths.get(srchDto.getDirPath());
@@ -70,8 +69,9 @@ public class MapSheetMngService {
String parentPath = path.getParent().toString(); String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString(); String fullPath = path.toAbsolutePath().toString();
boolean isValid = !NameValidator.containsKorean(folderNm) && boolean isValid =
!NameValidator.containsWhitespaceRegex(folderNm); !NameValidator.containsKorean(folderNm)
&& !NameValidator.containsWhitespaceRegex(folderNm);
File directory = new File(fullPath); File directory = new File(fullPath);
File[] childFolders = directory.listFiles(File::isDirectory); File[] childFolders = directory.listFiles(File::isDirectory);
@@ -98,8 +98,7 @@ public class MapSheetMngService {
depth, depth,
childCnt, childCnt,
lastModified, lastModified,
isValid isValid);
);
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -110,7 +109,9 @@ public class MapSheetMngService {
.reversed()); .reversed());
folderTotCnt = folderDtoList.size(); folderTotCnt = folderDtoList.size();
folderErrTotCnt = (int)folderDtoList.stream() folderErrTotCnt =
(int)
folderDtoList.stream()
.filter(dto -> dto.getIsValid().toString().equals("false")) .filter(dto -> dto.getIsValid().toString().equals("false"))
.count(); .count();
@@ -118,7 +119,8 @@ public class MapSheetMngService {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList); // FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt,
// folderDtoList);
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList); return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
} }
@@ -167,7 +169,9 @@ public class MapSheetMngService {
long fileSize = file.length(); long fileSize = file.length();
String lastModified = dttmFormat.format(new Date(file.lastModified())); String lastModified = dttmFormat.format(new Date(file.lastModified()));
files.add(new FileDto.Basic(fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified)); files.add(
new FileDto.Basic(
fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
fileTotCnt = fileTotCnt + 1; fileTotCnt = fileTotCnt + 1;
fileTotSize = fileTotSize + fileSize; fileTotSize = fileTotSize + fileSize;
@@ -182,8 +186,6 @@ public class MapSheetMngService {
return filesDto; return filesDto;
} }
public FilesDto getFilesDepthAll(SrchFilesDto srchDto) { public FilesDto getFilesDepthAll(SrchFilesDto srchDto) {
int maxDepth = 20; int maxDepth = 20;
@@ -205,15 +207,15 @@ public class MapSheetMngService {
fileDtoList = fileDtoList =
stream stream
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
.filter(p -> extension == null || .filter(
extension.equals("") || p ->
extension.equals("*") || extension == null
targetExtensions.contains(extractExtension(p)) || extension.equals("")
) || extension.equals("*")
|| targetExtensions.contains(extractExtension(p)))
.sorted(getFileComparator(sortType)) .sorted(getFileComparator(sortType))
.map( .map(
path -> { path -> {
int depth = path.getNameCount(); int depth = path.getNameCount();
String fileNm = path.getFileName().toString(); String fileNm = path.getFileName().toString();
@@ -226,14 +228,13 @@ public class MapSheetMngService {
long fileSize = file.length(); long fileSize = file.length();
String lastModified = dttmFormat.format(new Date(file.lastModified())); String lastModified = dttmFormat.format(new Date(file.lastModified()));
return new FileDto.Basic(fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified); return new FileDto.Basic(
fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
fileTotCnt = fileDtoList.size(); fileTotCnt = fileDtoList.size();
fileTotSize = fileDtoList.stream() fileTotSize = fileDtoList.stream().mapToLong(FileDto.Basic::getFileSize).sum();
.mapToLong(FileDto.Basic::getFileSize)
.sum();
/* /*
if( sort.equals("name")) { if( sort.equals("name")) {
@@ -286,24 +287,21 @@ public class MapSheetMngService {
return filename.substring(lastDotIndex).toLowerCase(); return filename.substring(lastDotIndex).toLowerCase();
} }
public Comparator<Path> getFileComparator(String sortType) { public Comparator<Path> getFileComparator(String sortType) {
// 파일 이름 비교 기본 Comparator (대소문자 무시) // 파일 이름 비교 기본 Comparator (대소문자 무시)
Comparator<Path> nameComparator = Comparator.comparing( Comparator<Path> nameComparator =
path -> path.getFileName().toString(), Comparator.comparing(path -> path.getFileName().toString(), CASE_INSENSITIVE_ORDER);
CASE_INSENSITIVE_ORDER
);
Comparator<Path> dateComparator = Comparator.comparing( Comparator<Path> dateComparator =
Comparator.comparing(
path -> { path -> {
try { try {
return Files.getLastModifiedTime(path); return Files.getLastModifiedTime(path);
} catch (IOException e) { } catch (IOException e) {
return FileTime.fromMillis(0); return FileTime.fromMillis(0);
} }
} });
);
if ("name desc".equalsIgnoreCase(sortType)) { if ("name desc".equalsIgnoreCase(sortType)) {
return nameComparator.reversed(); return nameComparator.reversed();
@@ -316,8 +314,6 @@ public class MapSheetMngService {
} }
} }
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList( public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid searchReq searchReq) { MapSheetMngDto.@Valid searchReq searchReq) {
return mapSheetMngCoreService.findMapSheetErrorList(searchReq); return mapSheetMngCoreService.findMapSheetErrorList(searchReq);

View File

@@ -35,21 +35,36 @@ public class CommonCodeCoreService
new EntityNotFoundException( new EntityNotFoundException(
"parent id 를 찾을 수 없습니다. id : " + req.getParentId())); "parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
Long existsCount = commonCodeRepository.findByParentIdCodeExists(req.getParentId(), req.getCode()); Long existsCount =
commonCodeRepository.findByParentIdCodeExists(req.getParentId(), req.getCode());
if (existsCount > 0) { if (existsCount > 0) {
throw new DuplicateKeyException("이미 등록되어 있습니다."); throw new DuplicateKeyException("이미 등록되어 있습니다.");
} }
CommonCodeEntity entity = CommonCodeEntity entity =
new CommonCodeEntity( new CommonCodeEntity(
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed(), req.getProps1(), req.getProps2(), req.getProps3()); req.getCode(),
req.getName(),
req.getDescription(),
req.getOrder(),
req.isUsed(),
req.getProps1(),
req.getProps2(),
req.getProps3());
entity.addParent(parentCommonCodeEntity); entity.addParent(parentCommonCodeEntity);
return commonCodeRepository.save(entity).toDto(); return commonCodeRepository.save(entity).toDto();
} }
CommonCodeEntity entity = CommonCodeEntity entity =
new CommonCodeEntity( new CommonCodeEntity(
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed(), req.getProps1(), req.getProps2(), req.getProps3()); req.getCode(),
req.getName(),
req.getDescription(),
req.getOrder(),
req.isUsed(),
req.getProps1(),
req.getProps2(),
req.getProps3());
return commonCodeRepository.save(entity).toDto(); return commonCodeRepository.save(entity).toDto();
} }
@@ -60,7 +75,8 @@ public class CommonCodeCoreService
.orElseThrow(() -> new EntityNotFoundException("common code 를 찾을 수 없습니다. id : " + id)); .orElseThrow(() -> new EntityNotFoundException("common code 를 찾을 수 없습니다. id : " + id));
Long parentId = found.getParent() == null ? null : found.getParent().getId(); Long parentId = found.getParent() == null ? null : found.getParent().getId();
Long existsCount = commonCodeRepository.findByParentIdCodeExiststoUpdate(id, parentId, req.getCode()); Long existsCount =
commonCodeRepository.findByParentIdCodeExiststoUpdate(id, parentId, req.getCode());
if (existsCount > 0) { if (existsCount > 0) {
throw new DuplicateKeyException("이미 등록되어 있습니다."); throw new DuplicateKeyException("이미 등록되어 있습니다.");
} }
@@ -76,8 +92,7 @@ public class CommonCodeCoreService
found.getDeleted(), found.getDeleted(),
req.getProps1(), req.getProps1(),
req.getProps2(), req.getProps2(),
req.getProps3() req.getProps3());
);
return commonCodeRepository.save(entity).toDto(); return commonCodeRepository.save(entity).toDto();
} }

View File

@@ -74,7 +74,14 @@ public class CommonCodeEntity extends CommonDateEntity {
private String props3; private String props3;
public CommonCodeEntity( public CommonCodeEntity(
String code, String name, String description, Integer order, Boolean used, String props1, String props2, String props3) { String code,
String name,
String description,
Integer order,
Boolean used,
String props1,
String props2,
String props3) {
this.code = code; this.code = code;
this.name = name; this.name = name;
this.description = description; this.description = description;
@@ -86,7 +93,16 @@ public class CommonCodeEntity extends CommonDateEntity {
} }
public CommonCodeEntity( public CommonCodeEntity(
Long id, String code, String name, String description, Integer order, Boolean used, Boolean deleted, String props1, String props2, String props3) { Long id,
String code,
String name,
String description,
Integer order,
Boolean used,
Boolean deleted,
String props1,
String props2,
String props3) {
this.id = id; this.id = id;
this.code = code; this.code = code;
this.name = name; this.name = name;
@@ -113,8 +129,7 @@ public class CommonCodeEntity extends CommonDateEntity {
super.getModifiedDate(), super.getModifiedDate(),
this.props1, this.props1,
this.props2, this.props2,
this.props3 this.props3);
);
} }
public void addParent(CommonCodeEntity parent) { public void addParent(CommonCodeEntity parent) {

View File

@@ -3,7 +3,6 @@ package com.kamco.cd.kamcoback.postgres.repository.code;
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto; import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity; import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;

View File

@@ -101,10 +101,7 @@ public class CommonCodeRepositoryImpl implements CommonCodeRepositoryCustom {
return queryFactory return queryFactory
.select(commonCodeEntity.code.count()) .select(commonCodeEntity.code.count())
.from(commonCodeEntity) .from(commonCodeEntity)
.where( .where(commonCodeEntity.parent.id.eq(parentId), commonCodeEntity.code.eq(code))
commonCodeEntity.parent.id.eq(parentId),
commonCodeEntity.code.eq(code)
)
.fetchOne(); .fetchOne();
} }
@@ -116,8 +113,7 @@ public class CommonCodeRepositoryImpl implements CommonCodeRepositoryCustom {
.where( .where(
commonCodeEntity.parent.id.eq(parentId), commonCodeEntity.parent.id.eq(parentId),
commonCodeEntity.code.eq(code), commonCodeEntity.code.eq(code),
commonCodeEntity.id.ne(id) commonCodeEntity.id.ne(id))
)
.fetchOne(); .fetchOne();
} }