260212_01_DOC: 프로젝트 전체에 구글 java 스타일 적용

This commit is contained in:
2026-02-12 11:23:15 +09:00
parent 4948faa28a
commit b07a4389d1
84 changed files with 3176 additions and 2891 deletions

View File

@@ -1,33 +1,33 @@
package com.kri.contact.server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@SpringBootApplication
public class ContactServerApplication {
public static void main(String[] args) {
SpringApplication.run(ContactServerApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(ContactServerApplication.class, args);
}
@Bean
ApplicationRunner dsCheck(ApplicationContext ctx) {
return args -> {
String[] names = ctx.getBeanNamesForType(javax.sql.DataSource.class);
log.info("DataSource beans = {}", java.util.Arrays.toString(names));
for (String n : names) {
Object ds = ctx.getBean(n);
log.info(" - {} = {}", n, ds.getClass().getName());
if (ds instanceof com.zaxxer.hikari.HikariDataSource hk) {
log.info(" jdbcUrl=" + hk.getJdbcUrl());
log.info(" driver=" + hk.getDriverClassName());
}
}
};
}
@Bean
ApplicationRunner dsCheck(ApplicationContext ctx) {
return args -> {
String[] names = ctx.getBeanNamesForType(javax.sql.DataSource.class);
log.info("DataSource beans = {}", java.util.Arrays.toString(names));
for (String n : names) {
Object ds = ctx.getBean(n);
log.info(" - {} = {}", n, ds.getClass().getName());
if (ds instanceof com.zaxxer.hikari.HikariDataSource hk) {
log.info(" jdbcUrl=" + hk.getJdbcUrl());
log.info(" driver=" + hk.getDriverClassName());
}
}
};
}
}

View File

@@ -1,10 +1,10 @@
package com.kri.contact.server.common.consts;
public final class ContactConstant {
private ContactConstant() {}
public static final String DEFAULT_COMPANY_NAME = "KRI";
public static final int OUTSOURCE_USER_ROLE = 4000;
public static final int FIELDWORK_USER_ROLE = 9000;
public static final String DEFAULT_COMPANY_NAME = "KRI";
public static final int OUTSOURCE_USER_ROLE = 4000;
public static final int FIELDWORK_USER_ROLE = 9000;
private ContactConstant() {
}
}

View File

@@ -10,21 +10,25 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public enum ChannelType implements CodeEnum<Short> {
EMAIL((short) 1),
SMS((short) 2);
EMAIL((short) 1),
SMS((short) 2);
private final Short code;
private final Short code;
ChannelType(CodeEnum<Short> source) {
this.code = source.getCode();
ChannelType(CodeEnum<Short> source) {
this.code = source.getCode();
}
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ChannelType fromCode(Short code) {
if (code == null) {
return null;
}
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ChannelType fromCode(Short code) {
if (code == null) return null;
for (ChannelType s : values()) {
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown ChannelType code: " + code);
for (ChannelType s : values()) {
if (s.code == code) {
return s;
}
}
throw new IllegalArgumentException("Unknown ChannelType code: " + code);
}
}

View File

@@ -9,18 +9,22 @@ import lombok.RequiredArgsConstructor;
@Getter(onMethod_ = @JsonValue) // Lombok이 생성하는 getCode()에 @JsonValue 부착
@RequiredArgsConstructor
public enum ProjectStatus implements CodeEnum<Short> {
STANDBY((short) 0), // 대기
PROGRESS((short) 1), // 진행
COMPELETE((short) 10); // 완료
STANDBY((short) 0), // 대기
PROGRESS((short) 1), // 진행
COMPELETE((short) 10); // 완료
private final Short code;
private final Short code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ProjectStatus fromCode(Short code) {
if (code == null) return null;
for (ProjectStatus s : values()) {
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown ProjectStatus code: " + code);
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ProjectStatus fromCode(Short code) {
if (code == null) {
return null;
}
for (ProjectStatus s : values()) {
if (s.code == code) {
return s;
}
}
throw new IllegalArgumentException("Unknown ProjectStatus code: " + code);
}
}

View File

@@ -10,18 +10,22 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public enum ResultCodeType implements CodeEnum<Short> {
CONTACT((short) 0), // 컨택 결과코드
INTERVIEW((short) 1), // 면접 결과코드
SURVEY((short) 2); // 설문 결과코드
CONTACT((short) 0), // 컨택 결과코드
INTERVIEW((short) 1), // 면접 결과코드
SURVEY((short) 2); // 설문 결과코드
private final Short code;
private final Short code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ResultCodeType fromCode(Short code) {
if (code == null) return null;
for (ResultCodeType s : values()) {
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown ResultCodeType code: " + code);
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ResultCodeType fromCode(Short code) {
if (code == null) {
return null;
}
for (ResultCodeType s : values()) {
if (s.code == code) {
return s;
}
}
throw new IllegalArgumentException("Unknown ResultCodeType code: " + code);
}
}

View File

@@ -9,19 +9,23 @@ import lombok.RequiredArgsConstructor;
@Getter(onMethod_ = @JsonValue)
@RequiredArgsConstructor
public enum SurveyType implements CodeEnum<Short> {
NONE((short) 0), // 없음
KON((short) 1), // KON
KIWI((short) 2), // KIWI
EXTERNAL((short) 99); // 외부
NONE((short) 0), // 없음
KON((short) 1), // KON
KIWI((short) 2), // KIWI
EXTERNAL((short) 99); // 외부
private final Short code;
private final Short code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static SurveyType fromCode(Short code) {
if (code == null) return null;
for (SurveyType s : values()) {
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown SurveyType code: " + code);
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static SurveyType fromCode(Short code) {
if (code == null) {
return null;
}
for (SurveyType s : values()) {
if (s.code == code) {
return s;
}
}
throw new IllegalArgumentException("Unknown SurveyType code: " + code);
}
}

View File

@@ -1,6 +1,5 @@
package com.kri.contact.server.common.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import com.kri.common.enums.CodeEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -8,28 +7,28 @@ import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum SystemEventType implements CodeEnum<Short> {
//1의 자리 1 insert, 2 update, 3 delete, 4 upload
//100의 자리 대분류, 10의 자리 소분류
//1의 자리 1 insert, 2 update, 3 delete, 4 upload
//100의 자리 대분류, 10의 자리 소분류
LOGIN((short) 111), // 로그인
LOGOUT((short) 121), // 로그 아웃
LOGIN((short) 111), // 로그인
LOGOUT((short) 121), // 로그 아웃
CREATE_PROJECT((short) 211), // 프로젝트 생성
UPDATE_PROJECT((short) 212), // 프로젝트 수정
DELETE_PROJECT((short) 213), // 프로젝트 삭제
ASSIGN_PROJECT_USER((short) 222), // 프로젝트 배정
UPDATE_PROJECT_DEFAULT_TEMPLATE((short) 232), // 기본 템플릿 수정
CREATE_PROJECT((short) 211), // 프로젝트 생성
UPDATE_PROJECT((short) 212), // 프로젝트 수정
DELETE_PROJECT((short) 213), // 프로젝트 삭제
ASSIGN_PROJECT_USER((short) 222), // 프로젝트 배정
UPDATE_PROJECT_DEFAULT_TEMPLATE((short) 232), // 기본 템플릿 수정
CREATE_USER((short) 311), // 사용자 생성
UPDATE_USER((short) 312), // 사용자 수정
DELETE_USER((short) 313), // 사용자 삭제
UPLOAD_USER((short) 314), // 사용자 삭제
CREATE_USER((short) 311), // 사용자 생성
UPDATE_USER((short) 312), // 사용자 수정
DELETE_USER((short) 313), // 사용자 삭제
UPLOAD_USER((short) 314), // 사용자 삭제
CREATE_ROLE((short) 411), // 권한 생성
UPDATE_ROLE((short) 412), // 권한 수정
DELETE_ROLE((short) 413), // 권한 삭제
CREATE_ROLE((short) 411), // 권한 생성
UPDATE_ROLE((short) 412), // 권한 수정
DELETE_ROLE((short) 413), // 권한 삭제
DUMMY((short) 9999);
DUMMY((short) 9999);
private final Short code;
private final Short code;
}

View File

@@ -1,68 +1,65 @@
package com.kri.contact.server.common.external.intranet;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kri.common.http.ExternalApiClient;
import com.kri.common.http.ExternalApiResponse;
import com.kri.contact.server.dto.LoginRequestDto;
import java.util.Collections;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.kri.common.http.ExternalApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* 공통 모듈로 분리하기 위한 외부(Intranet-Extension) 인증 API 클라이언트.
* 현재 프로젝트 내에 두되, 이후 common 리포지토리로 이동이 용이하도록
* 공통 모듈로 분리하기 위한 외부(Intranet-Extension) 인증 API 클라이언트. 현재 프로젝트 내에 두되, 이후 common 리포지토리로 이동이 용이하도록
* contact-server 의 도메인(Service) 코드와 분리한다.
*/
@Component
@RequiredArgsConstructor
public class IntranetExtensionApiClient {
@Value("${kri.api-url.intranet-extension}")
private String intranetExtensionBaseUrl;
// ExternalApiClient 를 직접 생성해 사용 (starter에서 Bean 미제공 시 대비)
private final ExternalApiClient externalApiClient = new ExternalApiClient();
private final ObjectMapper objectMapper = new ObjectMapper();
@Value("${kri.api-url.intranet-extension}")
private String intranetExtensionBaseUrl;
@Value("${kri.auth.apikey.header-name:X-API-Key}")
private String apiKeyHeaderName;
@Value("${kri.auth.apikey.key}")
private String apiKey;
@Value("${kri.auth.apikey.header-name:X-API-Key}")
private String apiKeyHeaderName;
public SearchLoginInfoResponseDto searchLoginInfo(LoginRequestDto request) {
String url = String.format("%s/user/login-info", intranetExtensionBaseUrl);
// 요구사항: ExternalApiClient.post() 사용 (시그니처: post(url, headers, body))
Map<String, String> headers = new HashMap<>();
headers.put(apiKeyHeaderName, apiKey);
try {
String body = objectMapper.writeValueAsString(request);
ExternalApiResponse response = externalApiClient.post(url, headers, body);
@Value("${kri.auth.apikey.key}")
private String apiKey;
// ExternalApiClient 를 직접 생성해 사용 (starter에서 Bean 미제공 시 대비)
private final ExternalApiClient externalApiClient = new ExternalApiClient();
private final ObjectMapper objectMapper = new ObjectMapper();
public SearchLoginInfoResponseDto searchLoginInfo(LoginRequestDto request) {
String url = String.format("%s/user/login-info", intranetExtensionBaseUrl);
// 요구사항: ExternalApiClient.post() 사용 (시그니처: post(url, headers, body))
Map<String, String> headers = new HashMap<>();
headers.put(apiKeyHeaderName, apiKey);
try {
String body = objectMapper.writeValueAsString(request);
ExternalApiResponse response = externalApiClient.post(url, headers, body);
return objectMapper.readValue(response.getBody(), SearchLoginInfoResponseDto.class);
} catch (JsonProcessingException e) {
return null;
}
return objectMapper.readValue(response.getBody(), SearchLoginInfoResponseDto.class);
} catch (JsonProcessingException e) {
return null;
}
}
public List<String> getUserIdArray() {
String url = String.format("%s/user/user-id-list", intranetExtensionBaseUrl);
Map<String, String> headers = new HashMap<>();
headers.put(apiKeyHeaderName, apiKey);
try {
ExternalApiResponse response = externalApiClient.get(url, headers);
public List<String> getUserIdArray() {
String url = String.format("%s/user/user-id-list", intranetExtensionBaseUrl);
Map<String, String> headers = new HashMap<>();
headers.put(apiKeyHeaderName, apiKey);
try {
ExternalApiResponse response = externalApiClient.get(url, headers);
return objectMapper.readValue(
response.getBody(),
new com.fasterxml.jackson.core.type.TypeReference<List<String>>() {}
);
} catch (JsonProcessingException e) {
return Collections.emptyList();
}
return objectMapper.readValue(
response.getBody(),
new com.fasterxml.jackson.core.type.TypeReference<List<String>>() {
}
);
} catch (JsonProcessingException e) {
return Collections.emptyList();
}
}
}

View File

@@ -12,18 +12,19 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor // Builder 패턴 사용 시 필요
@Schema(description = "인트라넷 사용자 검색 응답 DTO")
public class SearchLoginInfoResponseDto {
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 이름")
private String userNm;
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@Schema(description = "사용자 팀")
private String userTeam;
@Schema(description = "사용자 이름")
private String userNm;
@Schema(description = "사용자 역할")
private int userRole;
@Schema(description = "사용자 팀")
private String userTeam;
@Schema(description = "사용자 역할")
private int userRole;
}

View File

@@ -6,7 +6,8 @@ import jakarta.persistence.Converter;
@Converter(autoApply = false)
public class ResultCodeTypeConverter extends AbstractCodeEnumConverter<ResultCodeType, Short> {
public ResultCodeTypeConverter() {
super(ResultCodeType.class);
}
public ResultCodeTypeConverter() {
super(ResultCodeType.class);
}
}

View File

@@ -2,67 +2,67 @@ package com.kri.contact.server.common.util;
import com.kri.common.excel.ExcelMapper;
import com.kri.contact.server.dto.ExcelUploadResponseDto;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.ByteArrayOutputStream;
import java.util.Base64;
import java.util.List;
import org.apache.poi.ss.usermodel.Workbook;
public final class ExcelUploadResultUtil {
private ExcelUploadResultUtil() {}
private ExcelUploadResultUtil() {
}
/**
* 엑셀 업로드 결과 + 에러 엑셀 생성까지 공통 처리.
*
* @param totalCount 전체 행 수
* @param successCount 성공 개수
* @param errorList 에러 DTO 리스트
* @param errorClass 에러 DTO 타입 (ExcelMapper용)
* @param errorFileName 에러 엑셀 파일명
*/
public static <E> ExcelUploadResponseDto buildUploadResult(
int totalCount,
int successCount,
List<E> errorList,
Class<E> errorClass,
String errorFileName
) {
int failCount = (errorList != null) ? errorList.size() : 0;
/**
* 엑셀 업로드 결과 + 에러 엑셀 생성까지 공통 처리.
*
* @param totalCount 전체 행 수
* @param successCount 성공 개수
* @param errorList 에러 DTO 리스트
* @param errorClass 에러 DTO 타입 (ExcelMapper용)
* @param errorFileName 에러 엑셀 파일명
*/
public static <E> ExcelUploadResponseDto buildUploadResult(
int totalCount,
int successCount,
List<E> errorList,
Class<E> errorClass,
String errorFileName
) {
int failCount = (errorList != null) ? errorList.size() : 0;
// 1) 에러가 없으면 파일 없이 반환
if (failCount == 0) {
return ExcelUploadResponseDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(0)
.hasErrorFile(false)
.build();
}
// 2) 에러가 있으면 에러 리스트를 엑셀로 생성
try (Workbook errorWb = ExcelMapper.writeToWorkbook(errorList, errorClass);
ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
errorWb.write(bos);
byte[] bytes = bos.toByteArray();
String base64 = Base64.getEncoder().encodeToString(bytes);
return ExcelUploadResponseDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(failCount)
.hasErrorFile(true)
.errorFileName(errorFileName)
.errorFileBase64(base64)
.build();
} catch (Exception e) {
// 에러 파일 생성 실패해도 업로드 결과는 그대로 리턴
return ExcelUploadResponseDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(failCount)
.hasErrorFile(false)
.build();
}
// 1) 에러가 없으면 파일 없이 반환
if (failCount == 0) {
return ExcelUploadResponseDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(0)
.hasErrorFile(false)
.build();
}
// 2) 에러가 있으면 에러 리스트를 엑셀로 생성
try (Workbook errorWb = ExcelMapper.writeToWorkbook(errorList, errorClass);
ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
errorWb.write(bos);
byte[] bytes = bos.toByteArray();
String base64 = Base64.getEncoder().encodeToString(bytes);
return ExcelUploadResponseDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(failCount)
.hasErrorFile(true)
.errorFileName(errorFileName)
.errorFileBase64(base64)
.build();
} catch (Exception e) {
// 에러 파일 생성 실패해도 업로드 결과는 그대로 리턴
return ExcelUploadResponseDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(failCount)
.hasErrorFile(false)
.build();
}
}
}

View File

@@ -1,19 +1,19 @@
package com.kri.contact.server.config;
import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import lombok.RequiredArgsConstructor;
import jakarta.persistence.EntityManager;
import com.querydsl.jpa.impl.JPAQueryFactory;
@Configuration
@RequiredArgsConstructor
public class QueryDSLConfig {
private final EntityManager entityManager;
private final EntityManager entityManager;
@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager);
}
@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager);
}
}

View File

@@ -8,13 +8,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebResourceConfig implements WebMvcConfigurer {
@Value("${kri.contact-senario.upload-base-dir}")
private String uploadBaseDir;
@Value("${kri.contact-senario.upload-base-dir}")
private String uploadBaseDir;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// /contact-senario/** → /data/upload-file/contact-senario/** 매핑
registry.addResourceHandler("/contact-senario/**")
.addResourceLocations("file:" + uploadBaseDir + "/");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// /contact-senario/** → /data/upload-file/contact-senario/** 매핑
registry.addResourceHandler("/contact-senario/**")
.addResourceLocations("file:" + uploadBaseDir + "/");
}
}

View File

@@ -7,11 +7,15 @@ import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/assign")
@@ -19,30 +23,31 @@ import java.util.List;
@Tag(name = "Assign", description = "배정 API")
public class AssignController {
private final SystemEventLogService systemEventLogService;
private final AssignService assignService;
private final SystemEventLogService systemEventLogService;
private final AssignService assignService;
@Operation(summary = "배정된 외주사 조회")
@GetMapping("/prjct-outsource/{prjctIdx}")
public List<String> getPrjctOutsourceAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctOutsourceAssign(prjctIdx);
}
@Operation(summary = "배정된 컨택원/면접원 조회")
@GetMapping("/prjct-fieldwork/{prjctIdx}")
public List<String> getPrjctFieldworkAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctFieldworkAssign(prjctIdx);
}
@Operation(summary = "배정된 외주사 조회")
@GetMapping("/prjct-outsource/{prjctIdx}")
public List<String> getPrjctOutsourceAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctOutsourceAssign(prjctIdx);
}
@Operation(summary = "컨택원/면접원 배정")
@PutMapping("/prjct-fieldwork/{prjctIdx}")
public void upsertPrjctFieldworkAssign(
@PathVariable Long prjctIdx,
@Valid @RequestBody List<String> assignUserIdList,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, assignUserIdList);
}
@Operation(summary = "배정된 컨택원/면접원 조회")
@GetMapping("/prjct-fieldwork/{prjctIdx}")
public List<String> getPrjctFieldworkAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctFieldworkAssign(prjctIdx);
}
@Operation(summary = "컨택원/면접원 배정")
@PutMapping("/prjct-fieldwork/{prjctIdx}")
public void upsertPrjctFieldworkAssign(
@PathVariable Long prjctIdx,
@Valid @RequestBody List<String> assignUserIdList,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx,
assignUserIdList);
}
}

View File

@@ -9,40 +9,44 @@ import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/auth")
@RequiredArgsConstructor
@Tag(name = "Auth", description = "인증 API")
public class AuthController {
private final AuthService authService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "로그인 요청")
@PostMapping("/login")
public LoginResponseDto tryLogin(
@Valid @RequestBody LoginRequestDto request,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
private final AuthService authService;
private final SystemEventLogService systemEventLogService;
LoginResponseDto response = authService.tryLogin(request);
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp());
@Operation(summary = "로그인 요청")
@PostMapping("/login")
public LoginResponseDto tryLogin(
@Valid @RequestBody LoginRequestDto request,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return response;
}
LoginResponseDto response = authService.tryLogin(request);
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp());
@Operation(summary = "로그아웃 요청")
@PostMapping("/logout/{userId}")
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return response;
}
systemEventLogService.writeLogoutLog(userId, now, ctx.getClientIp());
@Operation(summary = "로그아웃 요청")
@PostMapping("/logout/{userId}")
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return true;
}
systemEventLogService.writeLogoutLog(userId, now, ctx.getClientIp());
return true;
}
}

View File

@@ -4,19 +4,32 @@ import com.kri.common.datetime.DateTimeUtil;
import com.kri.common.webmvc.RequestUserContext;
import com.kri.common.webmvc.page.PageResponseDto;
import com.kri.contact.server.common.enums.ChannelType;
import com.kri.contact.server.dto.*;
import com.kri.contact.server.dto.ProjectCreateRequestDto;
import com.kri.contact.server.dto.ProjectInfoDto;
import com.kri.contact.server.dto.ProjectMainTemplateUpdateRequestDto;
import com.kri.contact.server.dto.ProjectOwnerResponseDto;
import com.kri.contact.server.dto.ProjectSearchRequestDto;
import com.kri.contact.server.dto.ProjectUpdateRequestDto;
import com.kri.contact.server.service.FileService;
import com.kri.contact.server.service.ProjectService;
import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/v1/project")
@@ -24,109 +37,113 @@ import java.util.List;
@Tag(name = "Project", description = "프로젝트 API")
public class ProjectController {
private final SystemEventLogService systemEventLogService;
private final ProjectService projectService;
private final FileService fileService;
private final SystemEventLogService systemEventLogService;
private final ProjectService projectService;
private final FileService fileService;
@Operation(summary = "프로젝트 조회")
@GetMapping("/{prjctIdx}")
public ProjectInfoDto getProject(@PathVariable Long prjctIdx) {
return projectService.getProject(prjctIdx);
}
@Operation(summary = "프로젝트 조회")
@GetMapping("/{prjctIdx}")
public ProjectInfoDto getProject(@PathVariable Long prjctIdx) {
return projectService.getProject(prjctIdx);
}
@Operation(summary = "상위 프로젝트 조회(생성일자 늦은 순)")
@GetMapping("/top/{topCount}")
public List<ProjectInfoDto> getTopProject(
@PathVariable int topCount,
@RequestParam(required = false) String keyword,
RequestUserContext ctx
) {
return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "상위 프로젝트 조회(생성일자 늦은 순)")
@GetMapping("/top/{topCount}")
public List<ProjectInfoDto> getTopProject(
@PathVariable int topCount,
@RequestParam(required = false) String keyword,
RequestUserContext ctx
) {
return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "프로젝트 목록 조회")
@PostMapping("/list")
public PageResponseDto<ProjectInfoDto> searchProject(
@Valid @RequestBody ProjectSearchRequestDto req,
RequestUserContext ctx
) {
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "프로젝트 목록 조회")
@PostMapping("/list")
public PageResponseDto<ProjectInfoDto> searchProject(
@Valid @RequestBody ProjectSearchRequestDto req,
RequestUserContext ctx
) {
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole());
}
@Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회")
@GetMapping("/owner-list")
public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) {
return projectService.getOwnerList(ctx.getUserRole());
}
//프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기
@Operation(summary = "프로젝트 대표 발송 템플릿 조회")
@GetMapping("/main-template/{prjctIdx}/{chnnlTy}")
public Long getMainTemplateIdx(
@PathVariable Long prjctIdx,
@PathVariable ChannelType chnnlTy
){
return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode());
}
@Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회")
@GetMapping("/owner-list")
public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) {
return projectService.getOwnerList(ctx.getUserRole());
}
@Operation(summary = "프로젝트 생성")
@PutMapping()
public ProjectInfoDto createProject(
@Valid @RequestBody ProjectCreateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기
@Operation(summary = "프로젝트 대표 발송 템플릿 조회")
@GetMapping("/main-template/{prjctIdx}/{chnnlTy}")
public Long getMainTemplateIdx(
@PathVariable Long prjctIdx,
@PathVariable ChannelType chnnlTy
) {
return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode());
}
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now);
systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctInfo.getPrjctIdx(), req);
@Operation(summary = "프로젝트 생성")
@PutMapping()
public ProjectInfoDto createProject(
@Valid @RequestBody ProjectCreateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return prjctInfo;
}
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now);
systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(),
prjctInfo.getPrjctIdx(), req);
@Operation(summary = "시나리오 이미지 업로드")
@PutMapping("/senario-image/{prjctCd}")
public String uploadContactSenarioImage(@PathVariable String prjctCd, @RequestParam("file") MultipartFile file) {
return fileService.storeTempFile(prjctCd, file);
}
return prjctInfo;
}
@Operation(summary = "프로젝트 수정")
@PatchMapping("/{prjctIdx}")
public void updateProject(
@PathVariable long prjctIdx,
@Valid @RequestBody ProjectUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@Operation(summary = "시나리오 이미지 업로드")
@PutMapping("/senario-image/{prjctCd}")
public String uploadContactSenarioImage(@PathVariable String prjctCd,
@RequestParam("file") MultipartFile file) {
return fileService.storeTempFile(prjctCd, file);
}
String newHtml = fileService.syncOnSave(
req.getProjectInfo().getPrjctCd(),
req.getProjectInfo().getContactSenario()
);
req.getProjectInfo().setContactSenario(newHtml);
@Operation(summary = "프로젝트 수정")
@PatchMapping("/{prjctIdx}")
public void updateProject(
@PathVariable long prjctIdx,
@Valid @RequestBody ProjectUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.updateProject(prjctIdx, req, ctx.getUserId(), now);
String newHtml = fileService.syncOnSave(
req.getProjectInfo().getPrjctCd(),
req.getProjectInfo().getContactSenario()
);
req.getProjectInfo().setContactSenario(newHtml);
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req);
}
projectService.updateProject(prjctIdx, req, ctx.getUserId(), now);
@Operation(summary = "프로젝트 대표 발송 템플릿 지정")
@PatchMapping("/main-template")
public void updateProjectMainTemplate(
@Valid @RequestBody ProjectMainTemplateUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx,
req);
}
projectService.updateProjectMainTemplate(req, ctx.getUserId(), now);
systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(), req);
}
@Operation(summary = "프로젝트 대표 발송 템플릿 지정")
@PatchMapping("/main-template")
public void updateProjectMainTemplate(
@Valid @RequestBody ProjectMainTemplateUpdateRequestDto req,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@Operation(summary = "프로젝트 삭제(소프트 삭제)")
@DeleteMapping("/{prjctIdx}")
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.updateProjectMainTemplate(req, ctx.getUserId(), now);
systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(),
req);
}
projectService.deleteProject(prjctIdx, ctx.getUserId(), now);
systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
}
@Operation(summary = "프로젝트 삭제(소프트 삭제)")
@DeleteMapping("/{prjctIdx}")
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.deleteProject(prjctIdx, ctx.getUserId(), now);
systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
}
}

View File

@@ -1,16 +1,18 @@
package com.kri.contact.server.controller;
import com.kri.common.webmvc.RequestUserContext;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.dto.ResultCodeDto;
import com.kri.contact.server.service.ResultCodeService;
import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/result-code")
@@ -18,15 +20,15 @@ import java.util.List;
@Tag(name = "Result Code", description = "결과 코드 API")
public class ResultCodeController {
private final SystemEventLogService systemEventLogService;
private final ResultCodeService resultCodeService;
private final SystemEventLogService systemEventLogService;
private final ResultCodeService resultCodeService;
@Operation(summary = "결과 코드 조회")
@GetMapping("/{prjctIdx}")
public List<ResultCodeDto> getResultCodeList(
@PathVariable long prjctIdx,
@RequestParam(required = false) ResultCodeType resultCdTy
) {
return resultCodeService.getResultCode(prjctIdx, resultCdTy);
}
@Operation(summary = "결과 코드 조회")
@GetMapping("/{prjctIdx}")
public List<ResultCodeDto> getResultCodeList(
@PathVariable long prjctIdx,
@RequestParam(required = false) ResultCodeType resultCdTy
) {
return resultCodeService.getResultCode(prjctIdx, resultCdTy);
}
}

View File

@@ -5,23 +5,23 @@ import com.kri.contact.server.dto.RoleInfoDto;
import com.kri.contact.server.service.RoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/v1/role")
@RequiredArgsConstructor
@Tag(name = "Role", description = "권한 관리 API")
public class RoleController {
private final RoleService roleService;
@Operation(summary = "권한 목록 조회")
@GetMapping()
public List<RoleInfoDto> getRoleList(RequestUserContext ctx) {
return roleService.getRoleList(ctx.getUserRole());
}
private final RoleService roleService;
@Operation(summary = "권한 목록 조회")
@GetMapping()
public List<RoleInfoDto> getRoleList(RequestUserContext ctx) {
return roleService.getRoleList(ctx.getUserRole());
}
}

View File

@@ -12,149 +12,159 @@ import com.kri.contact.server.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
@RestController
@RequestMapping("/api/v1/user")
@RequiredArgsConstructor
@Tag(name = "User", description = "사용자 관리 API")
public class UserController {
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "ID 가용 여부 검사")
@GetMapping("/check-user-id")
public DataVerificationDto checkUserId(@RequestParam String userId) {
return userService.checkUserId(userId);
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "ID 가용 여부 검사")
@GetMapping("/check-user-id")
public DataVerificationDto checkUserId(@RequestParam String userId) {
return userService.checkUserId(userId);
}
@Operation(summary = "사용자 정보 조회")
@GetMapping("/{userId}")
public UserInfoDto getUser(@PathVariable String userId) {
return userService.getUser(userId);
}
@Operation(summary = "사용자 목록 조회")
@GetMapping()
public List<UserInfoDto> getUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if (ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserList();
} else {
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
}
@Operation(summary = "컨택원/면접원 목록 조회")
@GetMapping("fieldwork")
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if (ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
searchCmpn = "";
}
@Operation(summary = "사용자 정보 조회")
@GetMapping("/{userId}")
public UserInfoDto getUser(@PathVariable String userId) {
return userService.getUser(userId);
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
@Operation(summary = "외주사 목록 조회")
@GetMapping("outsource")
List<UserInfoDto> getOutsourceList() {
return userService.getOutsourceList();
}
@Operation(summary = "사용자 회사 목록 조회")
@GetMapping("cmpn")
public List<String> getUserCmpnList(RequestUserContext ctx) {
if (ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserCmpnList();
}
@Operation(summary = "사용자 목록 조회")
@GetMapping()
public List<UserInfoDto> getUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserList();
}
else{
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
}
return Collections.emptyList();
}
@Operation(summary = "컨택원/면접원 목록 조회")
@GetMapping("fieldwork")
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
searchCmpn = "";
}
@Operation(summary = "사용자 생성")
@PutMapping
public void createUser(
@Valid @RequestBody UserInfoDto userInfo,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
userService.createUser(userInfo, regId, now);
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo);
}
@Operation(summary = "외주사 목록 조회")
@GetMapping("outsource")
List<UserInfoDto> getOutsourceList() {
return userService.getOutsourceList();
}
@Operation(summary = "사용자 일괄 생성(엑셀 업로드)")
@PostMapping("/excel")
public ExcelUploadResponseDto createUserFromExcel(
@RequestPart("file") MultipartFile file,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//외주사급이 업로드로 계정을 생성하는 경우 자신의 회사명으로 고정
String forceCmpn =
ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE ? "" : ctx.getUserCmpn();
@Operation(summary = "사용자 회사 목록 조회")
@GetMapping("cmpn")
public List<String> getUserCmpnList(RequestUserContext ctx) {
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserCmpnList();
}
ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, now, forceCmpn);
return Collections.emptyList();
}
UploadUserContentDto content = new UploadUserContentDto(
file.getOriginalFilename(),
file.getContentType(),
file.getSize()
);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
@Operation(summary = "사용자 생성")
@PutMapping
public void createUser(
@Valid @RequestBody UserInfoDto userInfo,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
return result;
}
userService.createUser(userInfo, regId, now);
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo);
}
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
@PostMapping("/excel/template")
public ResponseEntity<byte[]> exportUserTemplate() {
byte[] bytes = userService.exportUserTemplate();
@Operation(summary = "사용자 일괄 생성(엑셀 업로드)")
@PostMapping("/excel")
public ExcelUploadResponseDto createUserFromExcel(
@RequestPart("file") MultipartFile file,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//외주사급이 업로드로 계정을 생성하는 경우 자신의 회사명으로 고정
String forceCmpn = ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE? "" : ctx.getUserCmpn();
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"user_upload_template.xlsx\"")
.contentType(MediaType.parseMediaType(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.body(bytes);
}
ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, now, forceCmpn);
@Operation(summary = "사용자 정보 수정")
@PatchMapping()
public void updateUser(
@Valid @RequestBody UserInfoDto dto,
RequestUserContext ctx
) {
String modId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
UploadUserContentDto content = new UploadUserContentDto(
file.getOriginalFilename(),
file.getContentType(),
file.getSize()
);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
userService.updateUser(dto, modId, now);
systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
}
return result;
}
@Operation(summary = "사용자 삭제(소프트 삭제)")
@DeleteMapping("/{userId}")
public void deleteUser(@PathVariable String userId, RequestUserContext ctx) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
@PostMapping("/excel/template")
public ResponseEntity<byte[]> exportUserTemplate() {
byte[] bytes = userService.exportUserTemplate();
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"user_upload_template.xlsx\"")
.contentType(MediaType.parseMediaType(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.body(bytes);
}
@Operation(summary = "사용자 정보 수정")
@PatchMapping()
public void updateUser(
@Valid @RequestBody UserInfoDto dto,
RequestUserContext ctx
) {
String modId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
userService.updateUser(dto, modId, now);
systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
}
@Operation(summary = "사용자 삭제(소프트 삭제)")
@DeleteMapping("/{userId}")
public void deleteUser(@PathVariable String userId, RequestUserContext ctx) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
userService.deleteUser(userId, regId);
systemEventLogService.writeDeleteUserLog(regId, now, clientIp, userId);
}
userService.deleteUser(userId, regId);
systemEventLogService.writeDeleteUserLog(regId, now, clientIp, userId);
}
}

View File

@@ -12,18 +12,19 @@ import lombok.Setter;
@AllArgsConstructor
@Schema(description = "데이터 검증에 대한 공용 Dto")
public class DataVerificationDto {
@Schema(description = "데이터 검증 통과 여부")
private boolean success;
@Schema(description = "검증 필드명")
private String fieldName;
@Schema(description = "데이터 검증 통과 여부")
private boolean success;
@Schema(description = "검증 메시지(error)")
private String errMessage;
@Schema(description = "검증 필드명")
private String fieldName;
public DataVerificationDto() {
this.success = true;
this.fieldName = "";
this.errMessage = "";
}
@Schema(description = "검증 메시지(error)")
private String errMessage;
public DataVerificationDto() {
this.success = true;
this.fieldName = "";
this.errMessage = "";
}
}

View File

@@ -10,21 +10,21 @@ import lombok.Setter;
@Builder
public class ExcelUploadResponseDto {
@Schema(description = "전체 읽은 행 수 (헤더 제외)")
private int totalCount;
@Schema(description = "전체 읽은 행 수 (헤더 제외)")
private int totalCount;
@Schema(description = "DB에 실제로 insert/update 성공한 개수")
private int successCount;
@Schema(description = "DB에 실제로 insert/update 성공한 개수")
private int successCount;
@Schema(description = "실패(에러) 개수")
private int failCount;
@Schema(description = "실패(에러) 개수")
private int failCount;
@Schema(description = "에러 엑셀 파일이 있는지 여부")
private boolean hasErrorFile;
@Schema(description = "에러 엑셀 파일이 있는지 여부")
private boolean hasErrorFile;
@Schema(description = "프론트가 저장용으로 쓸 파일명")
private String errorFileName;
@Schema(description = "프론트가 저장용으로 쓸 파일명")
private String errorFileName;
@Schema(description = "에러 엑셀 파일 (xlsx)의 Base64 문자열 (hasErrorFile == true일 때만 세팅)")
private String errorFileBase64;
@Schema(description = "에러 엑셀 파일 (xlsx)의 Base64 문자열 (hasErrorFile == true일 때만 세팅)")
private String errorFileBase64;
}

View File

@@ -8,9 +8,10 @@ import lombok.Setter;
@Setter
@Schema(description = "사용자 로그인 요청")
public class LoginRequestDto {
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 PW")
private String userPw;
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 PW")
private String userPw;
}

View File

@@ -10,16 +10,17 @@ import lombok.Getter;
@Builder
@Schema(description = "로그인 응답")
public class LoginResponseDto {
@Schema(description = "jwt access 토큰")
private String accessToken;
@Schema(description = "사용자 정보")
private JwtUserClaimsDto user;
@Schema(description = "jwt access 토큰")
private String accessToken;
public static LoginResponseDto from(String accessToken, JwtUserClaimsDto jwtUserClaims) {
return LoginResponseDto.builder()
.accessToken(accessToken)
.user(jwtUserClaims)
.build();
}
@Schema(description = "사용자 정보")
private JwtUserClaimsDto user;
public static LoginResponseDto from(String accessToken, JwtUserClaimsDto jwtUserClaims) {
return LoginResponseDto.builder()
.accessToken(accessToken)
.user(jwtUserClaims)
.build();
}
}

View File

@@ -3,7 +3,10 @@ package com.kri.contact.server.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@@ -11,23 +14,24 @@ import lombok.*;
@AllArgsConstructor
@Schema(description = "프로젝트 생성 요청")
public class ProjectCreateRequestDto {
@Size(max = 128)
@NotBlank
@Schema(description = "프로젝트 명")
private String prjctName;
@Size(max = 32)
@NotBlank
@Schema(description = "인트라넷 프로젝트 코드")
private String itrntPrjctCd;
@Size(max = 128)
@NotBlank
@Schema(description = "프로젝트 명")
private String prjctName;
@Size(max = 32)
@NotBlank
@Schema(description = "담당 그룹")
private String ownerDept;
@Size(max = 32)
@NotBlank
@Schema(description = "인트라넷 프로젝트 코드")
private String itrntPrjctCd;
@Size(max = 16)
@NotBlank
@Schema(description = "담당 실사")
private String ownerFw;
@Size(max = 32)
@NotBlank
@Schema(description = "담당 그룹")
private String ownerDept;
@Size(max = 16)
@NotBlank
@Schema(description = "담당 실사")
private String ownerFw;
}

View File

@@ -8,9 +8,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@@ -19,99 +22,100 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@Schema(description = "프로젝트 정보")
public class ProjectInfoDto {
@NotNull
@Schema(description = "프로젝트 고유 번호")
private Long prjctIdx;
@Size(max = 32)
@NotBlank
@Schema(description = "프로젝트 코드")
private String prjctCd;
@NotNull
@Schema(description = "프로젝트 고유 번호")
private Long prjctIdx;
@NotNull
@Schema(description = "프로젝트 진행 상태")
private ProjectStatus prjctStatus;
@Size(max = 32)
@NotBlank
@Schema(description = "프로젝트 코드")
private String prjctCd;
@Size(max = 128)
@NotBlank
@Schema(description = "프로젝트 명")
private String prjctName;
@NotNull
@Schema(description = "프로젝트 진행 상태")
private ProjectStatus prjctStatus;
@Size(max = 32)
@NotBlank
@Schema(description = "인트라넷 프로젝트 코드")
private String itrntPrjctCd;
@Size(max = 128)
@NotBlank
@Schema(description = "프로젝트 명")
private String prjctName;
@Size(max = 32)
@NotBlank
@Schema(description = "담당 그룹")
private String ownerDept;
@Size(max = 32)
@NotBlank
@Schema(description = "인트라넷 프로젝트 코드")
private String itrntPrjctCd;
@Size(max = 16)
@NotBlank
@Schema(description = "담당 실사")
private String ownerFw;
@Size(max = 32)
@NotBlank
@Schema(description = "담당 그룹")
private String ownerDept;
@NotNull
@Schema(description = "설문지 타입")
private SurveyType surveyTy;
@Size(max = 16)
@NotBlank
@Schema(description = "담당 실사")
private String ownerFw;
@Size(max = 32)
@Schema(description = "내부 설문 시스템 프로젝트 코드")
private String surveyPrjctCd;
@NotNull
@Schema(description = "설문지 타입")
private SurveyType surveyTy;
@Size(max = 128)
@Schema(description = "설문 URL")
private String surveyUrl;
@Size(max = 32)
@Schema(description = "내부 설문 시스템 프로젝트 코드")
private String surveyPrjctCd;
@NotNull
@Schema(description = "면접원 확인사항 여부")
private Boolean ff;
@Size(max = 128)
@Schema(description = "설문 URL")
private String surveyUrl;
@NotNull
@Schema(description = "컨택 시나리오 사용 여부")
private Boolean useContactSenario;
@NotNull
@Schema(description = "면접원 확인사항 여부")
private Boolean ff;
@Schema(description = "컨택 시나리오")
private String contactSenario;
@NotNull
@Schema(description = "컨택 시나리오 사용 여부")
private Boolean useContactSenario;
@Size(max = 32)
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Schema(description = "컨택 시나리오")
private String contactSenario;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt;
@Size(max = 32)
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Size(max = 32)
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt;
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt;
@Size(max = 32)
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
public static ProjectInfoDto from(TPrjctEntity entity) {
return ProjectInfoDto.builder()
.prjctIdx(entity.getPrjctIdx())
.prjctCd(entity.getPrjctCd())
.prjctStatus(ProjectStatus.fromCode(entity.getPrjctStatus()))
.prjctName(entity.getPrjctNm())
.itrntPrjctCd(entity.getItrntPrjctCd())
.ownerDept(entity.getOwnerDept())
.ownerFw(entity.getOwnerFw())
.surveyTy(SurveyType.fromCode(entity.getSurveyTy()))
.surveyPrjctCd(entity.getSurveyPrjctCd())
.surveyUrl(entity.getSurveyUrl())
.ff(entity.getFf())
.useContactSenario(entity.getUseContactSenario())
.contactSenario(entity.getContactSenario())
.regUser(entity.getRegUser())
.regDt(entity.getRegDt())
.modUser(entity.getModUser())
.modDt(entity.getModDt())
.build();
}
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt;
public static ProjectInfoDto from(TPrjctEntity entity) {
return ProjectInfoDto.builder()
.prjctIdx(entity.getPrjctIdx())
.prjctCd(entity.getPrjctCd())
.prjctStatus(ProjectStatus.fromCode(entity.getPrjctStatus()))
.prjctName(entity.getPrjctNm())
.itrntPrjctCd(entity.getItrntPrjctCd())
.ownerDept(entity.getOwnerDept())
.ownerFw(entity.getOwnerFw())
.surveyTy(SurveyType.fromCode(entity.getSurveyTy()))
.surveyPrjctCd(entity.getSurveyPrjctCd())
.surveyUrl(entity.getSurveyUrl())
.ff(entity.getFf())
.useContactSenario(entity.getUseContactSenario())
.contactSenario(entity.getContactSenario())
.regUser(entity.getRegUser())
.regDt(entity.getRegDt())
.modUser(entity.getModUser())
.modDt(entity.getModDt())
.build();
}
}

View File

@@ -15,16 +15,16 @@ import lombok.Setter;
@Schema(description = "프로젝트 생성 요청")
public class ProjectMainTemplateUpdateRequestDto {
@NotNull
@Schema(description = "프로젝트 명")
private Long prjctIdx;
@NotNull
@Schema(description = "프로젝트 명")
private Long prjctIdx;
@NotNull
@Schema(description = "템플릿 채널 타입")
private ChannelType chnnlTy;
@NotNull
@Schema(description = "템플릿 채널 타입")
private ChannelType chnnlTy;
@NotNull
@Schema(description = "프로젝트 명")
private Long tmplatIdx;
@NotNull
@Schema(description = "프로젝트 명")
private Long tmplatIdx;
}

View File

@@ -1,9 +1,11 @@
package com.kri.contact.server.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@@ -11,8 +13,9 @@ import java.util.List;
@AllArgsConstructor
@Schema(description = "프로젝트 담당들 정보")
public class ProjectOwnerResponseDto {
@Schema(description = "담당 연구 부서")
List<String> ownerDeptList;
@Schema(description = "담당 실사 인원")
List<String> ownerFwList;
@Schema(description = "담당 연구 부서")
List<String> ownerDeptList;
@Schema(description = "담당 실사 인원")
List<String> ownerFwList;
}

View File

@@ -2,23 +2,23 @@ package com.kri.contact.server.dto;
import com.kri.common.webmvc.page.PageRequestDto;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@Schema(description = "프로젝트 검색 조건")
public class ProjectSearchRequestDto {
@Schema(description = "검색 텍스트")
private String prjctText; // like 대상
@Schema(description = "프로젝트 상태 리스트")
private List<Short> prjctStatusList; // in (0,1,10)
@Schema(description = "담당 부서 리스트")
private List<String> ownerDeptList; // in ('S101','P101')
@Schema(description = "담당 실사 리스트")
private List<String> ownerFwList; // in ('jspark','jhchae')
private PageRequestDto pageRequest;
@Schema(description = "검색 텍스트")
private String prjctText; // like 대상
@Schema(description = "프로젝트 상태 리스트")
private List<Short> prjctStatusList; // in (0,1,10)
@Schema(description = "담당 부서 리스트")
private List<String> ownerDeptList; // in ('S101','P101')
@Schema(description = "담당 실사 리스트")
private List<String> ownerFwList; // in ('jspark','jhchae')
private PageRequestDto pageRequest;
}

View File

@@ -2,23 +2,22 @@ package com.kri.contact.server.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@Getter
@Setter
@Schema(description = "프로젝트 수정 요청")
public class ProjectUpdateRequestDto {
@NotNull
@Schema(description = "프로젝트 정보")
private ProjectInfoDto projectInfo;
@Schema(description = "프로젝트 수정 되야 할 결과코드")
private List<ResultCodeDto> resultCodeList;
@NotNull
@Schema(description = "프로젝트 정보")
private ProjectInfoDto projectInfo;
@Schema(description = "배정될 외주 업체 목록")
private List<String> assignUserIdList;
@Schema(description = "프로젝트 수정 되야 할 결과코드")
private List<ResultCodeDto> resultCodeList;
@Schema(description = "배정될 외주 업체 목록")
private List<String> assignUserIdList;
}

View File

@@ -3,39 +3,39 @@ package com.kri.contact.server.dto;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.persistence.entity.TResultCodeEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.util.UUID;
@Getter
@Setter
@Builder
@Schema(description = "결과 코드")
public class ResultCodeDto {
@Schema(description = "결과 코드 고유 키")
private String resultCdUUID;
@Schema(description = "프로젝트 인덱스")
private Long prjctIdx;
@Schema(description = "결과 코드 고유 키")
private String resultCdUUID;
@Schema(description = "결과 코드 타입")
private ResultCodeType resultCdTy;
@Schema(description = "프로젝트 인덱스")
private Long prjctIdx;
@Schema(description = "결과 코드")
private Short resultCd;
@Schema(description = "결과 코드 타입")
private ResultCodeType resultCdTy;
@Schema(description = "결과 코드 라벨")
private String resultCdLbl;
@Schema(description = "결과 코드")
private Short resultCd;
public static ResultCodeDto from(TResultCodeEntity entity) {
return ResultCodeDto.builder()
.resultCdUUID(UUID.randomUUID().toString())
.prjctIdx(entity.getPrjctIdx())
.resultCdTy(entity.getResultCdTy())
.resultCd(entity.getResultCd())
.resultCdLbl(entity.getResultCdLbl())
.build();
}
@Schema(description = "결과 코드 라벨")
private String resultCdLbl;
public static ResultCodeDto from(TResultCodeEntity entity) {
return ResultCodeDto.builder()
.resultCdUUID(UUID.randomUUID().toString())
.prjctIdx(entity.getPrjctIdx())
.resultCdTy(entity.getResultCdTy())
.resultCd(entity.getResultCd())
.resultCdLbl(entity.getResultCdLbl())
.build();
}
}

View File

@@ -3,52 +3,52 @@ package com.kri.contact.server.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.kri.contact.server.persistence.entity.TRoleEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Getter
@Setter
@Builder
@Schema(description = "권한 정보")
public class RoleInfoDto {
@Schema(description = "권한 코드")
private Integer roleCd;
@Schema(description = "권한 명")
private String roleNm;
@Schema(description = "권한 코드")
private Integer roleCd;
@Schema(description = "메모")
private String memo;
@Schema(description = "권한 명")
private String roleNm;
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Schema(description = "메모")
private String memo;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt;
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt;
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt;
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt;
public static RoleInfoDto from(TRoleEntity roleEntity) {
return RoleInfoDto.builder()
.roleCd(roleEntity.getRoleCd())
.roleNm(roleEntity.getRoleNm())
.memo(roleEntity.getMemo())
.regUser(roleEntity.getRegUser())
.regDt(roleEntity.getRegDt())
.modUser(roleEntity.getModUser())
.modDt(roleEntity.getModDt())
.build();
}
public static RoleInfoDto from(TRoleEntity roleEntity) {
return RoleInfoDto.builder()
.roleCd(roleEntity.getRoleCd())
.roleNm(roleEntity.getRoleNm())
.memo(roleEntity.getMemo())
.regUser(roleEntity.getRegUser())
.regDt(roleEntity.getRegDt())
.modUser(roleEntity.getModUser())
.modDt(roleEntity.getModDt())
.build();
}
}

View File

@@ -8,9 +8,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@@ -19,82 +22,83 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@Schema(description = "사용자 정보")
public class UserInfoDto {
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 ID")
private String userId;
@Size(max = 128)
@NotBlank
@Schema(description = "사용자 PW")
private String userPw;
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 ID")
private String userId;
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 이름")
private String userName;
@Size(max = 128)
@NotBlank
@Schema(description = "사용자 PW")
private String userPw;
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 이름")
private String userName;
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 소속 팀")
private String userTeam = "S101";
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@NotNull
@Schema(description = "사용자 권한")
private Integer userRole;
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 소속 팀")
private String userTeam = "S101";
@Schema(description = "메모")
private String memo;
@NotNull
@Schema(description = "사용자 권한")
private Integer userRole;
@Size(max = 32)
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Schema(description = "메모")
private String memo;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt;
@Size(max = 32)
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Size(max = 32)
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt;
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt;
@Size(max = 32)
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
public static UserInfoDto from(TUserEntity entity) {
return UserInfoDto.builder()
.userId(entity.getUserId())
.userName(entity.getUserNm())
.userCmpn(entity.getUserCmpn())
.userTeam(entity.getUserTeam())
.userRole(entity.getUserRole())
.memo(entity.getMemo())
.regUser(entity.getRegUser())
.regDt(entity.getRegDt())
.modUser(entity.getModUser())
.modDt(entity.getModDt())
.build();
}
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt;
public static UserInfoDto from(UserUploadDto dto, Integer userRole, String regUser) {
return UserInfoDto.builder()
.userId(dto.getUserId())
.userPw(dto.getUserPw())
.userName(dto.getUserName())
.userCmpn(dto.getUserCmpn())
.userTeam("S101")
.userRole(userRole)
.memo(dto.getMemo())
.regUser(regUser)
.regDt(DateTimeUtil.nowKstLocalDateTime())
.build();
}
public static UserInfoDto from(TUserEntity entity) {
return UserInfoDto.builder()
.userId(entity.getUserId())
.userName(entity.getUserNm())
.userCmpn(entity.getUserCmpn())
.userTeam(entity.getUserTeam())
.userRole(entity.getUserRole())
.memo(entity.getMemo())
.regUser(entity.getRegUser())
.regDt(entity.getRegDt())
.modUser(entity.getModUser())
.modDt(entity.getModDt())
.build();
}
public static UserInfoDto from(UserUploadDto dto, Integer userRole, String regUser) {
return UserInfoDto.builder()
.userId(dto.getUserId())
.userPw(dto.getUserPw())
.userName(dto.getUserName())
.userCmpn(dto.getUserCmpn())
.userTeam("S101")
.userRole(userRole)
.memo(dto.getMemo())
.regUser(regUser)
.regDt(DateTimeUtil.nowKstLocalDateTime())
.build();
}
}

View File

@@ -10,20 +10,20 @@ import lombok.experimental.SuperBuilder;
@Setter
public class ExcelErrorDto {
@ExcelColumn(header = "행 번호", order = 0)
private int rowNumber;
@ExcelColumn(header = "행 번호", order = 0)
private int rowNumber;
@ExcelColumn(header = "필드명", order = 1)
private String fieldName;
@ExcelColumn(header = "필드명", order = 1)
private String fieldName;
@ExcelColumn(header = "에러 메시지", order = 2)
private String errorMessage;
@ExcelColumn(header = "에러 메시지", order = 2)
private String errorMessage;
public static ExcelErrorDto of(int rowNumber, String fieldName, String errorMessage) {
return ExcelErrorDto.builder()
.rowNumber(rowNumber)
.fieldName(fieldName)
.errorMessage(errorMessage)
.build();
}
public static ExcelErrorDto of(int rowNumber, String fieldName, String errorMessage) {
return ExcelErrorDto.builder()
.rowNumber(rowNumber)
.fieldName(fieldName)
.errorMessage(errorMessage)
.build();
}
}

View File

@@ -2,7 +2,11 @@ package com.kri.contact.server.dto.excel;
import com.kri.common.excel.ExcelColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@@ -10,27 +14,28 @@ import lombok.*;
@NoArgsConstructor
@AllArgsConstructor
public class UserUploadDto {
@ExcelColumn(header = "사용자 ID", order = 0, width = 11)
@Schema(description = "사용자 ID")
private String userId;
@ExcelColumn(header = "사용자 PW", order = 1, width = 11)
@Schema(description = "사용자 PW")
private String userPw;
@ExcelColumn(header = "사용자 ID", order = 0, width = 11)
@Schema(description = "사용자 ID")
private String userId;
@ExcelColumn(header = "사용자 이름", order = 2, width = 11)
@Schema(description = "사용자 이름")
private String userName;
@ExcelColumn(header = "사용자 PW", order = 1, width = 11)
@Schema(description = "사용자 PW")
private String userPw;
@ExcelColumn(header = "사용자 소속 회사", order = 3, width = 16)
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@ExcelColumn(header = "사용자 이름", order = 2, width = 11)
@Schema(description = "사용자 이름")
private String userName;
@ExcelColumn(header = "사용자 권한", order = 4, width = 11)
@Schema(description = "사용자 권한")
private String userRoleStr;
@ExcelColumn(header = "사용자 소속 회사", order = 3, width = 16)
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@ExcelColumn(header = "메모", order = 5, width = 20)
@Schema(description = "메모")
private String memo;
@ExcelColumn(header = "사용자 권한", order = 4, width = 11)
@Schema(description = "사용자 권한")
private String userRoleStr;
@ExcelColumn(header = "메모", order = 5, width = 20)
@Schema(description = "메모")
private String memo;
}

View File

@@ -9,11 +9,11 @@ import lombok.experimental.SuperBuilder;
@Setter
public class UserUploadErrorDto extends ExcelErrorDto {
public static UserUploadErrorDto of(int rowNumber, String fieldName, String errorMessage) {
return UserUploadErrorDto.builder()
.rowNumber(rowNumber)
.fieldName(fieldName)
.errorMessage(errorMessage)
.build();
}
public static UserUploadErrorDto of(int rowNumber, String fieldName, String errorMessage) {
return UserUploadErrorDto.builder()
.rowNumber(rowNumber)
.fieldName(fieldName)
.errorMessage(errorMessage)
.build();
}
}

View File

@@ -8,8 +8,9 @@ import lombok.Setter;
@Getter
@AllArgsConstructor
public class UploadUserContentDto {
String fileName;
String fileType;
Long fileSize;
String fileName;
String fileType;
Long fileSize;
}

View File

@@ -1,6 +1,10 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
@@ -12,32 +16,33 @@ import org.hibernate.annotations.ColumnDefault;
@Entity
@Table(name = "t_func")
public class TFuncEntity {
@Id
@NotNull
@Column(name = "func_cd")
private Integer funcCd;
@Size(max = 32)
@NotNull
@Column(name = "func_nm", nullable = false, length = 32)
private String funcNm;
@Id
@NotNull
@Column(name = "func_cd")
private Integer funcCd;
@NotNull
@ColumnDefault("1")
@Column(name = "is_menu", nullable = false)
private Boolean menu = false;
@Size(max = 32)
@NotNull
@Column(name = "func_nm", nullable = false, length = 32)
private String funcNm;
@NotNull
@Column(name = "depth", nullable = false)
private Integer depth;
@NotNull
@ColumnDefault("1")
@Column(name = "is_menu", nullable = false)
private Boolean menu = false;
@NotNull
@Column(name = "parent", nullable = false)
private Integer parent;
@NotNull
@Column(name = "depth", nullable = false)
private Integer depth;
@NotNull
@Lob
@Column(name = "func_memo", nullable = false)
private String funcMemo;
@NotNull
@Column(name = "parent", nullable = false)
private Integer parent;
@NotNull
@Lob
@Column(name = "func_memo", nullable = false)
private String funcMemo;
}

View File

@@ -1,44 +1,49 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_assign")
public class TListAssignEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_assign_idx", nullable = false)
private Long listAssignIdx;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_assign_idx", nullable = false)
private Long listAssignIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "assign_ty", nullable = false)
private Short assignTy;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Size(max = 32)
@Column(name = "user_id", length = 32)
private String userId;
@NotNull
@Column(name = "assign_ty", nullable = false)
private Short assignTy;
@Size(max = 32)
@Column(name = "reg_user", length = 32)
private String regUser;
@Size(max = 32)
@Column(name = "user_id", length = 32)
private String userId;
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt")
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "reg_user", length = 32)
private String regUser;
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt")
private LocalDateTime regDt;
}

View File

@@ -6,50 +6,50 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list")
public class TListEntity {
@EmbeddedId
private TListEntityId id;
@NotNull
@Column(name = "is_use", nullable = false)
private Short use;
@EmbeddedId
private TListEntityId id;
@Size(max = 2048)
@Column(name = "memo", length = 2048)
private String memo;
@NotNull
@Column(name = "is_use", nullable = false)
private Short use;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 2048)
@Column(name = "memo", length = 2048)
private String memo;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public Integer getSid() {
return id.getSid();
}
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
public Integer getSid() {
return id.getSid();
}
}

View File

@@ -3,37 +3,41 @@ package com.kri.contact.server.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
@Embeddable
public class TListEntityId implements Serializable {
private static final long serialVersionUID = 7012247084434778447L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
private static final long serialVersionUID = 7012247084434778447L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListEntityId entity = (TListEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.sid, entity.sid);
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, sid);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TListEntityId entity = (TListEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.sid, entity.sid);
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, sid);
}
}

View File

@@ -1,49 +1,55 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_event_hist")
public class TListEventHistEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_event_hist_idx", nullable = false)
private Long listEventHistIdx;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_event_hist_idx", nullable = false)
private Long listEventHistIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "result_cd", nullable = false)
private Integer resultCd;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@NotNull
@Lob
@Column(name = "contact_memo", nullable = false)
private String contactMemo;
@NotNull
@Column(name = "result_cd", nullable = false)
private Integer resultCd;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@Lob
@Column(name = "contact_memo", nullable = false)
private String contactMemo;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
}

View File

@@ -6,71 +6,71 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_header")
public class TListHeaderEntity {
@EmbeddedId
private TListHeaderEntityId id;
@NotNull
@Column(name = "list_hder_grad", nullable = false)
private Short listHderGrad;
@EmbeddedId
private TListHeaderEntityId id;
@Size(max = 32)
@NotNull
@Column(name = "list_hder_nm", nullable = false, length = 32)
private String listHderNm;
@NotNull
@Column(name = "list_hder_grad", nullable = false)
private Short listHderGrad;
@NotNull
@Column(name = "list_hder_ty", nullable = false)
private Short listHderTy;
@Size(max = 32)
@NotNull
@Column(name = "list_hder_nm", nullable = false, length = 32)
private String listHderNm;
@NotNull
@Column(name = "use_filter", nullable = false)
private Boolean useFilter = false;
@NotNull
@Column(name = "list_hder_ty", nullable = false)
private Short listHderTy;
@NotNull
@Column(name = "use_view", nullable = false)
private Boolean useView = false;
@NotNull
@Column(name = "use_filter", nullable = false)
private Boolean useFilter = false;
@NotNull
@Column(name = "use_intrvwer_view", nullable = false)
private Boolean useIntrvwerView = false;
@NotNull
@Column(name = "use_view", nullable = false)
private Boolean useView = false;
@NotNull
@Column(name = "use_intrvwer_edit", nullable = false)
private Boolean useIntrvwerEdit = false;
@NotNull
@Column(name = "use_intrvwer_view", nullable = false)
private Boolean useIntrvwerView = false;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@Column(name = "use_intrvwer_edit", nullable = false)
private Boolean useIntrvwerEdit = false;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public Integer getListHderId() {
return id.getListHderId();
}
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
public Integer getListHderId() {
return id.getListHderId();
}
}

View File

@@ -3,37 +3,41 @@ package com.kri.contact.server.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
@Embeddable
public class TListHeaderEntityId implements Serializable {
private static final long serialVersionUID = -1296812261527497087L;
@Column(name = "prjct_idx", insertable = false, updatable = false, columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
private static final long serialVersionUID = -1296812261527497087L;
@Column(name = "prjct_idx", insertable = false, updatable = false, columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListHeaderEntityId entity = (TListHeaderEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.listHderId, entity.listHderId);
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, listHderId);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TListHeaderEntityId entity = (TListHeaderEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.listHderId, entity.listHderId);
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, listHderId);
}
}

View File

@@ -1,53 +1,57 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_item")
public class TListItemEntity {
@EmbeddedId
private TListItemEntityId id;
@NotNull
@Lob
@Column(name = "list_item_val", nullable = false)
private String listItemVal;
@EmbeddedId
private TListItemEntityId id;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@Lob
@Column(name = "list_item_val", nullable = false)
private String listItemVal;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public Integer getSid() {
return id.getSid();
}
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
public Integer getListHderId() {
return id.getListHderId();
}
public Integer getSid() {
return id.getSid();
}
public Integer getListHderId() {
return id.getListHderId();
}
}

View File

@@ -3,42 +3,46 @@ package com.kri.contact.server.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
@Embeddable
public class TListItemEntityId implements Serializable {
private static final long serialVersionUID = -3478285652359764540L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
private static final long serialVersionUID = -3478285652359764540L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListItemEntityId entity = (TListItemEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.listHderId, entity.listHderId) &&
Objects.equals(this.sid, entity.sid);
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, listHderId, sid);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TListItemEntityId entity = (TListItemEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.listHderId, entity.listHderId) &&
Objects.equals(this.sid, entity.sid);
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, listHderId, sid);
}
}

View File

@@ -6,57 +6,57 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_item_upload")
public class TListItemUploadEntity {
@EmbeddedId
private TListItemUploadEntityId id;
@Size(max = 128)
@Column(name = "file_nm", length = 128)
private String fileNm;
@EmbeddedId
private TListItemUploadEntityId id;
@Column(name = "file_size")
private Integer fileSize;
@Size(max = 128)
@Column(name = "file_nm", length = 128)
private String fileNm;
@Size(max = 128)
@Column(name = "file_path", length = 128)
private String filePath;
@Column(name = "file_size")
private Integer fileSize;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 128)
@Column(name = "file_path", length = 128)
private String filePath;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public Integer getSid() {
return id.getSid();
}
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
public Integer getListHderId() {
return id.getListHderId();
}
public Integer getSid() {
return id.getSid();
}
public Integer getListHderId() {
return id.getListHderId();
}
}

View File

@@ -3,42 +3,46 @@ package com.kri.contact.server.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
@Embeddable
public class TListItemUploadEntityId implements Serializable {
private static final long serialVersionUID = -8073832649114843758L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
private static final long serialVersionUID = -8073832649114843758L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListItemUploadEntityId entity = (TListItemUploadEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.listHderId, entity.listHderId) &&
Objects.equals(this.sid, entity.sid);
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, listHderId, sid);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TListItemUploadEntityId entity = (TListItemUploadEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.listHderId, entity.listHderId) &&
Objects.equals(this.sid, entity.sid);
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, listHderId, sid);
}
}

View File

@@ -1,61 +1,66 @@
package com.kri.contact.server.persistence.entity;
import io.hypersistence.utils.hibernate.type.json.JsonType;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type;
import java.time.LocalDateTime;
import java.util.Map;
@Getter
@Setter
@Entity
@Table(name = "t_list_reset_log")
public class TListResetLogEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_reset_log_idx", columnDefinition = "int UNSIGNED not null")
private Long listResetLogIdx;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_reset_log_idx", columnDefinition = "int UNSIGNED not null")
private Long listResetLogIdx;
@NotNull
@Column(name = "mode", nullable = false)
private Short mode;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "list_cnt", nullable = false)
private Integer listCnt;
@NotNull
@Column(name = "mode", nullable = false)
private Short mode;
@NotNull
@Type(JsonType.class)
@Column(name = "sid", nullable = false)
private Map<String, Object> sid;
@NotNull
@Column(name = "list_cnt", nullable = false)
private Integer listCnt;
@Size(max = 128)
@NotNull
@Column(name = "backup_file_path", nullable = false, length = 128)
private String backupFilePath;
@NotNull
@Type(JsonType.class)
@Column(name = "sid", nullable = false)
private Map<String, Object> sid;
@Size(max = 128)
@NotNull
@Column(name = "backup_file_nm", nullable = false, length = 128)
private String backupFileNm;
@Size(max = 128)
@NotNull
@Column(name = "backup_file_path", nullable = false, length = 128)
private String backupFilePath;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@Size(max = 128)
@NotNull
@Column(name = "backup_file_nm", nullable = false, length = 128)
private String backupFileNm;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
}

View File

@@ -1,58 +1,63 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_resve")
public class TListResveEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_resve_idx", columnDefinition = "int UNSIGNED not null")
private Long listResveIdx;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_resve_idx", columnDefinition = "int UNSIGNED not null")
private Long listResveIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Size(max = 2048)
@NotNull
@Column(name = "memo", nullable = false, length = 2048)
private String memo;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@NotNull
@ColumnDefault("0")
@Column(name = "is_cnfirm", nullable = false)
private Boolean cnfirm = false;
@Size(max = 2048)
@NotNull
@Column(name = "memo", nullable = false, length = 2048)
private String memo;
@NotNull
@Column(name = "resve_dt", nullable = false)
private LocalDateTime resveDt;
@NotNull
@ColumnDefault("0")
@Column(name = "is_cnfirm", nullable = false)
private Boolean cnfirm = false;
@Size(max = 32)
@NotNull
@Column(name = "resve_user", nullable = false, length = 32)
private String resveUser;
@NotNull
@Column(name = "resve_dt", nullable = false)
private LocalDateTime resveDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@Size(max = 32)
@NotNull
@Column(name = "resve_user", nullable = false, length = 32)
private String resveUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
}

View File

@@ -1,53 +1,59 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_update_hist")
public class TListUpdateHistEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_update_hist_idx", nullable = false)
private Long listUpdateHistIdx;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_update_hist_idx", nullable = false)
private Long listUpdateHistIdx;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@NotNull
@Column(name = "sid", nullable = false)
private Integer sid;
@NotNull
@Lob
@Column(name = "before_val", nullable = false)
private String beforeVal;
@NotNull
@Column(name = "list_hder_id", nullable = false)
private Integer listHderId;
@NotNull
@Lob
@Column(name = "after_val", nullable = false)
private String afterVal;
@NotNull
@Lob
@Column(name = "before_val", nullable = false)
private String beforeVal;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@Lob
@Column(name = "after_val", nullable = false)
private String afterVal;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
}

View File

@@ -1,61 +1,66 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_list_upload_log")
public class TListUploadLogEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_upload_log_idx", nullable = false)
private Long listUploadLogIdx;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_upload_log_idx", nullable = false)
private Long listUploadLogIdx;
@NotNull
@Column(name = "wave", nullable = false)
private Integer wave;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Size(max = 128)
@NotNull
@Column(name = "file_nm", nullable = false, length = 128)
private String fileNm;
@NotNull
@Column(name = "wave", nullable = false)
private Integer wave;
@NotNull
@Column(name = "list_cnt", nullable = false)
private Integer listCnt;
@Size(max = 128)
@NotNull
@Column(name = "file_nm", nullable = false, length = 128)
private String fileNm;
@NotNull
@Column(name = "mode", nullable = false)
private Short mode;
@NotNull
@Column(name = "list_cnt", nullable = false)
private Integer listCnt;
@Size(max = 64)
@NotNull
@Column(name = "optn", nullable = false, length = 64)
private String optn;
@NotNull
@Column(name = "mode", nullable = false)
private Short mode;
@NotNull
@Column(name = "is_success", nullable = false)
private Boolean success = false;
@Size(max = 64)
@NotNull
@Column(name = "optn", nullable = false, length = 64)
private String optn;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@Column(name = "is_success", nullable = false)
private Boolean success = false;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
}

View File

@@ -6,10 +6,13 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -19,32 +22,34 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@Table(name = "t_prjct_assign")
public class TPrjctAssignEntity {
@EmbeddedId
private TPrjctAssignEntityId id;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@EmbeddedId
private TPrjctAssignEntityId id;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
public static TPrjctAssignEntity create(Long prjctIdx, String userId, String regUser, LocalDateTime regDt) {
return TPrjctAssignEntity.builder()
.id(TPrjctAssignEntityId.create(prjctIdx, userId))
.regUser(regUser)
.regDt(regDt)
.build();
}
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
public static TPrjctAssignEntity create(Long prjctIdx, String userId, String regUser,
LocalDateTime regDt) {
return TPrjctAssignEntity.builder()
.id(TPrjctAssignEntityId.create(prjctIdx, userId))
.regUser(regUser)
.regDt(regDt)
.build();
}
public String getUserId() {
return id.getUserId();
}
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
public String getUserId() {
return id.getUserId();
}
}

View File

@@ -4,11 +4,14 @@ import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter
@Setter
@@ -17,33 +20,38 @@ import java.util.Objects;
@NoArgsConstructor
@AllArgsConstructor
public class TPrjctAssignEntityId implements Serializable {
private static final long serialVersionUID = -263674621497298216L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Size(max = 32)
@NotNull
@Column(name = "user_id", nullable = false, length = 32)
private String userId;
private static final long serialVersionUID = -263674621497298216L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TPrjctAssignEntityId entity = (TPrjctAssignEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.userId, entity.userId);
@Size(max = 32)
@NotNull
@Column(name = "user_id", nullable = false, length = 32)
private String userId;
public static TPrjctAssignEntityId create(Long prjctIdx, String userId) {
return TPrjctAssignEntityId.builder()
.prjctIdx(prjctIdx)
.userId(userId)
.build();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, userId);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TPrjctAssignEntityId entity = (TPrjctAssignEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.userId, entity.userId);
}
public static TPrjctAssignEntityId create(Long prjctIdx, String userId) {
return TPrjctAssignEntityId.builder()
.prjctIdx(prjctIdx)
.userId(userId)
.build();
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, userId);
}
}

View File

@@ -5,13 +5,22 @@ import com.kri.contact.server.common.enums.ProjectStatus;
import com.kri.contact.server.common.enums.SurveyType;
import com.kri.contact.server.dto.ProjectCreateRequestDto;
import com.kri.contact.server.dto.ProjectInfoDto;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -21,146 +30,148 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@Table(name = "t_prjct")
public class TPrjctEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Size(max = 32)
@NotNull
@Column(name = "prjct_cd", nullable = false, length = 32)
private String prjctCd;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@ColumnDefault("0")
@Column(name = "prjct_status", nullable = false)
private Short prjctStatus;
@Size(max = 32)
@NotNull
@Column(name = "prjct_cd", nullable = false, length = 32)
private String prjctCd;
@Size(max = 128)
@NotNull
@Column(name = "prjct_nm", nullable = false, length = 128)
private String prjctNm;
@NotNull
@ColumnDefault("0")
@Column(name = "prjct_status", nullable = false)
private Short prjctStatus;
@Size(max = 32)
@NotNull
@Column(name = "itrnt_prjct_cd", nullable = false, length = 32)
private String itrntPrjctCd;
@Size(max = 128)
@NotNull
@Column(name = "prjct_nm", nullable = false, length = 128)
private String prjctNm;
@Size(max = 32)
@NotNull
@Column(name = "owner_dept", nullable = false, length = 32)
private String ownerDept;
@Size(max = 32)
@NotNull
@Column(name = "itrnt_prjct_cd", nullable = false, length = 32)
private String itrntPrjctCd;
@Size(max = 16)
@NotNull
@Column(name = "owner_fw", nullable = false, length = 16)
private String ownerFw;
@Size(max = 32)
@NotNull
@Column(name = "owner_dept", nullable = false, length = 32)
private String ownerDept;
@NotNull
@ColumnDefault("0")
@Column(name = "survey_ty", nullable = false)
private Short surveyTy;
@Size(max = 16)
@NotNull
@Column(name = "owner_fw", nullable = false, length = 16)
private String ownerFw;
@Size(max = 32)
@Column(name = "survey_prjct_cd", length = 32)
private String surveyPrjctCd;
@NotNull
@ColumnDefault("0")
@Column(name = "survey_ty", nullable = false)
private Short surveyTy;
@Size(max = 128)
@Column(name = "survey_url", length = 128)
private String surveyUrl;
@Size(max = 32)
@Column(name = "survey_prjct_cd", length = 32)
private String surveyPrjctCd;
@NotNull
@ColumnDefault("0")
@Column(name = "is_ff", nullable = false)
private Boolean ff;
@Size(max = 128)
@Column(name = "survey_url", length = 128)
private String surveyUrl;
@NotNull
@ColumnDefault("0")
@Column(name = "is_use_contact_senario", nullable = false)
private Boolean useContactSenario;
@NotNull
@ColumnDefault("0")
@Column(name = "is_ff", nullable = false)
private Boolean ff;
@Lob
@Column(name = "contact_senario")
private String contactSenario;
@NotNull
@ColumnDefault("0")
@Column(name = "is_use_contact_senario", nullable = false)
private Boolean useContactSenario;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Lob
@Column(name = "contact_senario")
private String contactSenario;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("0")
@Column(name = "is_del", nullable = false)
private Boolean del;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "del_user", length = 32)
private String delUser;
@NotNull
@ColumnDefault("0")
@Column(name = "is_del", nullable = false)
private Boolean del;
@Column(name = "del_dt")
private LocalDateTime delDt;
@Size(max = 32)
@Column(name = "del_user", length = 32)
private String delUser;
public static TPrjctEntity fromDto(ProjectInfoDto dto) {
return TPrjctEntity.builder()
.prjctCd(dto.getPrjctCd())
.prjctStatus(dto.getPrjctStatus().getCode())
.prjctNm(dto.getPrjctName())
.itrntPrjctCd(dto.getItrntPrjctCd())
.ownerDept(dto.getOwnerDept())
.ownerFw(dto.getOwnerFw())
.surveyTy(dto.getSurveyTy().getCode())
.surveyPrjctCd(dto.getSurveyPrjctCd())
.surveyUrl(dto.getSurveyUrl())
.ff(dto.getFf())
.useContactSenario(dto.getUseContactSenario())
.contactSenario(dto.getContactSenario())
.regUser(dto.getRegUser())
.regDt(DateTimeUtil.nowKstLocalDateTime())
.build();
}
@Column(name = "del_dt")
private LocalDateTime delDt;
public static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser, LocalDateTime regDt) {
return TPrjctEntity.builder()
.prjctCd(prjctCd)
.prjctStatus(ProjectStatus.STANDBY.getCode())
.prjctNm(req.getPrjctName())
.itrntPrjctCd(req.getItrntPrjctCd())
.ownerDept(req.getOwnerDept())
.ownerFw(req.getOwnerFw())
.surveyTy(SurveyType.NONE.getCode())
.ff(false)
.useContactSenario(false)
.regUser(regUser)
.regDt(regDt)
.del(false)
.build();
}
public static TPrjctEntity fromDto(ProjectInfoDto dto) {
return TPrjctEntity.builder()
.prjctCd(dto.getPrjctCd())
.prjctStatus(dto.getPrjctStatus().getCode())
.prjctNm(dto.getPrjctName())
.itrntPrjctCd(dto.getItrntPrjctCd())
.ownerDept(dto.getOwnerDept())
.ownerFw(dto.getOwnerFw())
.surveyTy(dto.getSurveyTy().getCode())
.surveyPrjctCd(dto.getSurveyPrjctCd())
.surveyUrl(dto.getSurveyUrl())
.ff(dto.getFf())
.useContactSenario(dto.getUseContactSenario())
.contactSenario(dto.getContactSenario())
.regUser(dto.getRegUser())
.regDt(DateTimeUtil.nowKstLocalDateTime())
.build();
}
public void updateFrom(ProjectInfoDto dto, String modUser, LocalDateTime modDt) {
this.prjctNm = dto.getPrjctName();
this.prjctStatus = dto.getPrjctStatus().getCode();
this.ownerDept = dto.getOwnerDept();
this.ownerFw = dto.getOwnerFw();
this.surveyTy = dto.getSurveyTy().getCode();
this.surveyPrjctCd = dto.getSurveyPrjctCd();
this.surveyUrl = dto.getSurveyUrl();
this.ff = dto.getFf();
this.useContactSenario = dto.getUseContactSenario();
this.contactSenario = dto.getContactSenario();
public static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser,
LocalDateTime regDt) {
return TPrjctEntity.builder()
.prjctCd(prjctCd)
.prjctStatus(ProjectStatus.STANDBY.getCode())
.prjctNm(req.getPrjctName())
.itrntPrjctCd(req.getItrntPrjctCd())
.ownerDept(req.getOwnerDept())
.ownerFw(req.getOwnerFw())
.surveyTy(SurveyType.NONE.getCode())
.ff(false)
.useContactSenario(false)
.regUser(regUser)
.regDt(regDt)
.del(false)
.build();
}
this.modUser = modUser;
this.modDt = modDt;
}
public void updateFrom(ProjectInfoDto dto, String modUser, LocalDateTime modDt) {
this.prjctNm = dto.getPrjctName();
this.prjctStatus = dto.getPrjctStatus().getCode();
this.ownerDept = dto.getOwnerDept();
this.ownerFw = dto.getOwnerFw();
this.surveyTy = dto.getSurveyTy().getCode();
this.surveyPrjctCd = dto.getSurveyPrjctCd();
this.surveyUrl = dto.getSurveyUrl();
this.ff = dto.getFf();
this.useContactSenario = dto.getUseContactSenario();
this.contactSenario = dto.getContactSenario();
this.modUser = modUser;
this.modDt = modDt;
}
}

View File

@@ -7,10 +7,13 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -20,38 +23,40 @@ import java.time.LocalDateTime;
@Entity
@Table(name = "t_prjct_main_tmplat")
public class TPrjctMainTmplatEntity {
@EmbeddedId
private TPrjctMainTmplatEntityId id;
@NotNull
@Column(name = "tmplat_idx", nullable = false)
private Long tmplatIdx;
@EmbeddedId
private TPrjctMainTmplatEntityId id;
@NotNull
@Size(max = 32)
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull
@Column(name = "tmplat_idx", nullable = false)
private Long tmplatIdx;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@NotNull
@Size(max = 32)
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
// convenience
public Long getPrjctIdx() {
return id != null ? id.getPrjctIdx() : null;
}
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public Short getChnnlTy() {
return id != null ? id.getChnnlTy() : null;
}
public static TPrjctMainTmplatEntity create(ProjectMainTemplateUpdateRequestDto req,
String regUser, LocalDateTime regDt) {
return TPrjctMainTmplatEntity.builder()
.id(TPrjctMainTmplatEntityId.create(req.getPrjctIdx(), req.getChnnlTy().getCode()))
.tmplatIdx(req.getTmplatIdx())
.regUser(regUser)
.regDt(regDt)
.build();
}
public static TPrjctMainTmplatEntity create(ProjectMainTemplateUpdateRequestDto req, String regUser, LocalDateTime regDt) {
return TPrjctMainTmplatEntity.builder()
.id(TPrjctMainTmplatEntityId.create(req.getPrjctIdx(), req.getChnnlTy().getCode()))
.tmplatIdx(req.getTmplatIdx())
.regUser(regUser)
.regDt(regDt)
.build();
}
// convenience
public Long getPrjctIdx() {
return id != null ? id.getPrjctIdx() : null;
}
public Short getChnnlTy() {
return id != null ? id.getChnnlTy() : null;
}
}

View File

@@ -2,11 +2,14 @@ package com.kri.contact.server.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.*;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter
@Setter
@@ -15,32 +18,37 @@ import java.util.Objects;
@NoArgsConstructor
@AllArgsConstructor
public class TPrjctMainTmplatEntityId implements Serializable {
private static final long serialVersionUID = -263674621497298216L;
@Column(name = "prjct_idx", nullable = false, columnDefinition = "INT UNSIGNED")
private Long prjctIdx;
private static final long serialVersionUID = -263674621497298216L;
@Column(name = "chnnl_ty", nullable = false)
private Short chnnlTy;
@Column(name = "prjct_idx", nullable = false, columnDefinition = "INT UNSIGNED")
private Long prjctIdx;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TPrjctMainTmplatEntityId entity = (TPrjctMainTmplatEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.chnnlTy, entity.chnnlTy);
@Column(name = "chnnl_ty", nullable = false)
private Short chnnlTy;
public static TPrjctMainTmplatEntityId create(Long prjctIdx, Short chnnlTy) {
return TPrjctMainTmplatEntityId.builder()
.prjctIdx(prjctIdx)
.chnnlTy(chnnlTy)
.build();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, chnnlTy);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TPrjctMainTmplatEntityId entity = (TPrjctMainTmplatEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.chnnlTy, entity.chnnlTy);
}
public static TPrjctMainTmplatEntityId create(Long prjctIdx, Short chnnlTy) {
return TPrjctMainTmplatEntityId.builder()
.prjctIdx(prjctIdx)
.chnnlTy(chnnlTy)
.build();
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, chnnlTy);
}
}

View File

@@ -1,6 +1,5 @@
package com.kri.contact.server.persistence.entity;
import com.kri.common.datetime.DateTimeUtil;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.dto.ResultCodeDto;
import jakarta.persistence.Column;
@@ -9,10 +8,13 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -22,57 +24,59 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@Table(name = "t_result_code")
public class TResultCodeEntity {
@EmbeddedId
private TResultCodeEntityId id;
@Size(max = 32)
@NotNull
@Column(name = "result_cd_lbl", nullable = false, length = 32)
private String resultCdLbl;
@EmbeddedId
private TResultCodeEntityId id;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@Size(max = 32)
@NotNull
@Column(name = "result_cd_lbl", nullable = false, length = 32)
private String resultCdLbl;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public ResultCodeType getResultCdTy() {
return id.getResultCdTy();
}
public static TResultCodeEntity copyFromDefault(
TResultCodeEntity src,
Long prjctIdx,
String regUser,
LocalDateTime regDt
) {
return TResultCodeEntity.builder()
.id(TResultCodeEntityId.create(prjctIdx, src.getResultCdTy(), src.getResultCd()))
.resultCdLbl(src.getResultCdLbl())
.regUser(regUser)
.regDt(regDt)
.build();
}
public Short getResultCd() {
return id.getResultCd();
}
public static TResultCodeEntity fromDto(Long prjctIdx, ResultCodeType resultCdTy,
ResultCodeDto req, String regUser, LocalDateTime regDt) {
return TResultCodeEntity.builder()
.id(TResultCodeEntityId.create(prjctIdx, resultCdTy, req.getResultCd()))
.resultCdLbl(req.getResultCdLbl())
.regUser(regUser)
.regDt(regDt)
.build();
public static TResultCodeEntity copyFromDefault(
TResultCodeEntity src,
Long prjctIdx,
String regUser,
LocalDateTime regDt
) {
return TResultCodeEntity.builder()
.id(TResultCodeEntityId.create(prjctIdx, src.getResultCdTy(), src.getResultCd()))
.resultCdLbl(src.getResultCdLbl())
.regUser(regUser)
.regDt(regDt)
.build();
}
}
public static TResultCodeEntity fromDto(Long prjctIdx, ResultCodeType resultCdTy, ResultCodeDto req, String regUser, LocalDateTime regDt) {
return TResultCodeEntity.builder()
.id(TResultCodeEntityId.create(prjctIdx, resultCdTy, req.getResultCd()))
.resultCdLbl(req.getResultCdLbl())
.regUser(regUser)
.regDt(regDt)
.build();
public Long getPrjctIdx() {
return id.getPrjctIdx();
}
}
public ResultCodeType getResultCdTy() {
return id.getResultCdTy();
}
public Short getResultCd() {
return id.getResultCd();
}
}

View File

@@ -1,16 +1,19 @@
package com.kri.contact.server.persistence.entity;
import com.kri.contact.server.common.jpa.ResultCodeTypeConverter;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.common.jpa.ResultCodeTypeConverter;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter
@Setter
@@ -19,39 +22,45 @@ import java.util.Objects;
@NoArgsConstructor
@AllArgsConstructor
public class TResultCodeEntityId implements Serializable {
private static final long serialVersionUID = -1984612223940078355L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "result_cd_ty", nullable = false)
@Convert(converter = ResultCodeTypeConverter.class)
private ResultCodeType resultCdTy;
private static final long serialVersionUID = -1984612223940078355L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull
@Column(name = "result_cd", nullable = false)
private Short resultCd;
@NotNull
@Column(name = "result_cd_ty", nullable = false)
@Convert(converter = ResultCodeTypeConverter.class)
private ResultCodeType resultCdTy;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TResultCodeEntityId entity = (TResultCodeEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.resultCdTy, entity.resultCdTy) &&
Objects.equals(this.resultCd, entity.resultCd);
@NotNull
@Column(name = "result_cd", nullable = false)
private Short resultCd;
public static TResultCodeEntityId create(Long prjctIdx, ResultCodeType resultCdTy,
Short resultCd) {
return TResultCodeEntityId.builder()
.prjctIdx(prjctIdx)
.resultCdTy(resultCdTy)
.resultCd(resultCd)
.build();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, resultCdTy, resultCd);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TResultCodeEntityId entity = (TResultCodeEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
Objects.equals(this.resultCdTy, entity.resultCdTy) &&
Objects.equals(this.resultCd, entity.resultCd);
}
public static TResultCodeEntityId create(Long prjctIdx, ResultCodeType resultCdTy, Short resultCd) {
return TResultCodeEntityId.builder()
.prjctIdx(prjctIdx)
.resultCdTy(resultCdTy)
.resultCd(resultCd)
.build();
}
@Override
public int hashCode() {
return Objects.hash(prjctIdx, resultCdTy, resultCd);
}
}

View File

@@ -1,48 +1,52 @@
package com.kri.contact.server.persistence.entity;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_role")
public class TRoleEntity {
@Id
@Column(name = "role_cd", nullable = false)
private Integer roleCd;
@Size(max = 16)
@NotNull
@Column(name = "role_nm", nullable = false, length = 16)
private String roleNm;
@Id
@Column(name = "role_cd", nullable = false)
private Integer roleCd;
@NotNull
@Lob
@Column(name = "memo", nullable = false)
private String memo;
@Size(max = 16)
@NotNull
@Column(name = "role_nm", nullable = false, length = 16)
private String roleNm;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@Lob
@Column(name = "memo", nullable = false)
private String memo;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
}

View File

@@ -6,35 +6,35 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter
@Setter
@Entity
@Table(name = "t_role_func_map")
public class TRoleFuncMapEntity {
@EmbeddedId
private TRoleFuncMapEntityId id;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@EmbeddedId
private TRoleFuncMapEntityId id;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
public Integer getRoleCd() {
return id.getRoleCd();
}
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public Long getFuncCd() {
return id.getFuncCd();
}
public Integer getRoleCd() {
return id.getRoleCd();
}
public Long getFuncCd() {
return id.getFuncCd();
}
}

View File

@@ -3,38 +3,42 @@ package com.kri.contact.server.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
@Embeddable
public class TRoleFuncMapEntityId implements Serializable {
private static final long serialVersionUID = 5430666726716009453L;
@NotNull
@Column(name = "role_cd", nullable = false)
private Integer roleCd;
@NotNull
@Column(name = "func_cd", nullable = false)
private Long funcCd;
private static final long serialVersionUID = 5430666726716009453L;
@NotNull
@Column(name = "role_cd", nullable = false)
private Integer roleCd;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TRoleFuncMapEntityId entity = (TRoleFuncMapEntityId) o;
return Objects.equals(this.roleCd, entity.roleCd) &&
Objects.equals(this.funcCd, entity.funcCd);
@NotNull
@Column(name = "func_cd", nullable = false)
private Long funcCd;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@Override
public int hashCode() {
return Objects.hash(roleCd, funcCd);
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
TRoleFuncMapEntityId entity = (TRoleFuncMapEntityId) o;
return Objects.equals(this.roleCd, entity.roleCd) &&
Objects.equals(this.funcCd, entity.funcCd);
}
@Override
public int hashCode() {
return Objects.hash(roleCd, funcCd);
}
}

View File

@@ -1,17 +1,24 @@
package com.kri.contact.server.persistence.entity;
import com.kri.common.datetime.DateTimeUtil;
import com.kri.contact.server.common.enums.SystemEventType;
import io.hypersistence.utils.hibernate.type.json.JsonType;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type;
@Getter
@Setter
@@ -21,60 +28,61 @@ import java.util.Map;
@AllArgsConstructor
@Table(name = "t_sys_event_log")
public class TSysEventLogEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "sys_event_log_idx", nullable = false)
private Long sysEventLogIdx;
@NotNull
@Column(name = "event_ty", nullable = false)
private Short eventTy;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "sys_event_log_idx", nullable = false)
private Long sysEventLogIdx;
@Size(max = 128)
@NotNull
@Column(name = "log_title", nullable = false, length = 128)
private String logTitle;
@NotNull
@Column(name = "event_ty", nullable = false)
private Short eventTy;
@NotNull
@Type(JsonType.class)
@Column(name = "log_content", nullable = false)
private Map<String, Object> logContent;
@Size(max = 128)
@NotNull
@Column(name = "log_title", nullable = false, length = 128)
private String logTitle;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED")
private Long prjctIdx;
@NotNull
@Type(JsonType.class)
@Column(name = "log_content", nullable = false)
private Map<String, Object> logContent;
@Size(max = 16)
@NotNull
@Column(name = "ip", nullable = false, length = 16)
private String ip;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED")
private Long prjctIdx;
@Size(max = 16)
@NotNull
@Column(name = "reg_user", nullable = false, length = 16)
private String regUser;
@Size(max = 16)
@NotNull
@Column(name = "ip", nullable = false, length = 16)
private String ip;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Size(max = 16)
@NotNull
@Column(name = "reg_user", nullable = false, length = 16)
private String regUser;
public static TSysEventLogEntity of(
SystemEventType eventTy,
String logTitle,
Map<String, Object> logContent,
Long prjctIdx,
String ip,
String regUser,
LocalDateTime regDt
) {
return TSysEventLogEntity.builder()
.eventTy(eventTy.getCode())
.logTitle(logTitle)
.logContent(logContent)
.prjctIdx(prjctIdx)
.ip(ip)
.regUser(regUser)
.regDt(regDt)
.build();
}
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public static TSysEventLogEntity of(
SystemEventType eventTy,
String logTitle,
Map<String, Object> logContent,
Long prjctIdx,
String ip,
String regUser,
LocalDateTime regDt
) {
return TSysEventLogEntity.builder()
.eventTy(eventTy.getCode())
.logTitle(logTitle)
.logContent(logContent)
.prjctIdx(prjctIdx)
.ip(ip)
.regUser(regUser)
.regDt(regDt)
.build();
}
}

View File

@@ -1,14 +1,22 @@
package com.kri.contact.server.persistence.entity;
import com.kri.common.datetime.DateTimeUtil;
import com.kri.contact.server.dto.UserInfoDto;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -18,105 +26,106 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@Table(name = "t_user")
public class TUserEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_idx", columnDefinition = "int UNSIGNED not null")
private Long userIdx;
@Size(max = 32)
@NotNull
@Column(name = "user_id", nullable = false, length = 32, updatable = false)
private String userId;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_idx", columnDefinition = "int UNSIGNED not null")
private Long userIdx;
@Size(max = 128)
@NotNull
@Column(name = "user_pw", nullable = false, length = 128)
private String userPw;
@Size(max = 32)
@NotNull
@Column(name = "user_id", nullable = false, length = 32, updatable = false)
private String userId;
@Size(max = 32)
@NotNull
@ColumnDefault("'KRI'")
@Column(name = "user_cmpn", nullable = false, length = 32, updatable = false)
private String userCmpn;
@Size(max = 128)
@NotNull
@Column(name = "user_pw", nullable = false, length = 128)
private String userPw;
@Size(max = 32)
@NotNull
@Column(name = "user_nm", nullable = false, length = 32)
private String userNm;
@Size(max = 32)
@NotNull
@ColumnDefault("'KRI'")
@Column(name = "user_cmpn", nullable = false, length = 32, updatable = false)
private String userCmpn;
@Size(max = 32)
@NotNull
@ColumnDefault("'S101'")
@Column(name = "user_team", nullable = false, length = 32, updatable = false)
private String userTeam;
@Size(max = 32)
@NotNull
@Column(name = "user_nm", nullable = false, length = 32)
private String userNm;
@NotNull
@Column(name = "user_role", nullable = false)
private Integer userRole;
@Size(max = 32)
@NotNull
@ColumnDefault("'S101'")
@Column(name = "user_team", nullable = false, length = 32, updatable = false)
private String userTeam;
@NotNull
@Lob
@Column(name = "memo", nullable = false)
private String memo;
@NotNull
@Column(name = "user_role", nullable = false)
private Integer userRole;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@Lob
@Column(name = "memo", nullable = false)
private String memo;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt")
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull
@ColumnDefault("0")
@Column(name = "is_del", nullable = false)
private Boolean del = false;
@Column(name = "mod_dt")
private LocalDateTime modDt;
@Size(max = 32)
@Column(name = "del_user", length = 32)
private String delUser;
@NotNull
@ColumnDefault("0")
@Column(name = "is_del", nullable = false)
private Boolean del = false;
@Column(name = "del_dt")
private LocalDateTime delDt;
@Size(max = 32)
@Column(name = "del_user", length = 32)
private String delUser;
public static TUserEntity fromDto(UserInfoDto dto, String regUser, LocalDateTime regDt) {
return TUserEntity.builder()
.userId(dto.getUserId())
.userPw(dto.getUserPw())
.userNm(dto.getUserName())
.userCmpn(dto.getUserCmpn())
.userTeam(
dto.getUserTeam() != null && !dto.getUserTeam().isBlank()
? dto.getUserTeam()
: "S101" // DB 기본값과 맞춰서 디폴트 세팅
)
.userRole(dto.getUserRole())
.memo(dto.getMemo() != null ? dto.getMemo() : "")
.regUser(regUser)
.regDt(regDt)
.build();
@Column(name = "del_dt")
private LocalDateTime delDt;
public static TUserEntity fromDto(UserInfoDto dto, String regUser, LocalDateTime regDt) {
return TUserEntity.builder()
.userId(dto.getUserId())
.userPw(dto.getUserPw())
.userNm(dto.getUserName())
.userCmpn(dto.getUserCmpn())
.userTeam(
dto.getUserTeam() != null && !dto.getUserTeam().isBlank()
? dto.getUserTeam()
: "S101" // DB 기본값과 맞춰서 디폴트 세팅
)
.userRole(dto.getUserRole())
.memo(dto.getMemo() != null ? dto.getMemo() : "")
.regUser(regUser)
.regDt(regDt)
.build();
}
public void updateFromDto(UserInfoDto dto, String modUser, LocalDateTime modDt) {
// 비번은 값이 있을 때만 변경
if (dto.getUserPw() != null && !dto.getUserPw().isBlank()) {
this.userPw = dto.getUserPw();
}
public void updateFromDto(UserInfoDto dto, String modUser, LocalDateTime modDt) {
// 비번은 값이 있을 때만 변경
if (dto.getUserPw() != null && !dto.getUserPw().isBlank()) {
this.userPw = dto.getUserPw();
}
this.userNm = dto.getUserName();
this.userRole = dto.getUserRole();
this.memo = (dto.getMemo() != null) ? dto.getMemo() : "";
this.userNm = dto.getUserName();
this.userRole = dto.getUserRole();
this.memo = (dto.getMemo() != null) ? dto.getMemo() : "";
this.modUser = modUser;
this.modDt = modDt;
}
this.modUser = modUser;
this.modDt = modDt;
}
}

View File

@@ -1,21 +1,22 @@
package com.kri.contact.server.persistence.query;
import org.springframework.data.domain.*;
import org.springframework.data.domain.Sort;
public class ProjectSorts {
public static Sort toSort(String sortBy, String sortDir) {
String prop = switch (sortBy) {
case "prjctIdx" -> "prjctIdx";
case "prjctCd" -> "prjctCd";
case "prjctName" -> "prjctNm";
case "prjctStatus" -> "prjctStatus";
case "ownerDept" -> "ownerDept";
case "ownerFw" -> "ownerFw";
case "regDt" -> "regDt";
default -> "prjctCd"; // fallback
};
Sort.Direction dir = "asc".equalsIgnoreCase(sortDir) ? Sort.Direction.ASC : Sort.Direction.DESC;
return Sort.by(dir, prop);
}
public static Sort toSort(String sortBy, String sortDir) {
String prop = switch (sortBy) {
case "prjctIdx" -> "prjctIdx";
case "prjctCd" -> "prjctCd";
case "prjctName" -> "prjctNm";
case "prjctStatus" -> "prjctStatus";
case "ownerDept" -> "ownerDept";
case "ownerFw" -> "ownerFw";
case "regDt" -> "regDt";
default -> "prjctCd"; // fallback
};
Sort.Direction dir = "asc".equalsIgnoreCase(sortDir) ? Sort.Direction.ASC : Sort.Direction.DESC;
return Sort.by(dir, prop);
}
}

View File

@@ -4,66 +4,73 @@ import com.kri.contact.server.persistence.entity.TPrjctAssignEntity;
import com.kri.contact.server.persistence.entity.TPrjctEntity;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import java.util.List;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.StringUtils;
import java.util.List;
public class ProjectSpecs {
public static Specification<TPrjctEntity> isDelFalse() {
return (root, query, cb) -> cb.equal(root.get("del"), false);
}
public static Specification<TPrjctEntity> isDelFalse() {
return (root, query, cb) -> cb.equal(root.get("del"), false);
}
public static Specification<TPrjctEntity> keywordLike(String searchText) {
return (root, query, cb) -> {
if (!StringUtils.hasText(searchText)) return cb.conjunction();
String like = "%" + searchText.trim() + "%";
public static Specification<TPrjctEntity> keywordLike(String searchText) {
return (root, query, cb) -> {
if (!StringUtils.hasText(searchText)) {
return cb.conjunction();
}
String like = "%" + searchText.trim() + "%";
return cb.or(
cb.like(root.get("prjctCd"), like),
cb.like(root.get("prjctNm"), like) // 엔티티 필드명에 맞추기
);
};
}
return cb.or(
cb.like(root.get("prjctCd"), like),
cb.like(root.get("prjctNm"), like) // 엔티티 필드명에 맞추기
);
};
}
public static Specification<TPrjctEntity> statusIn(List<Short> list) {
return (root, query, cb) -> {
if (list == null || list.isEmpty()) return cb.conjunction();
return root.get("prjctStatus").in(list);
};
}
public static Specification<TPrjctEntity> statusIn(List<Short> list) {
return (root, query, cb) -> {
if (list == null || list.isEmpty()) {
return cb.conjunction();
}
return root.get("prjctStatus").in(list);
};
}
public static Specification<TPrjctEntity> ownerDeptIn(List<String> list) {
return (root, query, cb) -> {
if (list == null || list.isEmpty()) return cb.conjunction();
return root.get("ownerDept").in(list);
};
}
public static Specification<TPrjctEntity> ownerDeptIn(List<String> list) {
return (root, query, cb) -> {
if (list == null || list.isEmpty()) {
return cb.conjunction();
}
return root.get("ownerDept").in(list);
};
}
public static Specification<TPrjctEntity> ownerFwIn(List<String> list) {
return (root, query, cb) -> {
if (list == null || list.isEmpty()) return cb.conjunction();
return root.get("ownerFw").in(list);
};
}
public static Specification<TPrjctEntity> ownerFwIn(List<String> list) {
return (root, query, cb) -> {
if (list == null || list.isEmpty()) {
return cb.conjunction();
}
return root.get("ownerFw").in(list);
};
}
public static Specification<TPrjctEntity> assignedToUserAndNotExcluded(String userId) {
return (root, query, cb) -> {
if (userId == null || userId.isBlank()) {
return cb.disjunction(); // 외부유저인데 userId 없으면 아무것도 안 보이게(안전)
}
public static Specification<TPrjctEntity> assignedToUserAndNotExcluded(String userId) {
return (root, query, cb) -> {
if (userId == null || userId.isBlank()) {
return cb.disjunction(); // 외부유저인데 userId 없으면 아무것도 안 보이게(안전)
}
var sub = query.subquery(Integer.class);
Root<TPrjctAssignEntity> a = sub.from(TPrjctAssignEntity.class);
var sub = query.subquery(Integer.class);
Root<TPrjctAssignEntity> a = sub.from(TPrjctAssignEntity.class);
// exists (select 1 from t_prjct_assign a where a.prjct_idx = root.prjctIdx and a.userId = ? and a.excDt is null)
Predicate p1 = cb.equal(a.get("id").get("prjctIdx"), root.get("prjctIdx"));
Predicate p2 = cb.equal(a.get("id").get("userId"), userId);
// exists (select 1 from t_prjct_assign a where a.prjct_idx = root.prjctIdx and a.userId = ? and a.excDt is null)
Predicate p1 = cb.equal(a.get("id").get("prjctIdx"), root.get("prjctIdx"));
Predicate p2 = cb.equal(a.get("id").get("userId"), userId);
sub.select(cb.literal(1)).where(p1, p2);
sub.select(cb.literal(1)).where(p1, p2);
return cb.exists(sub);
};
}
return cb.exists(sub);
};
}
}

View File

@@ -2,37 +2,38 @@ package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TPrjctAssignEntity;
import com.kri.contact.server.persistence.entity.TPrjctAssignEntityId;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface ProjectAssignRepository extends
JpaRepository<TPrjctAssignEntity, TPrjctAssignEntityId>,
JpaSpecificationExecutor<TPrjctAssignEntity> {
public interface ProjectAssignRepository extends JpaRepository<TPrjctAssignEntity, TPrjctAssignEntityId>, JpaSpecificationExecutor<TPrjctAssignEntity> {
@Query("""
select a.id.userId
from TPrjctAssignEntity a
join TUserEntity u on u.userId = a.id.userId
where a.id.prjctIdx = :prjctIdx
and u.del = false
and u.userRole >= :startRole
and u.userRole < :endRole
""")
List<String> findAssignUserIdByPrjctIdxAndRoleRange(Long prjctIdx, int startRole, int endRole);
@Query("""
select a.id.userId
from TPrjctAssignEntity a
join TUserEntity u on u.userId = a.id.userId
where a.id.prjctIdx = :prjctIdx
and u.del = false
and u.userRole >= :startRole
and u.userRole < :endRole
""")
List<String> findAssignUserIdByPrjctIdxAndRoleRange(Long prjctIdx, int startRole, int endRole);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query(value = """
delete from TPrjctAssignEntity a
where a.id.prjctIdx = :prjctIdx
and a.id.userId in (
select u.userId
from TUserEntity u
where 1=1
and u.userRole >= :startRole
and u.userRole < :endRole
)
""")
int deleteAssignByPrjctIdxAndRoleRange(Long prjctIdx, int startRole, int endRole);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query(value = """
delete from TPrjctAssignEntity a
where a.id.prjctIdx = :prjctIdx
and a.id.userId in (
select u.userId
from TUserEntity u
where 1=1
and u.userRole >= :startRole
and u.userRole < :endRole
)
""")
int deleteAssignByPrjctIdxAndRoleRange(Long prjctIdx, int startRole, int endRole);
}

View File

@@ -2,14 +2,15 @@ package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntity;
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntityId;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Optional;
public interface ProjectMainTemplateRepository extends
JpaRepository<TPrjctMainTmplatEntity, TPrjctMainTmplatEntityId>,
JpaSpecificationExecutor<TPrjctMainTmplatEntity> {
public interface ProjectMainTemplateRepository extends JpaRepository<TPrjctMainTmplatEntity, TPrjctMainTmplatEntityId>, JpaSpecificationExecutor<TPrjctMainTmplatEntity> {
Optional<TPrjctMainTmplatEntity> findByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
Optional<TPrjctMainTmplatEntity> findByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
long deleteByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
long deleteByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
}

View File

@@ -1,46 +1,46 @@
package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TPrjctEntity;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDateTime;
import java.util.List;
public interface ProjectRepository extends JpaRepository<TPrjctEntity, Long>,
JpaSpecificationExecutor<TPrjctEntity> {
public interface ProjectRepository extends JpaRepository<TPrjctEntity, Long>, JpaSpecificationExecutor<TPrjctEntity> {
List<TPrjctEntity> findByItrntPrjctCd(String itrntPrjctCd);
List<TPrjctEntity> findByItrntPrjctCd(String itrntPrjctCd);
TPrjctEntity findByPrjctIdxAndDelFalse(Long prjctIdx);
TPrjctEntity findByPrjctIdxAndDelFalse(Long prjctIdx);
@Query("""
select distinct p.ownerDept
from TPrjctEntity p
where p.del = false
and (:statusList is null or p.prjctStatus in :statusList)
order by p.ownerDept
""")
List<String> findDistinctOwnerDept(List<Short> statusList);
@Query("""
select distinct p.ownerDept
from TPrjctEntity p
where p.del = false
and (:statusList is null or p.prjctStatus in :statusList)
order by p.ownerDept
""")
List<String> findDistinctOwnerDept(List<Short> statusList);
@Query("""
select distinct p.ownerFw
from TPrjctEntity p
where p.del = false
and (:statusList is null or p.prjctStatus in :statusList)
order by p.ownerDept
""")
List<String> findDistinctOwnerFw(List<Short> statusList);
@Query("""
select distinct p.ownerFw
from TPrjctEntity p
where p.del = false
and (:statusList is null or p.prjctStatus in :statusList)
order by p.ownerDept
""")
List<String> findDistinctOwnerFw(List<Short> statusList);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
update TPrjctEntity u
set u.del = true,
u.delUser = :delUser,
u.delDt = :delDt
where u.prjctIdx = :prjctIdx
and u.del = false
""")
int softDeleteByPrjctIdx(Long prjctIdx, String delUser, LocalDateTime delDt);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
update TPrjctEntity u
set u.del = true,
u.delUser = :delUser,
u.delDt = :delDt
where u.prjctIdx = :prjctIdx
and u.del = false
""")
int softDeleteByPrjctIdx(Long prjctIdx, String delUser, LocalDateTime delDt);
}

View File

@@ -4,25 +4,26 @@ package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.persistence.entity.TResultCodeEntity;
import com.kri.contact.server.persistence.entity.TResultCodeEntityId;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface ResultCodeRepository extends JpaRepository<TResultCodeEntity, TResultCodeEntityId>,
JpaSpecificationExecutor<TResultCodeEntity> {
public interface ResultCodeRepository extends JpaRepository<TResultCodeEntity, TResultCodeEntityId>, JpaSpecificationExecutor<TResultCodeEntity> {
@Query("""
select r
from TResultCodeEntity r
where r.id.prjctIdx = 0
""")
List<TResultCodeEntity> findDefault();
@Query("""
select r
from TResultCodeEntity r
where r.id.prjctIdx = 0
""")
List<TResultCodeEntity> findDefault();
List<TResultCodeEntity> findByIdPrjctIdx(Long prjctIdx);
List<TResultCodeEntity> findByIdPrjctIdx(Long prjctIdx);
List<TResultCodeEntity> findByIdPrjctIdxAndIdResultCdTy(Long prjctIdx, Short resultCdTy);
List<TResultCodeEntity> findByIdPrjctIdxAndIdResultCdTy(Long prjctIdx, Short resultCdTy);
long deleteByIdPrjctIdx(Long prjctIdx);
long deleteByIdPrjctIdx(Long prjctIdx);
long deleteByIdPrjctIdxAndIdResultCdTy(Long prjctIdx, ResultCodeType resultCdTy);
long deleteByIdPrjctIdxAndIdResultCdTy(Long prjctIdx, ResultCodeType resultCdTy);
}

View File

@@ -1,11 +1,12 @@
package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TRoleEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
public interface RoleRepository extends JpaRepository<TRoleEntity, Integer>,
JpaSpecificationExecutor<TRoleEntity> {
public interface RoleRepository extends JpaRepository<TRoleEntity, Integer>, JpaSpecificationExecutor<TRoleEntity> {
List<TRoleEntity> findByRoleCdGreaterThanEqual(Integer roleCd);
List<TRoleEntity> findByRoleCdGreaterThanEqual(Integer roleCd);
}

View File

@@ -4,5 +4,7 @@ import com.kri.contact.server.persistence.entity.TSysEventLogEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface SystemEventLogRepository extends JpaRepository<TSysEventLogEntity, Long>, JpaSpecificationExecutor<TSysEventLogEntity> {
public interface SystemEventLogRepository extends JpaRepository<TSysEventLogEntity, Long>,
JpaSpecificationExecutor<TSysEventLogEntity> {
}

View File

@@ -1,63 +1,65 @@
package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TUserEntity;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
public interface UserRepository extends JpaRepository<TUserEntity, Long>,
JpaSpecificationExecutor<TUserEntity> {
public interface UserRepository extends JpaRepository<TUserEntity, Long>, JpaSpecificationExecutor<TUserEntity> {
Optional<TUserEntity> findByUserIdAndUserPwAndDelFalse(String userId, String userPw);
Optional<TUserEntity> findByUserIdAndUserPwAndDelFalse(String userId, String userPw);
Optional<TUserEntity> findByUserIdAndDelFalse(String userId);
Optional<TUserEntity> findByUserIdAndDelFalse(String userId);
List<TUserEntity> findByDelFalse();
List<TUserEntity> findByDelFalse();
List<TUserEntity> findByUserRoleGreaterThanEqualAndDelFalse(Integer userRoleCd);
List<TUserEntity> findByUserRoleGreaterThanEqualAndDelFalse(Integer userRoleCd);
List<TUserEntity> findByUserCmpnAndUserRoleGreaterThanEqualAndDelFalse(String userCmpn, Integer userRoleCd);
List<TUserEntity> findByUserCmpnAndUserRoleGreaterThanEqualAndDelFalse(String userCmpn,
Integer userRoleCd);
@Query("""
select u
from TUserEntity u
where u.del = false
and u.userRole >= :startRole
and u.userRole < :endRole
""")
List<TUserEntity> findByRoleRangeAndDelFalse(int startRole, int endRole);
@Query("""
select u
from TUserEntity u
where u.del = false
and u.userRole >= :startRole
and u.userRole < :endRole
""")
List<TUserEntity> findByRoleRangeAndDelFalse(int startRole, int endRole);
@Query("""
select u.userId
from TUserEntity u
where u.del = false
and u.userRole >= :startRole
and u.userRole < :endRole
""")
List<TUserEntity> findUserIdByRoleRangeAndDelFalse(int startRole, int endRole);
@Query("""
select u.userId
from TUserEntity u
where u.del = false
and u.userRole >= :startRole
and u.userRole < :endRole
""")
List<TUserEntity> findUserIdByRoleRangeAndDelFalse(int startRole, int endRole);
@Query("""
select distinct u.userCmpn
from TUserEntity u
where u.userCmpn is not null and u.userCmpn <> ''
@Query("""
select distinct u.userCmpn
from TUserEntity u
where u.userCmpn is not null and u.userCmpn <> ''
and u.del = false
order by u.userCmpn
""")
List<String> findDistinctUserCmpnAndDelFalse();
boolean existsByUserIdAndDelFalse(String userId);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
update TUserEntity u
set u.del = true,
u.delUser = :delUser,
u.delDt = :delDt
where u.userId = :userId
and u.del = false
order by u.userCmpn
""")
List<String> findDistinctUserCmpnAndDelFalse();
boolean existsByUserIdAndDelFalse(String userId);
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
update TUserEntity u
set u.del = true,
u.delUser = :delUser,
u.delDt = :delDt
where u.userId = :userId
and u.del = false
""")
int softDeleteByUserId(String userId, String delUser, LocalDateTime delDt);
""")
int softDeleteByUserId(String userId, String delUser, LocalDateTime delDt);
}

View File

@@ -1,91 +1,92 @@
package com.kri.contact.server.scheduler;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Duration;
import java.time.Instant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Duration;
import java.time.Instant;
@Slf4j
@Component
public class TempFileCleanupScheduler {
private final Path uploadBaseDir;
private final Duration expireDuration;
private final Path uploadBaseDir;
private final Duration expireDuration;
public TempFileCleanupScheduler(
@Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDirStr,
@Value("${kri.contact-senario.temp-expire-hours:24}") long expireHours
) {
this.uploadBaseDir = Paths.get(uploadBaseDirStr);
this.expireDuration = Duration.ofHours(expireHours);
public TempFileCleanupScheduler(
@Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDirStr,
@Value("${kri.contact-senario.temp-expire-hours:24}") long expireHours
) {
this.uploadBaseDir = Paths.get(uploadBaseDirStr);
this.expireDuration = Duration.ofHours(expireHours);
}
/**
* 매일 자정(00:00)에 실행. 필요하면 application.yml 에서 kri.contact-senario.temp-cleanup-cron 으로 변경 가능.
*/
@Scheduled(cron = "${kri.contact-senario.temp-cleanup-cron:0 0 0 * * *}")
public void cleanupOldTempFiles() {
if (!Files.isDirectory(uploadBaseDir)) {
log.warn("[TempCleanup] uploadBaseDir({}) 가 디렉토리가 아닙니다.", uploadBaseDir);
return;
}
/**
* 매일 자정(00:00)에 실행.
* 필요하면 application.yml 에서 kri.contact-senario.temp-cleanup-cron 으로 변경 가능.
*/
@Scheduled(cron = "${kri.contact-senario.temp-cleanup-cron:0 0 0 * * *}")
public void cleanupOldTempFiles() {
if (!Files.isDirectory(uploadBaseDir)) {
log.warn("[TempCleanup] uploadBaseDir({}) 가 디렉토리가 아닙니다.", uploadBaseDir);
return;
Instant now = Instant.now();
Instant threshold = now.minus(expireDuration);
log.info("[TempCleanup] 시작 - baseDir={}, threshold={}", uploadBaseDir, threshold);
try (DirectoryStream<Path> projectDirs = Files.newDirectoryStream(uploadBaseDir)) {
for (Path projectDir : projectDirs) {
if (!Files.isDirectory(projectDir)) {
continue;
}
Instant now = Instant.now();
Instant threshold = now.minus(expireDuration);
log.info("[TempCleanup] 시작 - baseDir={}, threshold={}", uploadBaseDir, threshold);
try (DirectoryStream<Path> projectDirs = Files.newDirectoryStream(uploadBaseDir)) {
for (Path projectDir : projectDirs) {
if (!Files.isDirectory(projectDir)) {
continue;
}
Path tempDir = projectDir.resolve("Temp"); // {prjctCd}/Temp
if (!Files.isDirectory(tempDir)) {
continue;
}
cleanupTempDir(tempDir, threshold);
}
} catch (IOException e) {
log.error("[TempCleanup] baseDir 스캔 중 오류 - baseDir={}", uploadBaseDir, e);
Path tempDir = projectDir.resolve("Temp"); // {prjctCd}/Temp
if (!Files.isDirectory(tempDir)) {
continue;
}
log.info("[TempCleanup] 종료");
cleanupTempDir(tempDir, threshold);
}
} catch (IOException e) {
log.error("[TempCleanup] baseDir 스캔 중 오류 - baseDir={}", uploadBaseDir, e);
}
private void cleanupTempDir(Path tempDir, Instant threshold) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(tempDir)) {
for (Path file : stream) {
if (!Files.isRegularFile(file)) {
continue;
}
log.info("[TempCleanup] 종료");
}
try {
BasicFileAttributes attrs =
Files.readAttributes(file, BasicFileAttributes.class);
// 생성 시간(지원 안 하면 마지막 수정 시간)을 기준으로 비교
Instant created = attrs.creationTime() != null
? attrs.creationTime().toInstant()
: attrs.lastModifiedTime().toInstant();
if (created.isBefore(threshold)) {
Files.deleteIfExists(file);
log.debug("[TempCleanup] 삭제: {} (created={})", file, created);
}
} catch (IOException ex) {
log.warn("[TempCleanup] 파일 삭제 실패: {}", file, ex);
}
}
} catch (IOException e) {
log.warn("[TempCleanup] temp 디렉토리 스캔 실패: {}", tempDir, e);
private void cleanupTempDir(Path tempDir, Instant threshold) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(tempDir)) {
for (Path file : stream) {
if (!Files.isRegularFile(file)) {
continue;
}
try {
BasicFileAttributes attrs =
Files.readAttributes(file, BasicFileAttributes.class);
// 생성 시간(지원 안 하면 마지막 수정 시간)을 기준으로 비교
Instant created = attrs.creationTime() != null
? attrs.creationTime().toInstant()
: attrs.lastModifiedTime().toInstant();
if (created.isBefore(threshold)) {
Files.deleteIfExists(file);
log.debug("[TempCleanup] 삭제: {} (created={})", file, created);
}
} catch (IOException ex) {
log.warn("[TempCleanup] 파일 삭제 실패: {}", file, ex);
}
}
} catch (IOException e) {
log.warn("[TempCleanup] temp 디렉토리 스캔 실패: {}", tempDir, e);
}
}
}

View File

@@ -1,77 +1,80 @@
package com.kri.contact.server.service;
import com.kri.common.datetime.DateTimeUtil;
import com.kri.contact.server.common.consts.ContactConstant;
import com.kri.contact.server.persistence.entity.TPrjctAssignEntity;
import com.kri.contact.server.persistence.repository.ProjectAssignRepository;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
@Service
@RequiredArgsConstructor
public class AssignService {
private final ProjectAssignRepository projectAssignRepository;
private final ProjectAssignRepository projectAssignRepository;
public List<String> getPrjctOutsourceAssign(Long prjctIdx) {
return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
);
public List<String> getPrjctOutsourceAssign(Long prjctIdx) {
return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
);
}
public List<String> getPrjctFieldworkAssign(Long prjctIdx) {
return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.FIELDWORK_USER_ROLE,
ContactConstant.FIELDWORK_USER_ROLE + 1000
);
}
@Transactional
public void upsertPrjctOutsourceAssign(Long prjctIdx, List<String> assignUserIdList,
String regUser, LocalDateTime regDt) {
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
);
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt);
}
@Transactional
public void upsertPrjctFieldworkAssign(Long prjctIdx, List<String> assignUserIdList,
String regUser, LocalDateTime regDt) {
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.FIELDWORK_USER_ROLE,
ContactConstant.FIELDWORK_USER_ROLE + 1000
);
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt);
}
private void insertPrjctAssign(Long prjctIdx, List<String> assignUserIdList, String regUser,
LocalDateTime regDt) {
if (assignUserIdList == null || assignUserIdList.isEmpty()) {
return;
}
public List<String> getPrjctFieldworkAssign(Long prjctIdx) {
return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.FIELDWORK_USER_ROLE,
ContactConstant.FIELDWORK_USER_ROLE + 1000
);
List<String> normalized = assignUserIdList.stream()
.filter(s -> s != null && !s.isBlank())
.map(String::trim)
.distinct()
.toList();
if (normalized.isEmpty()) {
return;
}
@Transactional
public void upsertPrjctOutsourceAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt) {
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
);
List<TPrjctAssignEntity> entities = normalized.stream()
.map(uid -> TPrjctAssignEntity.create(prjctIdx, uid, regUser, regDt))
.toList();
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt);
}
@Transactional
public void upsertPrjctFieldworkAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt) {
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange(
prjctIdx,
ContactConstant.FIELDWORK_USER_ROLE,
ContactConstant.FIELDWORK_USER_ROLE + 1000
);
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt);
}
private void insertPrjctAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt) {
if (assignUserIdList == null || assignUserIdList.isEmpty()) {
return;
}
List<String> normalized = assignUserIdList.stream()
.filter(s -> s != null && !s.isBlank())
.map(String::trim)
.distinct()
.toList();
if (normalized.isEmpty()) return;
List<TPrjctAssignEntity> entities = normalized.stream()
.map(uid -> TPrjctAssignEntity.create(prjctIdx, uid, regUser, regDt))
.toList();
projectAssignRepository.saveAll(entities);
}
projectAssignRepository.saveAll(entities);
}
}

View File

@@ -1,11 +1,11 @@
package com.kri.contact.server.service;
import com.kri.common.auth.jwt.JwtService;
import com.kri.common.auth.dto.JwtUserClaimsDto;
import com.kri.contact.server.dto.LoginRequestDto;
import com.kri.contact.server.dto.LoginResponseDto;
import com.kri.common.auth.jwt.JwtService;
import com.kri.contact.server.common.external.intranet.IntranetExtensionApiClient;
import com.kri.contact.server.common.external.intranet.SearchLoginInfoResponseDto;
import com.kri.contact.server.dto.LoginRequestDto;
import com.kri.contact.server.dto.LoginResponseDto;
import com.kri.contact.server.persistence.entity.TUserEntity;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -13,36 +13,37 @@ import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class AuthService {
private final JwtService jwtService;
private final UserService userService;
private final IntranetExtensionApiClient intranetExtensionApiClient;
private final JwtService jwtService;
private final UserService userService;
private final IntranetExtensionApiClient intranetExtensionApiClient;
public LoginResponseDto tryLogin(LoginRequestDto request) {
SearchLoginInfoResponseDto loginInfoResponse = intranetExtensionApiClient.searchLoginInfo(request);
public LoginResponseDto tryLogin(LoginRequestDto request) {
SearchLoginInfoResponseDto loginInfoResponse = intranetExtensionApiClient.searchLoginInfo(
request);
JwtUserClaimsDto claims;
if(loginInfoResponse != null) {
claims = JwtUserClaimsDto.builder()
.userId(loginInfoResponse.getUserId())
.userCmpn(loginInfoResponse.getUserCmpn())
.userName(loginInfoResponse.getUserNm())
.userTeam(loginInfoResponse.getUserTeam())
.userRole(loginInfoResponse.getUserRole())
.build();
}
else{
TUserEntity user = userService.getUser(request.getUserId(), request.getUserPw());
claims = JwtUserClaimsDto.builder()
.userId(user.getUserId())
.userCmpn(user.getUserCmpn())
.userName(user.getUserNm())
.userTeam(user.getUserTeam())
.userRole(user.getUserRole())
.build();
}
String accessToken = jwtService.generateAccessToken(claims);
return LoginResponseDto.from(accessToken, claims);
JwtUserClaimsDto claims;
if (loginInfoResponse != null) {
claims = JwtUserClaimsDto.builder()
.userId(loginInfoResponse.getUserId())
.userCmpn(loginInfoResponse.getUserCmpn())
.userName(loginInfoResponse.getUserNm())
.userTeam(loginInfoResponse.getUserTeam())
.userRole(loginInfoResponse.getUserRole())
.build();
} else {
TUserEntity user = userService.getUser(request.getUserId(), request.getUserPw());
claims = JwtUserClaimsDto.builder()
.userId(user.getUserId())
.userCmpn(user.getUserCmpn())
.userName(user.getUserNm())
.userTeam(user.getUserTeam())
.userRole(user.getUserRole())
.build();
}
String accessToken = jwtService.generateAccessToken(claims);
return LoginResponseDto.from(accessToken, claims);
}
}

View File

@@ -2,6 +2,15 @@ package com.kri.contact.server.service;
import com.kri.common.file.FileUtil;
import com.kri.common.util.CommonUtil;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -12,155 +21,160 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.file.*;
import java.util.*;
@Service
public class FileService {
private static final Logger log = LoggerFactory.getLogger(FileService.class);
private final Path uploadBaseDir; // ex) /data/upload-file/contact-senario
private final String publicBaseUrlPrefix; // ex) /upload-file/contact-senario
public FileService(
@Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDir,
@Value("${kri.contact-senario.public-base-url}") String publicBaseUrlPrefix
) {
this.uploadBaseDir = Paths.get(uploadBaseDir).toAbsolutePath().normalize();
this.publicBaseUrlPrefix = publicBaseUrlPrefix.endsWith("/")
? publicBaseUrlPrefix.substring(0, publicBaseUrlPrefix.length() - 1)
: publicBaseUrlPrefix;
private static final Logger log = LoggerFactory.getLogger(FileService.class);
private final Path uploadBaseDir; // ex) /data/upload-file/contact-senario
private final String publicBaseUrlPrefix; // ex) /upload-file/contact-senario
public FileService(
@Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDir,
@Value("${kri.contact-senario.public-base-url}") String publicBaseUrlPrefix
) {
this.uploadBaseDir = Paths.get(uploadBaseDir).toAbsolutePath().normalize();
this.publicBaseUrlPrefix = publicBaseUrlPrefix.endsWith("/")
? publicBaseUrlPrefix.substring(0, publicBaseUrlPrefix.length() - 1)
: publicBaseUrlPrefix;
}
/**
* Temp에 파일 저장 후, public URL 반환
*/
public String storeTempFile(String prjctCd, MultipartFile file) {
try {
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
String ext = "";
int dot = original.lastIndexOf('.');
if (dot > 0 && dot < original.length() - 1) {
ext = original.substring(dot);
}
String newName = CommonUtil.uuid32() + ext;
Path tempDir = getTempDir(prjctCd);
Files.createDirectories(tempDir);
Path target = tempDir.resolve(newName);
file.transferTo(target.toFile());
// 브라우저에서 사용할 URL
return publicBaseUrlPrefix + "/" + prjctCd + "/Temp/" + newName;
} catch (IOException e) {
throw new RuntimeException("파일 저장 실패", e);
}
}
/**
* 컨택 시나리오 저장 시: 1) HTML 내 Temp 이미지 -> Asset으로 이동 & src 수정 2) Asset 디렉토리에서 더 이상 사용되지 않는 파일 삭제 3)
* 정리된 HTML 반환
*/
public String syncOnSave(String prjctCd, String rawHtml) {
if (rawHtml == null) {
rawHtml = "";
}
/**
* Temp에 파일 저장 후, public URL 반환
*/
public String storeTempFile(String prjctCd, MultipartFile file) {
try {
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
String ext = "";
String returnHtml = rawHtml;
try {
int dot = original.lastIndexOf('.');
if (dot > 0 && dot < original.length() - 1) {
ext = original.substring(dot);
}
// body fragment로 파싱 (KriEditor가 body 없이 <p>...</p> 형태 저장하므로)
Document doc = Jsoup.parseBodyFragment(rawHtml);
Elements imgs = doc.select("img[src]");
String newName = CommonUtil.uuid32() + ext;
Set<String> assetFileNamesToKeep = new HashSet<>();
Path tempDir = getTempDir(prjctCd);
Files.createDirectories(tempDir);
Path target = tempDir.resolve(newName);
file.transferTo(target.toFile());
// 브라우저에서 사용할 URL
return publicBaseUrlPrefix + "/" + prjctCd + "/Temp/" + newName;
} catch (IOException e) {
throw new RuntimeException("파일 저장 실패", e);
for (Element img : imgs) {
String src = img.attr("src");
if (src == null || src.isBlank()) {
continue;
}
}
/**
* 컨택 시나리오 저장 시:
* 1) HTML 내 Temp 이미지 -> Asset으로 이동 & src 수정
* 2) Asset 디렉토리에서 더 이상 사용되지 않는 파일 삭제
* 3) 정리된 HTML 반환
*/
public String syncOnSave(String prjctCd, String rawHtml) {
if (rawHtml == null) rawHtml = "";
String returnHtml = rawHtml;
try{
// body fragment로 파싱 (KriEditor가 body 없이 <p>...</p> 형태 저장하므로)
Document doc = Jsoup.parseBodyFragment(rawHtml);
Elements imgs = doc.select("img[src]");
Set<String> assetFileNamesToKeep = new HashSet<>();
for (Element img : imgs) {
String src = img.attr("src");
if (src == null || src.isBlank()) continue;
if (!src.contains("/" + prjctCd + "/")) continue;
if (src.contains("/" + prjctCd + "/Temp/")) {
// Temp → Asset 이동
String fileName = FileUtil.extractFileNameFromPath(src);
moveTempToAsset(prjctCd, fileName);
String assetSrc = src.replace("/Temp/", "/Asset/");
img.attr("src", assetSrc);
assetFileNamesToKeep.add(fileName);
} else if (src.contains("/" + prjctCd + "/Asset/")) {
String fileName = FileUtil.extractFileNameFromPath(src);
assetFileNamesToKeep.add(fileName);
}
}
// Asset 디렉토리 정리 (본문에 없는 파일 삭제)
cleanupAssetDir(prjctCd, assetFileNamesToKeep);
// body 안의 HTML만 반환 (불필요한 <html><body> wrapper 제거)
returnHtml = doc.body().html();
}
catch (IOException e) {
log.warn("temp 파일 이동 실패: {}", rawHtml, e);
if (!src.contains("/" + prjctCd + "/")) {
continue;
}
return returnHtml;
}
if (src.contains("/" + prjctCd + "/Temp/")) {
// Temp → Asset 이동
String fileName = FileUtil.extractFileNameFromPath(src);
moveTempToAsset(prjctCd, fileName);
/***************************private************************************/
private String normalizeBaseUrl(String url) {
if (url.endsWith("/")) {
return url.substring(0, url.length() - 1);
String assetSrc = src.replace("/Temp/", "/Asset/");
img.attr("src", assetSrc);
assetFileNamesToKeep.add(fileName);
} else if (src.contains("/" + prjctCd + "/Asset/")) {
String fileName = FileUtil.extractFileNameFromPath(src);
assetFileNamesToKeep.add(fileName);
}
return url;
}
// Asset 디렉토리 정리 (본문에 없는 파일 삭제)
cleanupAssetDir(prjctCd, assetFileNamesToKeep);
// body 안의 HTML만 반환 (불필요한 <html><body> wrapper 제거)
returnHtml = doc.body().html();
} catch (IOException e) {
log.warn("temp 파일 이동 실패: {}", rawHtml, e);
}
private Path getTempDir(String prjctCd) {
return uploadBaseDir.resolve(prjctCd).resolve("Temp");
return returnHtml;
}
/***************************private************************************/
private String normalizeBaseUrl(String url) {
if (url.endsWith("/")) {
return url.substring(0, url.length() - 1);
}
return url;
}
private Path getTempDir(String prjctCd) {
return uploadBaseDir.resolve(prjctCd).resolve("Temp");
}
private Path getAssetDir(String prjctCd) {
return uploadBaseDir.resolve(prjctCd).resolve("Asset");
}
private void moveTempToAsset(String prjctCd, String fileName) throws IOException {
if (fileName == null || fileName.isBlank()) {
return;
}
private Path getAssetDir(String prjctCd) {
return uploadBaseDir.resolve(prjctCd).resolve("Asset");
Path tempDir = getTempDir(prjctCd);
Path assetDir = getAssetDir(prjctCd);
Files.createDirectories(assetDir);
Path source = tempDir.resolve(fileName).normalize();
Path target = assetDir.resolve(fileName).normalize();
if (!source.startsWith(tempDir) || !target.startsWith(assetDir)) {
// 안전 체크
return;
}
if (!Files.exists(source)) {
return;
}
private void moveTempToAsset(String prjctCd, String fileName) throws IOException {
if (fileName == null || fileName.isBlank()) return;
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
}
Path tempDir = getTempDir(prjctCd);
Path assetDir = getAssetDir(prjctCd);
Files.createDirectories(assetDir);
private void cleanupAssetDir(String prjctCd, Set<String> keepFileNames) throws IOException {
Path assetDir = getAssetDir(prjctCd);
if (!Files.exists(assetDir)) {
return;
}
Path source = tempDir.resolve(fileName).normalize();
Path target = assetDir.resolve(fileName).normalize();
if (!source.startsWith(tempDir) || !target.startsWith(assetDir)) {
// 안전 체크
return;
try (DirectoryStream<Path> stream = Files.newDirectoryStream(assetDir)) {
for (Path path : stream) {
if (!Files.isRegularFile(path)) {
continue;
}
if (!Files.exists(source)) {
return;
}
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
}
private void cleanupAssetDir(String prjctCd, Set<String> keepFileNames) throws IOException {
Path assetDir = getAssetDir(prjctCd);
if (!Files.exists(assetDir)) return;
try (DirectoryStream<Path> stream = Files.newDirectoryStream(assetDir)) {
for (Path path : stream) {
if (!Files.isRegularFile(path)) continue;
String fileName = path.getFileName().toString();
if (!keepFileNames.contains(fileName)) {
Files.deleteIfExists(path);
}
}
String fileName = path.getFileName().toString();
if (!keepFileNames.contains(fileName)) {
Files.deleteIfExists(path);
}
}
}
}
}

View File

@@ -1,192 +1,211 @@
package com.kri.contact.server.service;
import com.kri.common.web.BusinessException;
import com.kri.common.webmvc.page.*;
import com.kri.common.webmvc.page.PageRequestDto;
import com.kri.common.webmvc.page.PageResponseDto;
import com.kri.common.webmvc.page.Pageables;
import com.kri.contact.server.common.consts.ContactConstant;
import com.kri.contact.server.dto.*;;
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntity;
import com.kri.contact.server.dto.ProjectCreateRequestDto;
import com.kri.contact.server.dto.ProjectInfoDto;
import com.kri.contact.server.dto.ProjectMainTemplateUpdateRequestDto;
import com.kri.contact.server.dto.ProjectOwnerResponseDto;
import com.kri.contact.server.dto.ProjectSearchRequestDto;
import com.kri.contact.server.dto.ProjectUpdateRequestDto;
import com.kri.contact.server.persistence.entity.TPrjctEntity;
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntity;
import com.kri.contact.server.persistence.query.ProjectSpecs;
import com.kri.contact.server.persistence.repository.ProjectMainTemplateRepository;
import com.kri.contact.server.persistence.repository.ProjectRepository;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
;
@Service
@RequiredArgsConstructor
public class ProjectService {
private final AssignService assignService;
private final ResultCodeService resultCodeService;
private final ProjectRepository projectRepository;
private final ProjectMainTemplateRepository projectMainTemplateRepository;
private static final List<Short> STATUS_0_1 = List.of((short) 0, (short) 1);
private static final List<Short> STATUS_1 = List.of((short) 1);
private static final List<Short> STATUS_0_1 = List.of((short) 0, (short) 1);
private static final List<Short> STATUS_1 = List.of((short) 1);
private final AssignService assignService;
private final ResultCodeService resultCodeService;
private final ProjectRepository projectRepository;
private final ProjectMainTemplateRepository projectMainTemplateRepository;
@Transactional
public ProjectInfoDto createProject(ProjectCreateRequestDto req, String regUser, LocalDateTime regDt) {
String itrnt = req.getItrntPrjctCd();
@Transactional
public ProjectInfoDto createProject(ProjectCreateRequestDto req, String regUser,
LocalDateTime regDt) {
String itrnt = req.getItrntPrjctCd();
try {
String prjctCd = this.makePrjctCd(itrnt);
TPrjctEntity entity = TPrjctEntity.create(req, prjctCd, regUser, regDt);
try {
String prjctCd = this.makePrjctCd(itrnt);
TPrjctEntity entity = TPrjctEntity.create(req, prjctCd, regUser, regDt);
ProjectInfoDto savedProject = ProjectInfoDto.from(projectRepository.save(entity));
resultCodeService.copyResultCodeFromDefault(savedProject.getPrjctIdx(), regUser, regDt);
ProjectInfoDto savedProject = ProjectInfoDto.from(projectRepository.save(entity));
resultCodeService.copyResultCodeFromDefault(savedProject.getPrjctIdx(), regUser, regDt);
return savedProject;
} catch (DataIntegrityViolationException e) {
throw BusinessException.conflict(
"PROJECT_CODE_CONFLICT",
"프로젝트 코드 생성 중 충돌이 발생했습니다. 다시 시도해주세요."
).with("itrntPrjctCd", itrnt);
}
return savedProject;
} catch (DataIntegrityViolationException e) {
throw BusinessException.conflict(
"PROJECT_CODE_CONFLICT",
"프로젝트 코드 생성 중 충돌이 발생했습니다. 다시 시도해주세요."
).with("itrntPrjctCd", itrnt);
}
}
public ProjectInfoDto getProject(Long prjctIdx) {
return ProjectInfoDto.from(projectRepository.findByPrjctIdxAndDelFalse(prjctIdx));
}
public List<ProjectInfoDto> getTopProject(int topCount, String keyword, String userId,
Integer userRole) {
Specification<TPrjctEntity> spec =
ProjectSpecs.keywordLike(keyword)
.and(ProjectSpecs.isDelFalse());
if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
if (userRole >= ContactConstant.FIELDWORK_USER_ROLE) {
spec = spec.and(ProjectSpecs.statusIn(STATUS_1));
} else {
spec = spec.and(ProjectSpecs.statusIn(STATUS_0_1));
}
spec = spec.and(ProjectSpecs.assignedToUserAndNotExcluded(userId));
}
public ProjectInfoDto getProject(Long prjctIdx) {
return ProjectInfoDto.from(projectRepository.findByPrjctIdxAndDelFalse(prjctIdx));
Pageable pageable = PageRequest.of(0, topCount, Sort.by(Sort.Direction.DESC, "regDt"));
return projectRepository.findAll(spec, pageable)
.getContent()
.stream()
.map(ProjectInfoDto::from) // <-- 너네 매핑 방식에 맞게 수정
.toList();
}
public PageResponseDto<ProjectInfoDto> searchProject(ProjectSearchRequestDto req, String userId,
Integer userRole) {
Specification<TPrjctEntity> spec =
ProjectSpecs.keywordLike(req.getPrjctText())
.and(ProjectSpecs.isDelFalse())
.and(ProjectSpecs.statusIn(req.getPrjctStatusList()))
.and(ProjectSpecs.ownerDeptIn(req.getOwnerDeptList()))
.and(ProjectSpecs.ownerFwIn(req.getOwnerFwList()));
if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
if (userRole >= ContactConstant.FIELDWORK_USER_ROLE) {
spec = spec.and(ProjectSpecs.statusIn(STATUS_1));
} else {
spec = spec.and(ProjectSpecs.statusIn(STATUS_0_1));
}
spec = spec.and(ProjectSpecs.assignedToUserAndNotExcluded(userId));
}
public List<ProjectInfoDto> getTopProject(int topCount, String keyword, String userId, Integer userRole) {
Specification<TPrjctEntity> spec =
ProjectSpecs.keywordLike(keyword)
.and(ProjectSpecs.isDelFalse());
PageRequestDto pageReq = req.getPageRequest();
Pageable pageable = Pageables.of(pageReq, TPrjctEntity.class);
if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
if (userRole >= ContactConstant.FIELDWORK_USER_ROLE) {
spec = spec.and(ProjectSpecs.statusIn(STATUS_1));
} else {
spec = spec.and(ProjectSpecs.statusIn(STATUS_0_1));
}
spec = spec.and(ProjectSpecs.assignedToUserAndNotExcluded(userId));
}
Page<ProjectInfoDto> page = projectRepository.findAll(spec, pageable)
.map(ProjectInfoDto::from);
Pageable pageable = PageRequest.of(0, topCount, Sort.by(Sort.Direction.DESC, "regDt"));
return PageResponseDto.from(page);
}
return projectRepository.findAll(spec, pageable)
.getContent()
.stream()
.map(ProjectInfoDto::from) // <-- 너네 매핑 방식에 맞게 수정
.toList();
}
public ProjectOwnerResponseDto getOwnerList(Integer userRole) {
ProjectOwnerResponseDto responseDto = new ProjectOwnerResponseDto();
public PageResponseDto<ProjectInfoDto> searchProject(ProjectSearchRequestDto req, String userId, Integer userRole) {
Specification<TPrjctEntity> spec =
ProjectSpecs.keywordLike(req.getPrjctText())
.and(ProjectSpecs.isDelFalse())
.and(ProjectSpecs.statusIn(req.getPrjctStatusList()))
.and(ProjectSpecs.ownerDeptIn(req.getOwnerDeptList()))
.and(ProjectSpecs.ownerFwIn(req.getOwnerFwList()));
responseDto.setOwnerDeptList(this.getOwnerDeptList(userRole));
responseDto.setOwnerFwList(this.getOwnerFwList(userRole));
if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
if (userRole >= ContactConstant.FIELDWORK_USER_ROLE) {
spec = spec.and(ProjectSpecs.statusIn(STATUS_1));
} else {
spec = spec.and(ProjectSpecs.statusIn(STATUS_0_1));
}
spec = spec.and(ProjectSpecs.assignedToUserAndNotExcluded(userId));
}
return responseDto;
}
PageRequestDto pageReq = req.getPageRequest();
Pageable pageable = Pageables.of(pageReq, TPrjctEntity.class);
Page<ProjectInfoDto> page = projectRepository.findAll(spec, pageable)
.map(ProjectInfoDto::from);
return PageResponseDto.from(page);
}
public ProjectOwnerResponseDto getOwnerList(Integer userRole) {
ProjectOwnerResponseDto responseDto = new ProjectOwnerResponseDto();
responseDto.setOwnerDeptList(this.getOwnerDeptList(userRole));
responseDto.setOwnerFwList(this.getOwnerFwList(userRole));
return responseDto;
}
public List<String> getOwnerDeptList(Integer userRole) {
final List<Short> statusList =
(userRole < ContactConstant.OUTSOURCE_USER_ROLE) ? null :
public List<String> getOwnerDeptList(Integer userRole) {
final List<Short> statusList =
(userRole < ContactConstant.OUTSOURCE_USER_ROLE) ? null :
(userRole < ContactConstant.FIELDWORK_USER_ROLE) ? STATUS_0_1 :
STATUS_1;
STATUS_1;
return projectRepository.findDistinctOwnerDept(statusList);
}
return projectRepository.findDistinctOwnerDept(statusList);
}
public List<String> getOwnerFwList(Integer userRole) {
final List<Short> statusList =
(userRole < ContactConstant.OUTSOURCE_USER_ROLE) ? null :
public List<String> getOwnerFwList(Integer userRole) {
final List<Short> statusList =
(userRole < ContactConstant.OUTSOURCE_USER_ROLE) ? null :
(userRole < ContactConstant.FIELDWORK_USER_ROLE) ? STATUS_0_1 :
STATUS_1;
STATUS_1;
return projectRepository.findDistinctOwnerFw(statusList);
return projectRepository.findDistinctOwnerFw(statusList);
}
public Long getMainTemplateIdx(Long prjctIdx, Short chnnlTy) {
return projectMainTemplateRepository.findByIdPrjctIdxAndIdChnnlTy(prjctIdx, chnnlTy)
.map(TPrjctMainTmplatEntity::getTmplatIdx)
.orElse(null);
}
@Transactional
public void updateProject(long prjctIdx, ProjectUpdateRequestDto req, String modUser,
LocalDateTime modDt) {
// dirty checking 업데이트
TPrjctEntity entity = projectRepository.findById(prjctIdx)
.orElseThrow(() ->
BusinessException.notFound("PROJECT_NOT_FOUND", "프로젝트를 찾을 수 없습니다.")
.with("prjctIdx", prjctIdx)
);
entity.updateFrom(req.getProjectInfo(), modUser, modDt);
assignService.upsertPrjctOutsourceAssign(prjctIdx, req.getAssignUserIdList(), modUser, modDt);
resultCodeService.updateResultCode(prjctIdx, req.getResultCodeList(), modUser, modDt);
}
@Transactional
public void updateProjectMainTemplate(ProjectMainTemplateUpdateRequestDto req, String modUser,
LocalDateTime modDt) {
Short chnnlTy = req.getChnnlTy().getCode();
projectMainTemplateRepository.deleteByIdPrjctIdxAndIdChnnlTy(req.getPrjctIdx(), chnnlTy);
if (req.getTmplatIdx() == null) {
return;
}
public Long getMainTemplateIdx(Long prjctIdx, Short chnnlTy) {
return projectMainTemplateRepository.findByIdPrjctIdxAndIdChnnlTy(prjctIdx, chnnlTy)
.map(TPrjctMainTmplatEntity::getTmplatIdx)
.orElse(null);
TPrjctMainTmplatEntity entity = TPrjctMainTmplatEntity.create(req, modUser, modDt);
projectMainTemplateRepository.save(entity);
}
@Transactional
public void deleteProject(Long prjctIdx, String delUser, LocalDateTime delDt) {
int deleteCount = projectRepository.softDeleteByPrjctIdx(prjctIdx, delUser, delDt);
if (deleteCount == 0) {
throw BusinessException.notFound("PROJECT_NOT_FOUND", "프로젝트를 찾을 수 없습니다.")
.with("prjctIdx", prjctIdx);
}
}
@Transactional
public void updateProject(long prjctIdx, ProjectUpdateRequestDto req, String modUser, LocalDateTime modDt) {
// dirty checking 업데이트
TPrjctEntity entity = projectRepository.findById(prjctIdx)
.orElseThrow(() ->
BusinessException.notFound("PROJECT_NOT_FOUND", "프로젝트를 찾을 수 없습니다.")
.with("prjctIdx", prjctIdx)
);
/***************************private************************************/
private String makePrjctCd(String itrntPrjctCd) {
String prefix = itrntPrjctCd + "_";
entity.updateFrom(req.getProjectInfo(), modUser, modDt);
List<TPrjctEntity> sameItrnt = projectRepository.findByItrntPrjctCd(itrntPrjctCd);
int maxSubCode = sameItrnt.stream()
.map(TPrjctEntity::getPrjctCd)
.filter(Objects::nonNull)
.filter(cd -> cd.startsWith(prefix))
.map(cd -> cd.substring(prefix.length()))
.filter(s -> s.matches("\\d+"))
.mapToInt(Integer::parseInt)
.max()
.orElse(0);
assignService.upsertPrjctOutsourceAssign(prjctIdx, req.getAssignUserIdList(), modUser, modDt);
resultCodeService.updateResultCode(prjctIdx, req.getResultCodeList(), modUser, modDt);
}
@Transactional
public void updateProjectMainTemplate(ProjectMainTemplateUpdateRequestDto req, String modUser, LocalDateTime modDt) {
Short chnnlTy = req.getChnnlTy().getCode();
projectMainTemplateRepository.deleteByIdPrjctIdxAndIdChnnlTy(req.getPrjctIdx(), chnnlTy);
if(req.getTmplatIdx() == null) return;
TPrjctMainTmplatEntity entity = TPrjctMainTmplatEntity.create(req, modUser, modDt);
projectMainTemplateRepository.save(entity);
}
@Transactional
public void deleteProject(Long prjctIdx, String delUser, LocalDateTime delDt) {
int deleteCount = projectRepository.softDeleteByPrjctIdx(prjctIdx, delUser, delDt);
if(deleteCount == 0) {
throw BusinessException.notFound("PROJECT_NOT_FOUND", "프로젝트를 찾을 수 없습니다.")
.with("prjctIdx", prjctIdx);
}
}
/***************************private************************************/
private String makePrjctCd(String itrntPrjctCd) {
String prefix = itrntPrjctCd + "_";
List<TPrjctEntity> sameItrnt = projectRepository.findByItrntPrjctCd(itrntPrjctCd);
int maxSubCode = sameItrnt.stream()
.map(TPrjctEntity::getPrjctCd)
.filter(Objects::nonNull)
.filter(cd -> cd.startsWith(prefix))
.map(cd -> cd.substring(prefix.length()))
.filter(s -> s.matches("\\d+"))
.mapToInt(Integer::parseInt)
.max()
.orElse(0);
return prefix + String.format("%03d", (maxSubCode + 1));
}
return prefix + String.format("%03d", (maxSubCode + 1));
}
}

View File

@@ -1,70 +1,69 @@
package com.kri.contact.server.service;
import com.kri.common.datetime.DateTimeUtil;
import com.kri.common.web.BusinessException;
import com.kri.contact.server.common.enums.ResultCodeType;
import com.kri.contact.server.dto.ResultCodeDto;
import com.kri.contact.server.persistence.entity.TResultCodeEntity;
import com.kri.contact.server.persistence.entity.TResultCodeEntityId;
import com.kri.contact.server.persistence.repository.ResultCodeRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
public class ResultCodeService {
private final ResultCodeRepository resultCodeRepository;
private final ResultCodeRepository resultCodeRepository;
public void copyResultCodeFromDefault(long prjctIdx, String regUser, LocalDateTime regDt) {
List<TResultCodeEntity> defaultCodeList = resultCodeRepository.findDefault();
public void copyResultCodeFromDefault(long prjctIdx, String regUser, LocalDateTime regDt) {
List<TResultCodeEntity> defaultCodeList = resultCodeRepository.findDefault();
List<TResultCodeEntity> copyCodeList = defaultCodeList.stream()
.map(src -> TResultCodeEntity.copyFromDefault(src, prjctIdx, regUser, regDt))
.toList();
List<TResultCodeEntity> copyCodeList = defaultCodeList.stream()
.map(src -> TResultCodeEntity.copyFromDefault(src, prjctIdx, regUser, regDt))
.toList();
resultCodeRepository.saveAll(copyCodeList);
resultCodeRepository.saveAll(copyCodeList);
}
public List<ResultCodeDto> getResultCode(long prjctIdx, ResultCodeType resultCdTy) {
if (resultCdTy == null) {
return resultCodeRepository.findByIdPrjctIdx(prjctIdx).stream()
.map(ResultCodeDto::from)
.toList();
} else {
return resultCodeRepository.findByIdPrjctIdxAndIdResultCdTy(prjctIdx, resultCdTy.getCode())
.stream()
.map(ResultCodeDto::from)
.toList();
}
}
public List<ResultCodeDto> getResultCode(long prjctIdx, ResultCodeType resultCdTy) {
if (resultCdTy == null) {
return resultCodeRepository.findByIdPrjctIdx(prjctIdx).stream()
.map(ResultCodeDto::from)
.toList();
} else {
return resultCodeRepository.findByIdPrjctIdxAndIdResultCdTy(prjctIdx, resultCdTy.getCode()).stream()
.map(ResultCodeDto::from)
.toList();
}
@Transactional
public void updateResultCode(long prjctIdx, List<ResultCodeDto> resultCodeDtoList, String modUser,
LocalDateTime modDt) {
if (resultCodeDtoList != null && !resultCodeDtoList.isEmpty()) {
Map<ResultCodeType, List<ResultCodeDto>> dtoGroupByType = resultCodeDtoList.stream()
.filter(dto -> dto.getResultCdTy() != null)
.collect(Collectors.groupingBy(ResultCodeDto::getResultCdTy));
dtoGroupByType.forEach((resultCdTy, dtos) ->
replaceResultCodes(prjctIdx, resultCdTy, dtos, modUser, modDt)
);
}
}
@Transactional
public void updateResultCode(long prjctIdx, List<ResultCodeDto> resultCodeDtoList, String modUser, LocalDateTime modDt) {
if (resultCodeDtoList != null && !resultCodeDtoList.isEmpty()) {
Map<ResultCodeType, List<ResultCodeDto>> dtoGroupByType = resultCodeDtoList.stream()
.filter(dto -> dto.getResultCdTy() != null)
.collect(Collectors.groupingBy(ResultCodeDto::getResultCdTy));
/*************************private************************************/
private void replaceResultCodes(long prjctIdx, ResultCodeType resultCdTy,
List<ResultCodeDto> dtos, String userId, LocalDateTime modDt) {
resultCodeRepository.deleteByIdPrjctIdxAndIdResultCdTy(prjctIdx, resultCdTy);
dtoGroupByType.forEach((resultCdTy, dtos) ->
replaceResultCodes(prjctIdx, resultCdTy, dtos, modUser, modDt)
);
}
}
List<TResultCodeEntity> entities = dtos.stream()
.map(dto -> TResultCodeEntity.fromDto(prjctIdx, resultCdTy, dto, userId, modDt))
.toList();
/*************************private************************************/
private void replaceResultCodes(long prjctIdx, ResultCodeType resultCdTy, List<ResultCodeDto> dtos, String userId, LocalDateTime modDt) {
resultCodeRepository.deleteByIdPrjctIdxAndIdResultCdTy(prjctIdx, resultCdTy);
List<TResultCodeEntity> entities = dtos.stream()
.map(dto -> TResultCodeEntity.fromDto(prjctIdx, resultCdTy, dto, userId, modDt))
.toList();
resultCodeRepository.saveAll(entities);
}
resultCodeRepository.saveAll(entities);
}
}

View File

@@ -3,30 +3,29 @@ package com.kri.contact.server.service;
import com.kri.contact.server.common.consts.ContactConstant;
import com.kri.contact.server.dto.RoleInfoDto;
import com.kri.contact.server.persistence.repository.RoleRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class RoleService {
private final RoleRepository roleRepository;
private final RoleRepository roleRepository;
public List<RoleInfoDto> getRoleList() {
return roleRepository.findAll().stream()
.map(RoleInfoDto::from)
.toList();
}
public List<RoleInfoDto> getRoleList() {
return roleRepository.findAll().stream()
.map(RoleInfoDto::from)
.toList();
}
public List<RoleInfoDto> getRoleList(Integer roleCd) {
Integer searchRoleCd = roleCd < ContactConstant.OUTSOURCE_USER_ROLE ?
ContactConstant.OUTSOURCE_USER_ROLE :
ContactConstant.FIELDWORK_USER_ROLE;
public List<RoleInfoDto> getRoleList(Integer roleCd) {
Integer searchRoleCd = roleCd < ContactConstant.OUTSOURCE_USER_ROLE ?
ContactConstant.OUTSOURCE_USER_ROLE :
ContactConstant.FIELDWORK_USER_ROLE;
return roleRepository.findByRoleCdGreaterThanEqual(searchRoleCd).stream()
.map(RoleInfoDto::from)
.toList();
}
return roleRepository.findByRoleCdGreaterThanEqual(searchRoleCd).stream()
.map(RoleInfoDto::from)
.toList();
}
}

View File

@@ -1,162 +1,180 @@
package com.kri.contact.server.service;
import static com.kri.common.json.JsonUtil.toMap;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kri.contact.server.dto.*;
import com.kri.contact.server.dto.systemlog.UploadUserContentDto;
import com.kri.contact.server.common.enums.SystemEventType;
import com.kri.contact.server.dto.ProjectCreateRequestDto;
import com.kri.contact.server.dto.ProjectMainTemplateUpdateRequestDto;
import com.kri.contact.server.dto.ProjectUpdateRequestDto;
import com.kri.contact.server.dto.UserInfoDto;
import com.kri.contact.server.dto.systemlog.UploadUserContentDto;
import com.kri.contact.server.persistence.entity.TSysEventLogEntity;
import com.kri.contact.server.persistence.repository.SystemEventLogRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import static com.kri.common.json.JsonUtil.toMap;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class SystemEventLogService {
private final ObjectMapper objectMapper;
private final SystemEventLogRepository systemEventLogRepository;
public void writeLoginLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.LOGIN,
"Login",
null,
userId,
regDt,
clientIp,
"userId",
userId
);
}
private final ObjectMapper objectMapper;
private final SystemEventLogRepository systemEventLogRepository;
public void writeLogoutLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.LOGOUT,
"Logout",
null,
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeLoginLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.LOGIN,
"Login",
null,
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeCreateUserLog(String regId, LocalDateTime regDt, String clientIp, UserInfoDto userInfo) {
writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, regDt, clientIp, userInfo);
}
public void writeLogoutLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.LOGOUT,
"Logout",
null,
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeUploadUserLog(String regId, LocalDateTime regDt, String clientIp, UploadUserContentDto content) {
writeSystemLog(SystemEventType.UPLOAD_USER, "Upload User", null, regId, regDt, clientIp, content);
}
public void writeCreateUserLog(String regId, LocalDateTime regDt, String clientIp,
UserInfoDto userInfo) {
writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, regDt, clientIp,
userInfo);
}
public void writeUpdateUserLog(String regId, LocalDateTime regDt, String clientIp, UserInfoDto userInfo) {
writeSystemLog(SystemEventType.UPDATE_USER, "Update User", null, regId, regDt, clientIp, userInfo);
}
public void writeUploadUserLog(String regId, LocalDateTime regDt, String clientIp,
UploadUserContentDto content) {
writeSystemLog(SystemEventType.UPLOAD_USER, "Upload User", null, regId, regDt, clientIp,
content);
}
public void writeDeleteUserLog(String regId, LocalDateTime regDt, String clientIp, String userId) {
writeSystemLog(
SystemEventType.DELETE_USER,
"Delete User",
null,
regId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeUpdateUserLog(String regId, LocalDateTime regDt, String clientIp,
UserInfoDto userInfo) {
writeSystemLog(SystemEventType.UPDATE_USER, "Update User", null, regId, regDt, clientIp,
userInfo);
}
public void writeCreateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, ProjectCreateRequestDto req) {
writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, regDt, clientIp, req);
}
public void writeDeleteUserLog(String regId, LocalDateTime regDt, String clientIp,
String userId) {
writeSystemLog(
SystemEventType.DELETE_USER,
"Delete User",
null,
regId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeUpdateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, ProjectUpdateRequestDto req) {
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt, clientIp, req);
}
public void writeCreateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx,
ProjectCreateRequestDto req) {
writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, regDt,
clientIp, req);
}
public void writeUpdateDefaultMessageTemplate(String regId, LocalDateTime regDt, String clientIp, ProjectMainTemplateUpdateRequestDto req) {
writeSystemLog(SystemEventType.UPDATE_PROJECT_DEFAULT_TEMPLATE, "Update Project Default Message Template", req.getPrjctIdx(), regId, regDt, clientIp, req);
}
public void writeUpdateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx,
ProjectUpdateRequestDto req) {
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt,
clientIp, req);
}
public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx) {
writeSystemLog(
SystemEventType.DELETE_PROJECT,
"Delete Project",
prjctIdx,
regId,
regDt,
clientIp,
"prjctIdx",
prjctIdx
);
}
public void writeUpdateDefaultMessageTemplate(String regId, LocalDateTime regDt, String clientIp,
ProjectMainTemplateUpdateRequestDto req) {
writeSystemLog(SystemEventType.UPDATE_PROJECT_DEFAULT_TEMPLATE,
"Update Project Default Message Template", req.getPrjctIdx(), regId, regDt, clientIp, req);
}
public void writeAssignUserProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, List<String> assignUserIdList) {
writeSystemLog(
SystemEventType.ASSIGN_PROJECT_USER,
"Assign Project FW User",
prjctIdx,
regId,
regDt,
clientIp,
"assignUserIdList",
assignUserIdList
);
}
public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx) {
writeSystemLog(
SystemEventType.DELETE_PROJECT,
"Delete Project",
prjctIdx,
regId,
regDt,
clientIp,
"prjctIdx",
prjctIdx
);
}
protected <T> void writeSystemLog(
SystemEventType eventType,
String title,
Long prjctIdx,
String regId,
LocalDateTime regDt,
String clientIp,
T content
) {
Map<String, Object> contentMap = toMap(objectMapper, content);
public void writeAssignUserProject(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx, List<String> assignUserIdList) {
writeSystemLog(
SystemEventType.ASSIGN_PROJECT_USER,
"Assign Project FW User",
prjctIdx,
regId,
regDt,
clientIp,
"assignUserIdList",
assignUserIdList
);
}
saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
}
protected <T> void writeSystemLog(
SystemEventType eventType,
String title,
Long prjctIdx,
String regId,
LocalDateTime regDt,
String clientIp,
T content
) {
Map<String, Object> contentMap = toMap(objectMapper, content);
protected <T> void writeSystemLog(
SystemEventType eventType,
String title,
Long prjctIdx,
String regId,
LocalDateTime regDt,
String clientIp,
String contentKey,
T content
) {
Map<String, Object> contentMap = Map.of(contentKey, content);
saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
}
saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
}
private void saveLog(
SystemEventType eventType,
String title,
Long prjctIdx,
String regId,
LocalDateTime regDt,
String clientIp,
Map<String, Object> contentMap
) {
TSysEventLogEntity log = TSysEventLogEntity.of(
eventType,
title,
contentMap,
prjctIdx,
clientIp,
regId,
regDt
);
protected <T> void writeSystemLog(
SystemEventType eventType,
String title,
Long prjctIdx,
String regId,
LocalDateTime regDt,
String clientIp,
String contentKey,
T content
) {
Map<String, Object> contentMap = Map.of(contentKey, content);
saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
}
systemEventLogRepository.save(log);
}
private void saveLog(
SystemEventType eventType,
String title,
Long prjctIdx,
String regId,
LocalDateTime regDt,
String clientIp,
Map<String, Object> contentMap
) {
TSysEventLogEntity log = TSysEventLogEntity.of(
eventType,
title,
contentMap,
prjctIdx,
clientIp,
regId,
regDt
);
systemEventLogRepository.save(log);
}
}

View File

@@ -14,334 +14,342 @@ import com.kri.contact.server.dto.excel.UserUploadDto;
import com.kri.contact.server.dto.excel.UserUploadErrorDto;
import com.kri.contact.server.persistence.entity.TUserEntity;
import com.kri.contact.server.persistence.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@Service
@RequiredArgsConstructor
public class UserService {
private final IntranetExtensionApiClient intranetExtensionApiClient;
private final RoleService roleService;
private final UserRepository userRepository;
@Transactional
public void createUser(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
List<RoleInfoDto> roleList = roleService.getRoleList();
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
private final IntranetExtensionApiClient intranetExtensionApiClient;
private final RoleService roleService;
private final UserRepository userRepository;
userInfo.setUserId(userInfo.getUserId().toLowerCase());
@Transactional
public void createUser(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
List<RoleInfoDto> roleList = roleService.getRoleList();
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
List<DataVerificationDto> failList = validateUserDto(userInfo, roleList, intranetUserList).stream().filter(dto -> !dto.isSuccess()).toList();
if(!failList.isEmpty()) {
DataVerificationDto firstFail = failList.get(0);
throw BusinessException.badRequest("WRONG_USER_DATA", firstFail.getErrMessage());
}
userInfo.setUserId(userInfo.getUserId().toLowerCase());
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
userRepository.save(entity);
List<DataVerificationDto> failList = validateUserDto(userInfo, roleList,
intranetUserList).stream().filter(dto -> !dto.isSuccess()).toList();
if (!failList.isEmpty()) {
DataVerificationDto firstFail = failList.get(0);
throw BusinessException.badRequest("WRONG_USER_DATA", firstFail.getErrMessage());
}
@Transactional
public ExcelUploadResponseDto createUsersFromExcel(MultipartFile file, String regUser, LocalDateTime regDt, String forceCmpn) {
if (file == null || file.isEmpty()) {
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
}
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
List<UserUploadDto> rows;
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
// DTO 매핑 (스트리밍 X, 일반 방식)
rows = ExcelMapper.readFromWorkbook(workbook, UserUploadDto.class);
} catch (Exception e) {
throw BusinessException.badRequest("INVALID_EXCEL", "엑셀 파일을 읽는 중 오류가 발생했습니다.")
.with("fileName", file.getOriginalFilename());
}
userRepository.save(entity);
}
int totalCount = rows.size();
int successCount = 0;
List<RoleInfoDto> roleList = roleService.getRoleList();
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
List<UserUploadErrorDto> errorList = new ArrayList<>();
@Transactional
public ExcelUploadResponseDto createUsersFromExcel(MultipartFile file, String regUser,
LocalDateTime regDt, String forceCmpn) {
if (file == null || file.isEmpty()) {
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
}
// 엑셀 1행 = 헤더, DTO 리스트는 2행부터라고 가정
for (int i = 0; i < rows.size(); i++) {
UserUploadDto uploadDto = rows.get(i);
Integer roleCd = roleList.stream()
.filter(r -> java.util.Objects.equals(uploadDto.getUserRoleStr(), r.getRoleNm()))
.map(RoleInfoDto::getRoleCd)
.findFirst()
.orElse(null);
List<UserUploadDto> rows;
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
// DTO 매핑 (스트리밍 X, 일반 방식)
rows = ExcelMapper.readFromWorkbook(workbook, UserUploadDto.class);
} catch (Exception e) {
throw BusinessException.badRequest("INVALID_EXCEL", "엑셀 파일을 읽는 중 오류가 발생했습니다.")
.with("fileName", file.getOriginalFilename());
}
UserInfoDto dto = UserInfoDto.from(uploadDto, roleCd, regUser);
if(!forceCmpn.isBlank()) {
dto.setUserCmpn(forceCmpn);
}
int totalCount = rows.size();
int successCount = 0;
List<RoleInfoDto> roleList = roleService.getRoleList();
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
List<UserUploadErrorDto> errorList = new ArrayList<>();
int rowNumber = i + 2; // 엑셀 실제 행 번호 (헤더가 1행일 때)
// 1) 값 검증
List<UserUploadErrorDto> rowErrors = validateUserDtoForExcel(dto, rowNumber, roleList, intranetUserList);
if (!rowErrors.isEmpty()) {
errorList.addAll(rowErrors);
continue; // 이 행은 DB 저장 스킵
}
// 엑셀 1행 = 헤더, DTO 리스트는 2행부터라고 가정
for (int i = 0; i < rows.size(); i++) {
UserUploadDto uploadDto = rows.get(i);
Integer roleCd = roleList.stream()
.filter(r -> java.util.Objects.equals(uploadDto.getUserRoleStr(), r.getRoleNm()))
.map(RoleInfoDto::getRoleCd)
.findFirst()
.orElse(null);
// 2) 실제 DB 저장
try {
this.createUserInternal(dto, regUser, regDt);
successCount++;
} catch (BusinessException ex) {
// 시스템/비즈니스 예외도 에러 목록에 추가
errorList.add(
UserUploadErrorDto.of(
rowNumber,
"SYSTEM",
ex.getMessage()
)
);
}
}
UserInfoDto dto = UserInfoDto.from(uploadDto, roleCd, regUser);
if (!forceCmpn.isBlank()) {
dto.setUserCmpn(forceCmpn);
}
return ExcelUploadResultUtil.buildUploadResult(
totalCount,
successCount,
errorList,
UserUploadErrorDto.class,
"user_upload_errors.xlsx"
int rowNumber = i + 2; // 엑셀 실제 행 번호 (헤더가 1행일 때)
// 1) 값 검증
List<UserUploadErrorDto> rowErrors = validateUserDtoForExcel(dto, rowNumber, roleList,
intranetUserList);
if (!rowErrors.isEmpty()) {
errorList.addAll(rowErrors);
continue; // 이 행은 DB 저장 스킵
}
// 2) 실제 DB 저장
try {
this.createUserInternal(dto, regUser, regDt);
successCount++;
} catch (BusinessException ex) {
// 시스템/비즈니스 예외도 에러 목록에 추가
errorList.add(
UserUploadErrorDto.of(
rowNumber,
"SYSTEM",
ex.getMessage()
)
);
}
}
public byte[] exportUserTemplate() {
try (Workbook workbook =
ExcelMapper.writeToWorkbook(Collections.emptyList(), UserUploadDto.class);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
return ExcelUploadResultUtil.buildUploadResult(
totalCount,
successCount,
errorList,
UserUploadErrorDto.class,
"user_upload_errors.xlsx"
);
}
workbook.write(out);
return out.toByteArray();
} catch (Exception e) {
throw BusinessException.internalError("사용자 업로드 템플릿 엑셀 생성 중 오류");
}
public byte[] exportUserTemplate() {
try (Workbook workbook =
ExcelMapper.writeToWorkbook(Collections.emptyList(), UserUploadDto.class);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
workbook.write(out);
return out.toByteArray();
} catch (Exception e) {
throw BusinessException.internalError("사용자 업로드 템플릿 엑셀 생성 중 오류");
}
}
public DataVerificationDto checkUserId(String userId) {
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
return this.verifyUserId(userId, intranetUserList);
}
public DataVerificationDto checkUserId(String userId) {
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
return this.verifyUserId(userId, intranetUserList);
}
public UserInfoDto getUser(String userId) {
TUserEntity user = userRepository.findByUserIdAndDelFalse(userId)
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", userId)
);
UserInfoDto userInfoDto = UserInfoDto.from(user);
userInfoDto.setUserPw(user.getUserPw());
return userInfoDto;
}
public TUserEntity getUser(String userId, String userPw) {
return userRepository.findByUserIdAndUserPwAndDelFalse(userId, userPw)
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", userId)
);
}
public List<UserInfoDto> getUserList() {
return userRepository.findByDelFalse().stream()
.map(UserInfoDto::from)
.toList();
}
public List<UserInfoDto> getFieldworkUserListWithCmpn(String searchCmpn) {
List<TUserEntity> userList;
if(searchCmpn == null || searchCmpn.isBlank()) {
userList = userRepository.findByUserRoleGreaterThanEqualAndDelFalse(ContactConstant.FIELDWORK_USER_ROLE);
}
else{
userList = userRepository.findByUserCmpnAndUserRoleGreaterThanEqualAndDelFalse(searchCmpn, ContactConstant.FIELDWORK_USER_ROLE);
}
return userList.stream()
.map(UserInfoDto::from)
.toList();
}
public List<UserInfoDto> getOutsourceList() {
List<TUserEntity> userList = userRepository.findByRoleRangeAndDelFalse(
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
public UserInfoDto getUser(String userId) {
TUserEntity user = userRepository.findByUserIdAndDelFalse(userId)
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", userId)
);
return userList.stream()
.map(UserInfoDto::from)
.toList();
UserInfoDto userInfoDto = UserInfoDto.from(user);
userInfoDto.setUserPw(user.getUserPw());
return userInfoDto;
}
public TUserEntity getUser(String userId, String userPw) {
return userRepository.findByUserIdAndUserPwAndDelFalse(userId, userPw)
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", userId)
);
}
public List<UserInfoDto> getUserList() {
return userRepository.findByDelFalse().stream()
.map(UserInfoDto::from)
.toList();
}
public List<UserInfoDto> getFieldworkUserListWithCmpn(String searchCmpn) {
List<TUserEntity> userList;
if (searchCmpn == null || searchCmpn.isBlank()) {
userList = userRepository.findByUserRoleGreaterThanEqualAndDelFalse(
ContactConstant.FIELDWORK_USER_ROLE);
} else {
userList = userRepository.findByUserCmpnAndUserRoleGreaterThanEqualAndDelFalse(searchCmpn,
ContactConstant.FIELDWORK_USER_ROLE);
}
public List<String> getUserCmpnList() {
return userRepository.findDistinctUserCmpnAndDelFalse();
return userList.stream()
.map(UserInfoDto::from)
.toList();
}
public List<UserInfoDto> getOutsourceList() {
List<TUserEntity> userList = userRepository.findByRoleRangeAndDelFalse(
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
);
return userList.stream()
.map(UserInfoDto::from)
.toList();
}
public List<String> getUserCmpnList() {
return userRepository.findDistinctUserCmpnAndDelFalse();
}
@Transactional
public void updateUser(UserInfoDto dto, String modUser, LocalDateTime modDt) {
// dirty checking 업데이트
TUserEntity entity = userRepository.findByUserIdAndDelFalse(dto.getUserId())
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.")
.with("userId", dto.getUserId())
);
entity.updateFromDto(dto, modUser, modDt);// 기존 엔티티에 적용
}
@Transactional
public void deleteUser(String userId, String delUser) {
int deleteCount = userRepository.softDeleteByUserId(userId, delUser,
DateTimeUtil.nowKstLocalDateTime());
if (deleteCount == 0) {
throw BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.")
.with("userId", userId);
}
}
/*******************************private*******************************/
private DataVerificationDto verifyUserId(String userId, List<String> intranetUserList) {
if (userId == null || userId.isBlank()) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID가 비었습니다.");
}
if (userId.length() < 3 || userId.length() > 16) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID는 3~15 자리여야 합니다.");
}
if (!userId.matches("^[a-z가-힣][a-z0-9가-힣]+$")) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID는 한글, 영소문자, 숫자만 허용합니다.");
}
if (userRepository.existsByUserIdAndDelFalse(userId)) {
return new DataVerificationDto(false, "사용자 ID", "이미 사용중인 ID입니다.");
}
if (intranetUserList.contains(userId) || intranetUserList.contains(
String.format("%s@kric.com", userId))) {
return new DataVerificationDto(false, "사용자 ID", "이미 사용중인 직원 ID입니다.");
}
@Transactional
public void updateUser(UserInfoDto dto, String modUser, LocalDateTime modDt) {
// dirty checking 업데이트
TUserEntity entity = userRepository.findByUserIdAndDelFalse(dto.getUserId())
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.")
.with("userId", dto.getUserId())
);
return new DataVerificationDto();
}
entity.updateFromDto(dto, modUser, modDt);// 기존 엔티티에 적용
private List<DataVerificationDto> validateUserDto(
UserInfoDto dto,
List<RoleInfoDto> roleList,
List<String> intranetUserList
) {
List<DataVerificationDto> result = new ArrayList<>();
// 0. userId 기본 검증 (기존 로직)
result.add(this.verifyUserId(dto.getUserId(), intranetUserList));
// 1. userPw 비어있는지 / PW 정규식 검사
String userPw = dto.getUserPw();
if (userPw == null || userPw.isBlank()) {
result.add(new DataVerificationDto(
false,
"사용자 PW",
"비밀번호가 비어 있습니다."
));
} else {
// 예시: 8~20자, 영문 + 숫자 반드시 포함, 특수문자 허용
String pwPattern = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d!@#$%^&*()_+\\-={}\\[\\]:;\"'<>,.?/]{8,20}$";
if (!userPw.matches(pwPattern)) {
result.add(new DataVerificationDto(
false,
"사용자 PW",
"비밀번호는 영문과 숫자를 포함한 8~20자로 입력해야 합니다."
));
}
}
@Transactional
public void deleteUser(String userId, String delUser) {
int deleteCount = userRepository.softDeleteByUserId(userId, delUser, DateTimeUtil.nowKstLocalDateTime());
if(deleteCount == 0) {
throw BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.")
.with("userId", userId);
}
// 2. userName 비어있는지 / 한글·영문 대소문자만 허용
String userName = dto.getUserName();
if (userName == null || userName.isBlank()) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름이 비어 있습니다."
));
} else if (!userName.matches("^[가-힣A-Za-z][가-힣A-Za-z0-9_ ()]*$")) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름은 한글/영문으로 시작해야 하며, 한글/영문/숫자와 공백, '(', ')', '_'만 입력 가능합니다."
));
}
/*******************************private*******************************/
private DataVerificationDto verifyUserId(String userId, List<String> intranetUserList) {
if(userId == null || userId.isBlank()) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID가 비었습니다.");
}
if (userId.length() < 3 || userId.length() > 16 ) {
return new DataVerificationDto(false,"사용자 ID", "사용자 ID는 3~15 자리여야 합니다.");
}
if (!userId.matches("^[a-z가-힣][a-z0-9가-힣]+$")) {
return new DataVerificationDto(false,"사용자 ID", "사용자 ID는 한글, 영소문자, 숫자만 허용합니다.");
}
if(userRepository.existsByUserIdAndDelFalse(userId)) {
return new DataVerificationDto(false,"사용자 ID", "이미 사용중인 ID입니다.");
}
if(intranetUserList.contains(userId) || intranetUserList.contains(String.format("%s@kric.com", userId))) {
return new DataVerificationDto(false,"사용자 ID", "이미 사용중인 직원 ID입니다.");
}
return new DataVerificationDto();
// 3. userCmpn 비어있는지 / 한글, 영문, 숫자, 공백, (, ) 만 허용
String userCmpn = dto.getUserCmpn();
if (userCmpn == null || userCmpn.isBlank()) {
result.add(new DataVerificationDto(
false,
"사용자 소속 회사",
"사용자 소속 회사가 비어 있습니다."
));
} else if (!userCmpn.matches("^[가-힣A-Za-z0-9() ]+$")) {
result.add(new DataVerificationDto(
false,
"사용자 소속 회사",
"사용자 소속 회사는 한글, 영문, 숫자, 공백, '(', ')'만 사용할 수 있습니다."
));
}
private List<DataVerificationDto> validateUserDto(
UserInfoDto dto,
List<RoleInfoDto> roleList,
List<String> intranetUserList
) {
List<DataVerificationDto> result = new ArrayList<>();
// 4. userRole 이 roleList의 roleNm에 존재하는지 체크
Integer userRole = dto.getUserRole();
if (roleList != null && !roleList.isEmpty()) {
boolean exists = roleList.stream()
.anyMatch(r -> userRole.equals(r.getRoleCd()));
// 0. userId 기본 검증 (기존 로직)
result.add(this.verifyUserId(dto.getUserId(), intranetUserList));
// 1. userPw 비어있는지 / PW 정규식 검사
String userPw = dto.getUserPw();
if (userPw == null || userPw.isBlank()) {
result.add(new DataVerificationDto(
false,
"사용자 PW",
"비밀번호가 비어 있습니다."
));
} else {
// 예시: 8~20자, 영문 + 숫자 반드시 포함, 특수문자 허용
String pwPattern = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d!@#$%^&*()_+\\-={}\\[\\]:;\"'<>,.?/]{8,20}$";
if (!userPw.matches(pwPattern)) {
result.add(new DataVerificationDto(
false,
"사용자 PW",
"비밀번호는 영문과 숫자를 포함한 8~20자로 입력해야 합니다."
));
}
}
// 2. userName 비어있는지 / 한글·영문 대소문자만 허용
String userName = dto.getUserName();
if (userName == null || userName.isBlank()) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름이 비어 있습니다."
));
} else if (!userName.matches("^[가-힣A-Za-z][가-힣A-Za-z0-9_ ()]*$")) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름은 한글/영문으로 시작해야 하며, 한글/영문/숫자와 공백, '(', ')', '_'만 입력 가능합니다."
));
}
// 3. userCmpn 비어있는지 / 한글, 영문, 숫자, 공백, (, ) 만 허용
String userCmpn = dto.getUserCmpn();
if (userCmpn == null || userCmpn.isBlank()) {
result.add(new DataVerificationDto(
false,
"사용자 소속 회사",
"사용자 소속 회사가 비어 있습니다."
));
} else if (!userCmpn.matches("^[가-힣A-Za-z0-9() ]+$")) {
result.add(new DataVerificationDto(
false,
"사용자 소속 회사",
"사용자 소속 회사는 한글, 영문, 숫자, 공백, '(', ')'만 사용할 수 있습니다."
));
}
// 4. userRole 이 roleList의 roleNm에 존재하는지 체크
Integer userRole = dto.getUserRole();
if (roleList != null && !roleList.isEmpty()) {
boolean exists = roleList.stream()
.anyMatch(r -> userRole.equals(r.getRoleCd()));
if (!exists) {
result.add(new DataVerificationDto(
false,
"사용자 권한",
"사용자 권한이 잘 못 됐습니다."
));
}
}
return result;
if (!exists) {
result.add(new DataVerificationDto(
false,
"사용자 권한",
"사용자 권한이 잘 못 됐습니다."
));
}
}
private List<UserUploadErrorDto> validateUserDtoForExcel(
UserInfoDto dto,
int rowNumber,
List<RoleInfoDto> roleList,
List<String> intranetUserList
) {
List<UserUploadErrorDto> errors = new ArrayList<>();
return result;
}
List<DataVerificationDto> validateUserList = this.validateUserDto(dto, roleList, intranetUserList);
private List<UserUploadErrorDto> validateUserDtoForExcel(
UserInfoDto dto,
int rowNumber,
List<RoleInfoDto> roleList,
List<String> intranetUserList
) {
List<UserUploadErrorDto> errors = new ArrayList<>();
validateUserList.forEach(validateResult -> {
if(!validateResult.isSuccess()) {
errors.add(UserUploadErrorDto.of(
rowNumber,
validateResult.getFieldName(),
validateResult.getErrMessage()
));
}
});
List<DataVerificationDto> validateUserList = this.validateUserDto(dto, roleList,
intranetUserList);
return errors;
}
validateUserList.forEach(validateResult -> {
if (!validateResult.isSuccess()) {
errors.add(UserUploadErrorDto.of(
rowNumber,
validateResult.getFieldName(),
validateResult.getErrMessage()
));
}
});
private void createUserInternal(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
userInfo.setUserId(userInfo.getUserId().toLowerCase());
userInfo.setUserTeam("S101");
return errors;
}
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
userRepository.save(entity);
}
private void createUserInternal(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
userInfo.setUserId(userInfo.getUserId().toLowerCase());
userInfo.setUserTeam("S101");
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
userRepository.save(entity);
}
}

View File

@@ -27,7 +27,7 @@ kri:
security:
enabled: true
public-paths: # 인증 없이 열어둘 URL
public-paths: # 인증 없이 열어둘 URL
- /v3/api-docs/**
- /swagger-ui.html
- /swagger-ui/**

View File

@@ -6,8 +6,8 @@ import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ContactServerApplicationTests {
@Test
void contextLoads() {
}
@Test
void contextLoads() {
}
}