Merge pull request 'feat/infer_dev_260107' (#312) from feat/infer_dev_260107 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/312
This commit is contained in:
2026-01-22 20:18:54 +09:00
8 changed files with 40 additions and 21 deletions

View File

@@ -21,11 +21,10 @@ import org.springframework.web.context.request.ServletRequestAttributes;
@RequiredArgsConstructor
public class CustomAuthenticationProvider implements AuthenticationProvider {
private final MembersRepository membersRepository;
ServletRequestAttributes attr =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
private final MembersRepository membersRepository;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
@@ -61,7 +60,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
// front에서 전달한 사용자 ip 등록
HttpServletRequest req = (attr != null) ? attr.getRequest() : null;
String ip = (req != null) ? HeaderUtil.get(req, "kamco-userIp") : null;
String ip = (req != null) ? HeaderUtil.get(req, "kamco-user-ip") : null;
UsernamePasswordAuthenticationToken token =
new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());

View File

@@ -378,7 +378,7 @@ public class GlobalExceptionHandler {
HttpStatus.valueOf(codeName),
errorLog.getId());
return ResponseEntity.status(HttpStatus.UNAUTHORIZED) // 🔥 여기서 401 지정
return ResponseEntity.status(HttpStatus.UNAUTHORIZED) // 여기서 401 지정
.body(body);
}

View File

@@ -35,6 +35,14 @@ public class ApiLogFunction {
return ip;
}
public static String getXFowardedForIp(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if (ip != null) {
ip = ip.split(",")[0].trim();
}
return ip;
}
// 사용자 ID 추출 예시 (Spring Security 기준)
public static String getUserId(HttpServletRequest request) {
try {
@@ -53,15 +61,15 @@ public class ApiLogFunction {
return EventType.DOWNLOAD;
}
if (uri.contains("/print")) {
return EventType.PRINT;
return EventType.OTHER;
}
// 일반 CRUD
return switch (method) {
case "POST" -> EventType.CREATE;
case "GET" -> EventType.READ;
case "DELETE" -> EventType.DELETE;
case "PUT", "PATCH" -> EventType.UPDATE;
case "POST" -> EventType.ADDED;
case "GET" -> EventType.LIST;
case "DELETE" -> EventType.REMOVE;
case "PUT", "PATCH" -> EventType.MODIFIED;
default -> EventType.OTHER;
};
}

View File

@@ -66,7 +66,7 @@ public class ApiResponseAdvice implements ResponseBodyAdvice<Object> {
if (body instanceof ApiResponseDto<?> apiResponse) {
response.setStatusCode(apiResponse.getHttpStatus());
String ip = ApiLogFunction.getClientIp(servletRequest);
String ip = ApiLogFunction.getXFowardedForIp(servletRequest);
Long userid = null;
if (servletRequest.getUserPrincipal() instanceof UsernamePasswordAuthenticationToken auth

View File

@@ -7,16 +7,27 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum EventType implements EnumType {
CREATE("생성"),
READ("조회"),
UPDATE("수정"),
DELETE("삭제"),
LIST("목록"),
DETAIL("상세"),
POPUP("팝업"),
STATUS("상태"),
ADDED("추가"),
MODIFIED("수정"),
REMOVE("삭제"),
DOWNLOAD("다운로드"),
PRINT("출력"),
LOGIN("로그인"),
OTHER("기타");
private final String desc;
public static EventType fromName(String name) {
try {
return EventType.valueOf(name.toUpperCase());
} catch (Exception e) {
return OTHER;
}
}
@Override
public String getId() {
return name();

View File

@@ -1152,7 +1152,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// 날짜별 전체 건수
Expression<Long> dailyTotalCnt = Expressions.numberTemplate(Long.class, "COUNT(*)");
// 전체 기간 총 건수 (윈도우 함수)
// 전체 기간 총 건수 (윈도우 함수)
Expression<Long> totalCnt = Expressions.numberTemplate(Long.class, "SUM(COUNT(*)) OVER ()");
// 상태별 카운트 (Postgres FILTER 사용)
@@ -1192,7 +1192,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
LabelingStatDto.class,
workDate,
dailyTotalCnt,
totalCnt, // 전체 일자 배정 건수
totalCnt, // 전체 일자 배정 건수
assignedCnt,
skipCnt,
completeCnt,
@@ -1233,7 +1233,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
// 날짜별 전체 건수
Expression<Long> dailyTotalCnt = Expressions.numberTemplate(Long.class, "COUNT(*)");
// 전체 기간 총 건수 (윈도우 함수)
// 전체 기간 총 건수 (윈도우 함수)
Expression<Long> totalCnt = Expressions.numberTemplate(Long.class, "SUM(COUNT(*)) OVER ()");
// 상태별 카운트 (Postgres FILTER 사용)
@@ -1277,7 +1277,7 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
LabelingStatDto.class,
workDate,
dailyTotalCnt,
totalCnt, // 전체 일자 배정 건수
totalCnt, // 전체 일자 배정 건수
assignedCnt,
skipCnt,
completeCnt,

View File

@@ -426,7 +426,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
"concat({0}, substring({1}, 1, 5))",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum),
// 튜플 방지: concat으로 문자열 생성
// 튜플 방지: concat으로 문자열 생성
Expressions.stringTemplate(
"concat('(', {0}, ',', {1}, ')')",
mapInkx5kEntity.mapidNm, mapSheetMngHstEntity.mapSheetNum),
@@ -437,7 +437,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
// fid 타입 주의 (Long이면 DTO도 Long으로 맞추는 걸 추천)
mapInkx5kEntity.fid, // 또는 mapInkx5kEntity.fid.intValue()
// createdDate 말고 ZonedDateTime으로 매핑된 필드로
// createdDate 말고 ZonedDateTime으로 매핑된 필드로
mapSheetMngHstEntity.createdDate, // (예시)
mapSheetMngHstEntity.syncState,
mapSheetMngHstEntity.syncTfwFileName,

View File

@@ -19,6 +19,7 @@ spring:
datasource:
url: jdbc:postgresql://192.168.2.127:15432/kamco_cds
#url: jdbc:postgresql://localhost:15432/kamco_cds
username: kamco_cds
password: kamco_cds_Q!W@E#R$
hikari: