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

View File

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

View File

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

View File

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

View File

@@ -35,21 +35,36 @@ public class CommonCodeCoreService
new EntityNotFoundException(
"parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
Long existsCount = commonCodeRepository.findByParentIdCodeExists(req.getParentId(), req.getCode());
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.getProps1(), req.getProps2(), req.getProps3());
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.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();
}
@@ -60,7 +75,8 @@ public class CommonCodeCoreService
.orElseThrow(() -> new EntityNotFoundException("common code 를 찾을 수 없습니다. id : " + id));
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) {
throw new DuplicateKeyException("이미 등록되어 있습니다.");
}
@@ -76,8 +92,7 @@ public class CommonCodeCoreService
found.getDeleted(),
req.getProps1(),
req.getProps2(),
req.getProps3()
);
req.getProps3());
return commonCodeRepository.save(entity).toDto();
}

View File

@@ -74,7 +74,14 @@ public class CommonCodeEntity extends CommonDateEntity {
private String props3;
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.name = name;
this.description = description;
@@ -86,7 +93,16 @@ public class CommonCodeEntity extends CommonDateEntity {
}
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.code = code;
this.name = name;
@@ -113,8 +129,7 @@ public class CommonCodeEntity extends CommonDateEntity {
super.getModifiedDate(),
this.props1,
this.props2,
this.props3
);
this.props3);
}
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.postgres.entity.CommonCodeEntity;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Optional;

View File

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