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

@@ -20,7 +20,7 @@ configurations {
} }
} }
def giteaUser = findProperty("giteaUser") ?: "" def giteaUser = findProperty("giteaUser") ?: ""
def giteaToken = findProperty("giteaToken") ?: "" def giteaToken = findProperty("giteaToken") ?: ""
repositories { repositories {
@@ -81,7 +81,7 @@ def querydslDir = layout.buildDirectory.dir("generated/querydsl").get().asFile
sourceSets { sourceSets {
// Q클래스가 있는 디렉토리를 main 소스에 추가 // Q클래스가 있는 디렉토리를 main 소스에 추가
main.java.srcDirs += [ querydslDir ] main.java.srcDirs += [querydslDir]
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {

View File

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

View File

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

View File

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

View File

@@ -9,18 +9,22 @@ import lombok.RequiredArgsConstructor;
@Getter(onMethod_ = @JsonValue) // Lombok이 생성하는 getCode()에 @JsonValue 부착 @Getter(onMethod_ = @JsonValue) // Lombok이 생성하는 getCode()에 @JsonValue 부착
@RequiredArgsConstructor @RequiredArgsConstructor
public enum ProjectStatus implements CodeEnum<Short> { public enum ProjectStatus implements CodeEnum<Short> {
STANDBY((short) 0), // 대기 STANDBY((short) 0), // 대기
PROGRESS((short) 1), // 진행 PROGRESS((short) 1), // 진행
COMPELETE((short) 10); // 완료 COMPELETE((short) 10); // 완료
private final Short code; private final Short code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ProjectStatus fromCode(Short code) { public static ProjectStatus fromCode(Short code) {
if (code == null) return null; if (code == null) {
for (ProjectStatus s : values()) { return null;
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown ProjectStatus code: " + code);
} }
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 @RequiredArgsConstructor
public enum ResultCodeType implements CodeEnum<Short> { public enum ResultCodeType implements CodeEnum<Short> {
CONTACT((short) 0), // 컨택 결과코드 CONTACT((short) 0), // 컨택 결과코드
INTERVIEW((short) 1), // 면접 결과코드 INTERVIEW((short) 1), // 면접 결과코드
SURVEY((short) 2); // 설문 결과코드 SURVEY((short) 2); // 설문 결과코드
private final Short code; private final Short code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static ResultCodeType fromCode(Short code) { public static ResultCodeType fromCode(Short code) {
if (code == null) return null; if (code == null) {
for (ResultCodeType s : values()) { return null;
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown ResultCodeType code: " + code);
} }
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) @Getter(onMethod_ = @JsonValue)
@RequiredArgsConstructor @RequiredArgsConstructor
public enum SurveyType implements CodeEnum<Short> { public enum SurveyType implements CodeEnum<Short> {
NONE((short) 0), // 없음 NONE((short) 0), // 없음
KON((short) 1), // KON KON((short) 1), // KON
KIWI((short) 2), // KIWI KIWI((short) 2), // KIWI
EXTERNAL((short) 99); // 외부 EXTERNAL((short) 99); // 외부
private final Short code; private final Short code;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static SurveyType fromCode(Short code) { public static SurveyType fromCode(Short code) {
if (code == null) return null; if (code == null) {
for (SurveyType s : values()) { return null;
if (s.code == code) return s;
}
throw new IllegalArgumentException("Unknown SurveyType code: " + code);
} }
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; package com.kri.contact.server.common.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import com.kri.common.enums.CodeEnum; import com.kri.common.enums.CodeEnum;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -8,28 +7,28 @@ import lombok.RequiredArgsConstructor;
@Getter @Getter
@RequiredArgsConstructor @RequiredArgsConstructor
public enum SystemEventType implements CodeEnum<Short> { public enum SystemEventType implements CodeEnum<Short> {
//1의 자리 1 insert, 2 update, 3 delete, 4 upload //1의 자리 1 insert, 2 update, 3 delete, 4 upload
//100의 자리 대분류, 10의 자리 소분류 //100의 자리 대분류, 10의 자리 소분류
LOGIN((short) 111), // 로그인 LOGIN((short) 111), // 로그인
LOGOUT((short) 121), // 로그 아웃 LOGOUT((short) 121), // 로그 아웃
CREATE_PROJECT((short) 211), // 프로젝트 생성 CREATE_PROJECT((short) 211), // 프로젝트 생성
UPDATE_PROJECT((short) 212), // 프로젝트 수정 UPDATE_PROJECT((short) 212), // 프로젝트 수정
DELETE_PROJECT((short) 213), // 프로젝트 삭제 DELETE_PROJECT((short) 213), // 프로젝트 삭제
ASSIGN_PROJECT_USER((short) 222), // 프로젝트 배정 ASSIGN_PROJECT_USER((short) 222), // 프로젝트 배정
UPDATE_PROJECT_DEFAULT_TEMPLATE((short) 232), // 기본 템플릿 수정 UPDATE_PROJECT_DEFAULT_TEMPLATE((short) 232), // 기본 템플릿 수정
CREATE_USER((short) 311), // 사용자 생성 CREATE_USER((short) 311), // 사용자 생성
UPDATE_USER((short) 312), // 사용자 수정 UPDATE_USER((short) 312), // 사용자 수정
DELETE_USER((short) 313), // 사용자 삭제 DELETE_USER((short) 313), // 사용자 삭제
UPLOAD_USER((short) 314), // 사용자 삭제 UPLOAD_USER((short) 314), // 사용자 삭제
CREATE_ROLE((short) 411), // 권한 생성 CREATE_ROLE((short) 411), // 권한 생성
UPDATE_ROLE((short) 412), // 권한 수정 UPDATE_ROLE((short) 412), // 권한 수정
DELETE_ROLE((short) 413), // 권한 삭제 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; 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.ExternalApiClient;
import com.kri.common.http.ExternalApiResponse;
import com.kri.contact.server.dto.LoginRequestDto; import com.kri.contact.server.dto.LoginRequestDto;
import java.util.Collections; 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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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 클라이언트. * 공통 모듈로 분리하기 위한 외부(Intranet-Extension) 인증 API 클라이언트. 현재 프로젝트 내에 두되, 이후 common 리포지토리로 이동이 용이하도록
* 현재 프로젝트 내에 두되, 이후 common 리포지토리로 이동이 용이하도록
* contact-server 의 도메인(Service) 코드와 분리한다. * contact-server 의 도메인(Service) 코드와 분리한다.
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class IntranetExtensionApiClient { public class IntranetExtensionApiClient {
@Value("${kri.api-url.intranet-extension}") // ExternalApiClient 를 직접 생성해 사용 (starter에서 Bean 미제공 시 대비)
private String intranetExtensionBaseUrl; 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}") public SearchLoginInfoResponseDto searchLoginInfo(LoginRequestDto request) {
private String apiKeyHeaderName; 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}") return objectMapper.readValue(response.getBody(), SearchLoginInfoResponseDto.class);
private String apiKey; } catch (JsonProcessingException e) {
return null;
// 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;
}
} }
}
public List<String> getUserIdArray() { public List<String> getUserIdArray() {
String url = String.format("%s/user/user-id-list", intranetExtensionBaseUrl); String url = String.format("%s/user/user-id-list", intranetExtensionBaseUrl);
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put(apiKeyHeaderName, apiKey); headers.put(apiKeyHeaderName, apiKey);
try { try {
ExternalApiResponse response = externalApiClient.get(url, headers); ExternalApiResponse response = externalApiClient.get(url, headers);
return objectMapper.readValue( return objectMapper.readValue(
response.getBody(), response.getBody(),
new com.fasterxml.jackson.core.type.TypeReference<List<String>>() {} new com.fasterxml.jackson.core.type.TypeReference<List<String>>() {
); }
} catch (JsonProcessingException e) { );
return Collections.emptyList(); } catch (JsonProcessingException e) {
} return Collections.emptyList();
} }
}
} }

View File

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

View File

@@ -6,7 +6,8 @@ import jakarta.persistence.Converter;
@Converter(autoApply = false) @Converter(autoApply = false)
public class ResultCodeTypeConverter extends AbstractCodeEnumConverter<ResultCodeType, Short> { 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.common.excel.ExcelMapper;
import com.kri.contact.server.dto.ExcelUploadResponseDto; import com.kri.contact.server.dto.ExcelUploadResponseDto;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import org.apache.poi.ss.usermodel.Workbook;
public final class ExcelUploadResultUtil { public final class ExcelUploadResultUtil {
private ExcelUploadResultUtil() {} private ExcelUploadResultUtil() {
}
/** /**
* 엑셀 업로드 결과 + 에러 엑셀 생성까지 공통 처리. * 엑셀 업로드 결과 + 에러 엑셀 생성까지 공통 처리.
* *
* @param totalCount 전체 행 수 * @param totalCount 전체 행 수
* @param successCount 성공 개수 * @param successCount 성공 개수
* @param errorList 에러 DTO 리스트 * @param errorList 에러 DTO 리스트
* @param errorClass 에러 DTO 타입 (ExcelMapper용) * @param errorClass 에러 DTO 타입 (ExcelMapper용)
* @param errorFileName 에러 엑셀 파일명 * @param errorFileName 에러 엑셀 파일명
*/ */
public static <E> ExcelUploadResponseDto buildUploadResult( public static <E> ExcelUploadResponseDto buildUploadResult(
int totalCount, int totalCount,
int successCount, int successCount,
List<E> errorList, List<E> errorList,
Class<E> errorClass, Class<E> errorClass,
String errorFileName String errorFileName
) { ) {
int failCount = (errorList != null) ? errorList.size() : 0; int failCount = (errorList != null) ? errorList.size() : 0;
// 1) 에러가 없으면 파일 없이 반환 // 1) 에러가 없으면 파일 없이 반환
if (failCount == 0) { if (failCount == 0) {
return ExcelUploadResponseDto.builder() return ExcelUploadResponseDto.builder()
.totalCount(totalCount) .totalCount(totalCount)
.successCount(successCount) .successCount(successCount)
.failCount(0) .failCount(0)
.hasErrorFile(false) .hasErrorFile(false)
.build(); .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();
}
} }
// 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; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import lombok.RequiredArgsConstructor;
import jakarta.persistence.EntityManager;
import com.querydsl.jpa.impl.JPAQueryFactory;
@Configuration @Configuration
@RequiredArgsConstructor @RequiredArgsConstructor
public class QueryDSLConfig { public class QueryDSLConfig {
private final EntityManager entityManager; private final EntityManager entityManager;
@Bean @Bean
public JPAQueryFactory jpaQueryFactory() { public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager); return new JPAQueryFactory(entityManager);
} }
} }

View File

@@ -8,13 +8,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration @Configuration
public class WebResourceConfig implements WebMvcConfigurer { public class WebResourceConfig implements WebMvcConfigurer {
@Value("${kri.contact-senario.upload-base-dir}") @Value("${kri.contact-senario.upload-base-dir}")
private String uploadBaseDir; private String uploadBaseDir;
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
// /contact-senario/** → /data/upload-file/contact-senario/** 매핑 // /contact-senario/** → /data/upload-file/contact-senario/** 매핑
registry.addResourceHandler("/contact-senario/**") registry.addResourceHandler("/contact-senario/**")
.addResourceLocations("file:" + uploadBaseDir + "/"); .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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; 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 @RestController
@RequestMapping("/api/v1/assign") @RequestMapping("/api/v1/assign")
@@ -19,30 +23,31 @@ import java.util.List;
@Tag(name = "Assign", description = "배정 API") @Tag(name = "Assign", description = "배정 API")
public class AssignController { public class AssignController {
private final SystemEventLogService systemEventLogService; private final SystemEventLogService systemEventLogService;
private final AssignService assignService; private final AssignService assignService;
@Operation(summary = "배정된 외주사 조회") @Operation(summary = "배정된 외주사 조회")
@GetMapping("/prjct-outsource/{prjctIdx}") @GetMapping("/prjct-outsource/{prjctIdx}")
public List<String> getPrjctOutsourceAssign(@PathVariable Long prjctIdx) { public List<String> getPrjctOutsourceAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctOutsourceAssign(prjctIdx); return assignService.getPrjctOutsourceAssign(prjctIdx);
} }
@Operation(summary = "배정된 컨택원/면접원 조회") @Operation(summary = "배정된 컨택원/면접원 조회")
@GetMapping("/prjct-fieldwork/{prjctIdx}") @GetMapping("/prjct-fieldwork/{prjctIdx}")
public List<String> getPrjctFieldworkAssign(@PathVariable Long prjctIdx) { public List<String> getPrjctFieldworkAssign(@PathVariable Long prjctIdx) {
return assignService.getPrjctFieldworkAssign(prjctIdx); return assignService.getPrjctFieldworkAssign(prjctIdx);
} }
@Operation(summary = "컨택원/면접원 배정") @Operation(summary = "컨택원/면접원 배정")
@PutMapping("/prjct-fieldwork/{prjctIdx}") @PutMapping("/prjct-fieldwork/{prjctIdx}")
public void upsertPrjctFieldworkAssign( public void upsertPrjctFieldworkAssign(
@PathVariable Long prjctIdx, @PathVariable Long prjctIdx,
@Valid @RequestBody List<String> assignUserIdList, @Valid @RequestBody List<String> assignUserIdList,
RequestUserContext ctx RequestUserContext ctx
) { ) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime(); final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now); assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, assignUserIdList); 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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime; 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 @RestController
@RequestMapping("/api/v1/auth") @RequestMapping("/api/v1/auth")
@RequiredArgsConstructor @RequiredArgsConstructor
@Tag(name = "Auth", description = "인증 API") @Tag(name = "Auth", description = "인증 API")
public class AuthController { public class AuthController {
private final AuthService authService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "로그인 요청") private final AuthService authService;
@PostMapping("/login") private final SystemEventLogService systemEventLogService;
public LoginResponseDto tryLogin(
@Valid @RequestBody LoginRequestDto request,
RequestUserContext ctx
) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
LoginResponseDto response = authService.tryLogin(request); @Operation(summary = "로그인 요청")
systemEventLogService.writeLoginLog(response.getUser().getUserId(), now, ctx.getClientIp()); @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 = "로그아웃 요청") return response;
@PostMapping("/logout/{userId}") }
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
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.RequestUserContext;
import com.kri.common.webmvc.page.PageResponseDto; import com.kri.common.webmvc.page.PageResponseDto;
import com.kri.contact.server.common.enums.ChannelType; 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.FileService;
import com.kri.contact.server.service.ProjectService; import com.kri.contact.server.service.ProjectService;
import com.kri.contact.server.service.SystemEventLogService; import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; 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.time.LocalDateTime;
import java.util.List; 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 @RestController
@RequestMapping("/api/v1/project") @RequestMapping("/api/v1/project")
@@ -24,109 +37,113 @@ import java.util.List;
@Tag(name = "Project", description = "프로젝트 API") @Tag(name = "Project", description = "프로젝트 API")
public class ProjectController { public class ProjectController {
private final SystemEventLogService systemEventLogService; private final SystemEventLogService systemEventLogService;
private final ProjectService projectService; private final ProjectService projectService;
private final FileService fileService; private final FileService fileService;
@Operation(summary = "프로젝트 조회") @Operation(summary = "프로젝트 조회")
@GetMapping("/{prjctIdx}") @GetMapping("/{prjctIdx}")
public ProjectInfoDto getProject(@PathVariable Long prjctIdx) { public ProjectInfoDto getProject(@PathVariable Long prjctIdx) {
return projectService.getProject(prjctIdx); return projectService.getProject(prjctIdx);
} }
@Operation(summary = "상위 프로젝트 조회(생성일자 늦은 순)") @Operation(summary = "상위 프로젝트 조회(생성일자 늦은 순)")
@GetMapping("/top/{topCount}") @GetMapping("/top/{topCount}")
public List<ProjectInfoDto> getTopProject( public List<ProjectInfoDto> getTopProject(
@PathVariable int topCount, @PathVariable int topCount,
@RequestParam(required = false) String keyword, @RequestParam(required = false) String keyword,
RequestUserContext ctx RequestUserContext ctx
) { ) {
return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserRole()); return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserRole());
} }
@Operation(summary = "프로젝트 목록 조회") @Operation(summary = "프로젝트 목록 조회")
@PostMapping("/list") @PostMapping("/list")
public PageResponseDto<ProjectInfoDto> searchProject( public PageResponseDto<ProjectInfoDto> searchProject(
@Valid @RequestBody ProjectSearchRequestDto req, @Valid @RequestBody ProjectSearchRequestDto req,
RequestUserContext ctx RequestUserContext ctx
) { ) {
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole()); return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole());
} }
@Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회") @Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회")
@GetMapping("/owner-list") @GetMapping("/owner-list")
public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) { public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) {
return projectService.getOwnerList(ctx.getUserRole()); return projectService.getOwnerList(ctx.getUserRole());
} }
//프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기 //프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기
@Operation(summary = "프로젝트 대표 발송 템플릿 조회") @Operation(summary = "프로젝트 대표 발송 템플릿 조회")
@GetMapping("/main-template/{prjctIdx}/{chnnlTy}") @GetMapping("/main-template/{prjctIdx}/{chnnlTy}")
public Long getMainTemplateIdx( public Long getMainTemplateIdx(
@PathVariable Long prjctIdx, @PathVariable Long prjctIdx,
@PathVariable ChannelType chnnlTy @PathVariable ChannelType chnnlTy
){ ) {
return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode()); return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode());
} }
@Operation(summary = "프로젝트 생성") @Operation(summary = "프로젝트 생성")
@PutMapping() @PutMapping()
public ProjectInfoDto createProject( public ProjectInfoDto createProject(
@Valid @RequestBody ProjectCreateRequestDto req, @Valid @RequestBody ProjectCreateRequestDto req,
RequestUserContext ctx RequestUserContext ctx
) { ) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime(); final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now); ProjectInfoDto prjctInfo = projectService.createProject(req, ctx.getUserId(), now);
systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctInfo.getPrjctIdx(), req); systemEventLogService.writeCreateProject(ctx.getUserId(), now, ctx.getClientIp(),
prjctInfo.getPrjctIdx(), req);
return prjctInfo; return prjctInfo;
} }
@Operation(summary = "시나리오 이미지 업로드") @Operation(summary = "시나리오 이미지 업로드")
@PutMapping("/senario-image/{prjctCd}") @PutMapping("/senario-image/{prjctCd}")
public String uploadContactSenarioImage(@PathVariable String prjctCd, @RequestParam("file") MultipartFile file) { public String uploadContactSenarioImage(@PathVariable String prjctCd,
return fileService.storeTempFile(prjctCd, file); @RequestParam("file") MultipartFile file) {
} return fileService.storeTempFile(prjctCd, file);
}
@Operation(summary = "프로젝트 수정") @Operation(summary = "프로젝트 수정")
@PatchMapping("/{prjctIdx}") @PatchMapping("/{prjctIdx}")
public void updateProject( public void updateProject(
@PathVariable long prjctIdx, @PathVariable long prjctIdx,
@Valid @RequestBody ProjectUpdateRequestDto req, @Valid @RequestBody ProjectUpdateRequestDto req,
RequestUserContext ctx RequestUserContext ctx
) { ) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime(); final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
String newHtml = fileService.syncOnSave( String newHtml = fileService.syncOnSave(
req.getProjectInfo().getPrjctCd(), req.getProjectInfo().getPrjctCd(),
req.getProjectInfo().getContactSenario() req.getProjectInfo().getContactSenario()
); );
req.getProjectInfo().setContactSenario(newHtml); req.getProjectInfo().setContactSenario(newHtml);
projectService.updateProject(prjctIdx, req, ctx.getUserId(), now); projectService.updateProject(prjctIdx, req, ctx.getUserId(), now);
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req); systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx,
} req);
}
@Operation(summary = "프로젝트 대표 발송 템플릿 지정") @Operation(summary = "프로젝트 대표 발송 템플릿 지정")
@PatchMapping("/main-template") @PatchMapping("/main-template")
public void updateProjectMainTemplate( public void updateProjectMainTemplate(
@Valid @RequestBody ProjectMainTemplateUpdateRequestDto req, @Valid @RequestBody ProjectMainTemplateUpdateRequestDto req,
RequestUserContext ctx RequestUserContext ctx
) { ) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime(); final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.updateProjectMainTemplate(req, ctx.getUserId(), now); projectService.updateProjectMainTemplate(req, ctx.getUserId(), now);
systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(), req); systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(),
} req);
}
@Operation(summary = "프로젝트 삭제(소프트 삭제)") @Operation(summary = "프로젝트 삭제(소프트 삭제)")
@DeleteMapping("/{prjctIdx}") @DeleteMapping("/{prjctIdx}")
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) { public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime(); final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
projectService.deleteProject(prjctIdx, ctx.getUserId(), now); projectService.deleteProject(prjctIdx, ctx.getUserId(), now);
systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx); systemEventLogService.writeDeleteProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
} }
} }

View File

@@ -1,16 +1,18 @@
package com.kri.contact.server.controller; 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.common.enums.ResultCodeType;
import com.kri.contact.server.dto.ResultCodeDto; import com.kri.contact.server.dto.ResultCodeDto;
import com.kri.contact.server.service.ResultCodeService; import com.kri.contact.server.service.ResultCodeService;
import com.kri.contact.server.service.SystemEventLogService; import com.kri.contact.server.service.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List; 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 @RestController
@RequestMapping("/api/v1/result-code") @RequestMapping("/api/v1/result-code")
@@ -18,15 +20,15 @@ import java.util.List;
@Tag(name = "Result Code", description = "결과 코드 API") @Tag(name = "Result Code", description = "결과 코드 API")
public class ResultCodeController { public class ResultCodeController {
private final SystemEventLogService systemEventLogService; private final SystemEventLogService systemEventLogService;
private final ResultCodeService resultCodeService; private final ResultCodeService resultCodeService;
@Operation(summary = "결과 코드 조회") @Operation(summary = "결과 코드 조회")
@GetMapping("/{prjctIdx}") @GetMapping("/{prjctIdx}")
public List<ResultCodeDto> getResultCodeList( public List<ResultCodeDto> getResultCodeList(
@PathVariable long prjctIdx, @PathVariable long prjctIdx,
@RequestParam(required = false) ResultCodeType resultCdTy @RequestParam(required = false) ResultCodeType resultCdTy
) { ) {
return resultCodeService.getResultCode(prjctIdx, 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 com.kri.contact.server.service.RoleService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController @RestController
@RequestMapping("/api/v1/role") @RequestMapping("/api/v1/role")
@RequiredArgsConstructor @RequiredArgsConstructor
@Tag(name = "Role", description = "권한 관리 API") @Tag(name = "Role", description = "권한 관리 API")
public class RoleController { public class RoleController {
private final RoleService roleService;
@Operation(summary = "권한 목록 조회") private final RoleService roleService;
@GetMapping()
public List<RoleInfoDto> getRoleList(RequestUserContext ctx) { @Operation(summary = "권한 목록 조회")
return roleService.getRoleList(ctx.getUserRole()); @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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; 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 org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
@RestController @RestController
@RequestMapping("/api/v1/user") @RequestMapping("/api/v1/user")
@RequiredArgsConstructor @RequiredArgsConstructor
@Tag(name = "User", description = "사용자 관리 API") @Tag(name = "User", description = "사용자 관리 API")
public class UserController { public class UserController {
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "ID 가용 여부 검사") private final UserService userService;
@GetMapping("/check-user-id") private final SystemEventLogService systemEventLogService;
public DataVerificationDto checkUserId(@RequestParam String userId) {
return userService.checkUserId(userId); @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 = "사용자 정보 조회") return userService.getFieldworkUserListWithCmpn(searchCmpn);
@GetMapping("/{userId}") }
public UserInfoDto getUser(@PathVariable String userId) {
return userService.getUser(userId); @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 = "사용자 목록 조회") return Collections.emptyList();
@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 = "컨택원/면접원 목록 조회") @Operation(summary = "사용자 생성")
@GetMapping("fieldwork") @PutMapping
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx) { public void createUser(
String searchCmpn = ctx.getUserCmpn(); @Valid @RequestBody UserInfoDto userInfo,
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) { RequestUserContext ctx
searchCmpn = ""; ) {
} 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 = "외주사 목록 조회") @Operation(summary = "사용자 일괄 생성(엑셀 업로드)")
@GetMapping("outsource") @PostMapping("/excel")
List<UserInfoDto> getOutsourceList() { public ExcelUploadResponseDto createUserFromExcel(
return userService.getOutsourceList(); @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 = "사용자 회사 목록 조회") ExcelUploadResponseDto result = userService.createUsersFromExcel(file, regId, now, forceCmpn);
@GetMapping("cmpn")
public List<String> getUserCmpnList(RequestUserContext ctx) {
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserCmpnList();
}
return Collections.emptyList(); UploadUserContentDto content = new UploadUserContentDto(
} file.getOriginalFilename(),
file.getContentType(),
file.getSize()
);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
@Operation(summary = "사용자 생성") return result;
@PutMapping }
public void createUser(
@Valid @RequestBody UserInfoDto userInfo,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
userService.createUser(userInfo, regId, now); @Operation(summary = "사용자 일괄 생성 양식 다운로드")
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo); @PostMapping("/excel/template")
} public ResponseEntity<byte[]> exportUserTemplate() {
byte[] bytes = userService.exportUserTemplate();
@Operation(summary = "사용자 일괄 생성(엑셀 업로드)") return ResponseEntity.ok()
@PostMapping("/excel") .header(HttpHeaders.CONTENT_DISPOSITION,
public ExcelUploadResponseDto createUserFromExcel( "attachment; filename=\"user_upload_template.xlsx\"")
@RequestPart("file") MultipartFile file, .contentType(MediaType.parseMediaType(
RequestUserContext ctx "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
) { .body(bytes);
String regId = ctx.getUserId(); }
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
//외주사급이 업로드로 계정을 생성하는 경우 자신의 회사명으로 고정
String forceCmpn = ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE? "" : ctx.getUserCmpn();
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( userService.updateUser(dto, modId, now);
file.getOriginalFilename(), systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
file.getContentType(), }
file.getSize()
);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, content);
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 = "사용자 일괄 생성 양식 다운로드") userService.deleteUser(userId, regId);
@PostMapping("/excel/template") systemEventLogService.writeDeleteUserLog(regId, now, clientIp, userId);
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);
}
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,11 @@
package com.kri.contact.server.dto; package com.kri.contact.server.dto;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List; import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Getter
@Setter @Setter
@@ -11,8 +13,9 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@Schema(description = "프로젝트 담당들 정보") @Schema(description = "프로젝트 담당들 정보")
public class ProjectOwnerResponseDto { public class ProjectOwnerResponseDto {
@Schema(description = "담당 연구 부서")
List<String> ownerDeptList; @Schema(description = "담당 연구 부서")
@Schema(description = "담당 실사 인원") List<String> ownerDeptList;
List<String> ownerFwList; @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 com.kri.common.webmvc.page.PageRequestDto;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Getter @Getter
@Setter @Setter
@Schema(description = "프로젝트 검색 조건") @Schema(description = "프로젝트 검색 조건")
public class ProjectSearchRequestDto { 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 io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@Getter @Getter
@Setter @Setter
@Schema(description = "프로젝트 수정 요청") @Schema(description = "프로젝트 수정 요청")
public class ProjectUpdateRequestDto { public class ProjectUpdateRequestDto {
@NotNull
@Schema(description = "프로젝트 정보")
private ProjectInfoDto projectInfo;
@Schema(description = "프로젝트 수정 되야 할 결과코드") @NotNull
private List<ResultCodeDto> resultCodeList; @Schema(description = "프로젝트 정보")
private ProjectInfoDto projectInfo;
@Schema(description = "배정될 외주 업체 목록") @Schema(description = "프로젝트 수정 되야 할 결과코드")
private List<String> assignUserIdList; 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.common.enums.ResultCodeType;
import com.kri.contact.server.persistence.entity.TResultCodeEntity; import com.kri.contact.server.persistence.entity.TResultCodeEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.UUID;
@Getter @Getter
@Setter @Setter
@Builder @Builder
@Schema(description = "결과 코드") @Schema(description = "결과 코드")
public class ResultCodeDto { public class ResultCodeDto {
@Schema(description = "결과 코드 고유 키")
private String resultCdUUID;
@Schema(description = "프로젝트 인덱스") @Schema(description = "결과 코드 고유 키")
private Long prjctIdx; private String resultCdUUID;
@Schema(description = "결과 코드 타입") @Schema(description = "프로젝트 인덱스")
private ResultCodeType resultCdTy; private Long prjctIdx;
@Schema(description = "결과 코드") @Schema(description = "결과 코드 타입")
private Short resultCd; private ResultCodeType resultCdTy;
@Schema(description = "결과 코드 라벨") @Schema(description = "결과 코드")
private String resultCdLbl; private Short resultCd;
public static ResultCodeDto from(TResultCodeEntity entity) { @Schema(description = "결과 코드 라벨")
return ResultCodeDto.builder() private String resultCdLbl;
.resultCdUUID(UUID.randomUUID().toString())
.prjctIdx(entity.getPrjctIdx()) public static ResultCodeDto from(TResultCodeEntity entity) {
.resultCdTy(entity.getResultCdTy()) return ResultCodeDto.builder()
.resultCd(entity.getResultCd()) .resultCdUUID(UUID.randomUUID().toString())
.resultCdLbl(entity.getResultCdLbl()) .prjctIdx(entity.getPrjctIdx())
.build(); .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.fasterxml.jackson.annotation.JsonProperty;
import com.kri.contact.server.persistence.entity.TRoleEntity; import com.kri.contact.server.persistence.entity.TRoleEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Builder @Builder
@Schema(description = "권한 정보") @Schema(description = "권한 정보")
public class RoleInfoDto { public class RoleInfoDto {
@Schema(description = "권한 코드")
private Integer roleCd;
@Schema(description = "권한 명") @Schema(description = "권한 코드")
private String roleNm; private Integer roleCd;
@Schema(description = "메모") @Schema(description = "권한 명")
private String memo; private String roleNm;
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "메모")
@JsonProperty(access = JsonProperty.Access.READ_ONLY) private String memo;
private String regUser;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY) @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime regDt; private String regUser;
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY) @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser; private LocalDateTime regDt;
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY) @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private LocalDateTime modDt; 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) { public static RoleInfoDto from(TRoleEntity roleEntity) {
return RoleInfoDto.builder() return RoleInfoDto.builder()
.roleCd(roleEntity.getRoleCd()) .roleCd(roleEntity.getRoleCd())
.roleNm(roleEntity.getRoleNm()) .roleNm(roleEntity.getRoleNm())
.memo(roleEntity.getMemo()) .memo(roleEntity.getMemo())
.regUser(roleEntity.getRegUser()) .regUser(roleEntity.getRegUser())
.regDt(roleEntity.getRegDt()) .regDt(roleEntity.getRegDt())
.modUser(roleEntity.getModUser()) .modUser(roleEntity.getModUser())
.modDt(roleEntity.getModDt()) .modDt(roleEntity.getModDt())
.build(); .build();
} }
} }

View File

@@ -8,9 +8,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Getter
@Setter @Setter
@@ -19,82 +22,83 @@ import java.time.LocalDateTime;
@AllArgsConstructor @AllArgsConstructor
@Schema(description = "사용자 정보") @Schema(description = "사용자 정보")
public class UserInfoDto { public class UserInfoDto {
@Size(max = 32)
@NotBlank
@Schema(description = "사용자 ID")
private String userId;
@Size(max = 128) @Size(max = 32)
@NotBlank @NotBlank
@Schema(description = "사용자 PW") @Schema(description = "사용자 ID")
private String userPw; private String userId;
@Size(max = 32) @Size(max = 128)
@NotBlank @NotBlank
@Schema(description = "사용자 이름") @Schema(description = "사용자 PW")
private String userName; private String userPw;
@Size(max = 32) @Size(max = 32)
@NotBlank @NotBlank
@Schema(description = "사용자 소속 회사") @Schema(description = "사용자 이름")
private String userCmpn; private String userName;
@Size(max = 32) @Size(max = 32)
@NotBlank @NotBlank
@Schema(description = "사용자 소속 팀") @Schema(description = "사용자 소속 회사")
private String userTeam = "S101"; private String userCmpn;
@NotNull @Size(max = 32)
@Schema(description = "사용자 권한") @NotBlank
private Integer userRole; @Schema(description = "사용자 소속 팀")
private String userTeam = "S101";
@Schema(description = "메모") @NotNull
private String memo; @Schema(description = "사용자 권한")
private Integer userRole;
@Size(max = 32) @Schema(description = "메모")
@Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY) private String memo;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY) @Size(max = 32)
@JsonProperty(access = JsonProperty.Access.READ_ONLY) @Schema(description = "등록자", accessMode = Schema.AccessMode.READ_ONLY)
private LocalDateTime regDt; @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String regUser;
@Size(max = 32) @Schema(description = "등록일시", accessMode = Schema.AccessMode.READ_ONLY)
@Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY) private LocalDateTime regDt;
private String modUser;
@Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY) @Size(max = 32)
@JsonProperty(access = JsonProperty.Access.READ_ONLY) @Schema(description = "수정자", accessMode = Schema.AccessMode.READ_ONLY)
private LocalDateTime modDt; @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String modUser;
public static UserInfoDto from(TUserEntity entity) { @Schema(description = "수정일시", accessMode = Schema.AccessMode.READ_ONLY)
return UserInfoDto.builder() @JsonProperty(access = JsonProperty.Access.READ_ONLY)
.userId(entity.getUserId()) private LocalDateTime modDt;
.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) { public static UserInfoDto from(TUserEntity entity) {
return UserInfoDto.builder() return UserInfoDto.builder()
.userId(dto.getUserId()) .userId(entity.getUserId())
.userPw(dto.getUserPw()) .userName(entity.getUserNm())
.userName(dto.getUserName()) .userCmpn(entity.getUserCmpn())
.userCmpn(dto.getUserCmpn()) .userTeam(entity.getUserTeam())
.userTeam("S101") .userRole(entity.getUserRole())
.userRole(userRole) .memo(entity.getMemo())
.memo(dto.getMemo()) .regUser(entity.getRegUser())
.regUser(regUser) .regDt(entity.getRegDt())
.regDt(DateTimeUtil.nowKstLocalDateTime()) .modUser(entity.getModUser())
.build(); .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 @Setter
public class ExcelErrorDto { public class ExcelErrorDto {
@ExcelColumn(header = "행 번호", order = 0) @ExcelColumn(header = "행 번호", order = 0)
private int rowNumber; private int rowNumber;
@ExcelColumn(header = "필드명", order = 1) @ExcelColumn(header = "필드명", order = 1)
private String fieldName; private String fieldName;
@ExcelColumn(header = "에러 메시지", order = 2) @ExcelColumn(header = "에러 메시지", order = 2)
private String errorMessage; private String errorMessage;
public static ExcelErrorDto of(int rowNumber, String fieldName, String errorMessage) { public static ExcelErrorDto of(int rowNumber, String fieldName, String errorMessage) {
return ExcelErrorDto.builder() return ExcelErrorDto.builder()
.rowNumber(rowNumber) .rowNumber(rowNumber)
.fieldName(fieldName) .fieldName(fieldName)
.errorMessage(errorMessage) .errorMessage(errorMessage)
.build(); .build();
} }
} }

View File

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

View File

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

View File

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

View File

@@ -1,44 +1,49 @@
package com.kri.contact.server.persistence.entity; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_assign") @Table(name = "t_list_assign")
public class TListAssignEntity { 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") @Id
private Long prjctIdx; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_assign_idx", nullable = false)
private Long listAssignIdx;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "sid", nullable = false) private Long prjctIdx;
private Integer sid;
@NotNull @NotNull
@Column(name = "assign_ty", nullable = false) @Column(name = "sid", nullable = false)
private Short assignTy; private Integer sid;
@Size(max = 32) @NotNull
@Column(name = "user_id", length = 32) @Column(name = "assign_ty", nullable = false)
private String userId; private Short assignTy;
@Size(max = 32) @Size(max = 32)
@Column(name = "reg_user", length = 32) @Column(name = "user_id", length = 32)
private String regUser; private String userId;
@ColumnDefault("CURRENT_TIMESTAMP") @Size(max = 32)
@Column(name = "reg_dt") @Column(name = "reg_user", length = 32)
private LocalDateTime regDt; 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.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list") @Table(name = "t_list")
public class TListEntity { public class TListEntity {
@EmbeddedId
private TListEntityId id;
@NotNull @EmbeddedId
@Column(name = "is_use", nullable = false) private TListEntityId id;
private Short use;
@Size(max = 2048) @NotNull
@Column(name = "memo", length = 2048) @Column(name = "is_use", nullable = false)
private String memo; private Short use;
@Size(max = 32) @Size(max = 2048)
@NotNull @Column(name = "memo", length = 2048)
@Column(name = "reg_user", nullable = false, length = 32, updatable = false) private String memo;
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false, updatable = false) @Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private LocalDateTime regDt; private String regUser;
@Size(max = 32) @NotNull
@Column(name = "mod_user", length = 32, insertable = false) @ColumnDefault("CURRENT_TIMESTAMP")
private String modUser; @Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false) @Size(max = 32)
private LocalDateTime modDt; @Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() { @Column(name = "mod_dt", insertable = false)
return id.getPrjctIdx(); private LocalDateTime modDt;
}
public Integer getSid() { public Long getPrjctIdx() {
return id.getSid(); 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.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter @Getter
@Setter @Setter
@Embeddable @Embeddable
public class TListEntityId implements Serializable { public class TListEntityId implements Serializable {
private static final long serialVersionUID = 7012247084434778447L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull private static final long serialVersionUID = 7012247084434778447L;
@Column(name = "sid", nullable = false) @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Integer sid; private Long prjctIdx;
@Override @NotNull
public boolean equals(Object o) { @Column(name = "sid", nullable = false)
if (this == o) return true; private Integer sid;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListEntityId entity = (TListEntityId) o; @Override
return Objects.equals(this.prjctIdx, entity.prjctIdx) && public boolean equals(Object o) {
Objects.equals(this.sid, entity.sid); if (this == o) {
return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, sid);
} }
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; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_event_hist") @Table(name = "t_list_event_hist")
public class TListEventHistEntity { 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") @Id
private Long prjctIdx; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_event_hist_idx", nullable = false)
private Long listEventHistIdx;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "sid", nullable = false) private Long prjctIdx;
private Integer sid;
@NotNull @NotNull
@Column(name = "result_cd", nullable = false) @Column(name = "sid", nullable = false)
private Integer resultCd; private Integer sid;
@NotNull @NotNull
@Lob @Column(name = "result_cd", nullable = false)
@Column(name = "contact_memo", nullable = false) private Integer resultCd;
private String contactMemo;
@Size(max = 32) @NotNull
@NotNull @Lob
@Column(name = "reg_user", nullable = false, length = 32) @Column(name = "contact_memo", nullable = false)
private String regUser; private String contactMemo;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; 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.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_header") @Table(name = "t_list_header")
public class TListHeaderEntity { public class TListHeaderEntity {
@EmbeddedId
private TListHeaderEntityId id;
@NotNull @EmbeddedId
@Column(name = "list_hder_grad", nullable = false) private TListHeaderEntityId id;
private Short listHderGrad;
@Size(max = 32) @NotNull
@NotNull @Column(name = "list_hder_grad", nullable = false)
@Column(name = "list_hder_nm", nullable = false, length = 32) private Short listHderGrad;
private String listHderNm;
@NotNull @Size(max = 32)
@Column(name = "list_hder_ty", nullable = false) @NotNull
private Short listHderTy; @Column(name = "list_hder_nm", nullable = false, length = 32)
private String listHderNm;
@NotNull @NotNull
@Column(name = "use_filter", nullable = false) @Column(name = "list_hder_ty", nullable = false)
private Boolean useFilter = false; private Short listHderTy;
@NotNull @NotNull
@Column(name = "use_view", nullable = false) @Column(name = "use_filter", nullable = false)
private Boolean useView = false; private Boolean useFilter = false;
@NotNull @NotNull
@Column(name = "use_intrvwer_view", nullable = false) @Column(name = "use_view", nullable = false)
private Boolean useIntrvwerView = false; private Boolean useView = false;
@NotNull @NotNull
@Column(name = "use_intrvwer_edit", nullable = false) @Column(name = "use_intrvwer_view", nullable = false)
private Boolean useIntrvwerEdit = false; private Boolean useIntrvwerView = false;
@Size(max = 32) @NotNull
@NotNull @Column(name = "use_intrvwer_edit", nullable = false)
@Column(name = "reg_user", nullable = false, length = 32, updatable = false) private Boolean useIntrvwerEdit = false;
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false, updatable = false) @Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private LocalDateTime regDt; private String regUser;
@Size(max = 32) @NotNull
@Column(name = "mod_user", length = 32, insertable = false) @ColumnDefault("CURRENT_TIMESTAMP")
private String modUser; @Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false) @Size(max = 32)
private LocalDateTime modDt; @Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() { @Column(name = "mod_dt", insertable = false)
return id.getPrjctIdx(); private LocalDateTime modDt;
}
public Integer getListHderId() { public Long getPrjctIdx() {
return id.getListHderId(); 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.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter @Getter
@Setter @Setter
@Embeddable @Embeddable
public class TListHeaderEntityId implements Serializable { 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 private static final long serialVersionUID = -1296812261527497087L;
@Column(name = "list_hder_id", nullable = false) @Column(name = "prjct_idx", insertable = false, updatable = false, columnDefinition = "int UNSIGNED not null")
private Integer listHderId; private Long prjctIdx;
@Override @NotNull
public boolean equals(Object o) { @Column(name = "list_hder_id", nullable = false)
if (this == o) return true; private Integer listHderId;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListHeaderEntityId entity = (TListHeaderEntityId) o; @Override
return Objects.equals(this.prjctIdx, entity.prjctIdx) && public boolean equals(Object o) {
Objects.equals(this.listHderId, entity.listHderId); if (this == o) {
return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, listHderId);
} }
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; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_item") @Table(name = "t_list_item")
public class TListItemEntity { public class TListItemEntity {
@EmbeddedId
private TListItemEntityId id;
@NotNull @EmbeddedId
@Lob private TListItemEntityId id;
@Column(name = "list_item_val", nullable = false)
private String listItemVal;
@Size(max = 32) @NotNull
@NotNull @Lob
@Column(name = "reg_user", nullable = false, length = 32, updatable = false) @Column(name = "list_item_val", nullable = false)
private String regUser; private String listItemVal;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false, updatable = false) @Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private LocalDateTime regDt; private String regUser;
@Size(max = 32) @NotNull
@Column(name = "mod_user", length = 32, insertable = false) @ColumnDefault("CURRENT_TIMESTAMP")
private String modUser; @Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false) @Size(max = 32)
private LocalDateTime modDt; @Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() { @Column(name = "mod_dt", insertable = false)
return id.getPrjctIdx(); private LocalDateTime modDt;
}
public Integer getSid() { public Long getPrjctIdx() {
return id.getSid(); return id.getPrjctIdx();
} }
public Integer getListHderId() { public Integer getSid() {
return id.getListHderId(); 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.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter @Getter
@Setter @Setter
@Embeddable @Embeddable
public class TListItemEntityId implements Serializable { public class TListItemEntityId implements Serializable {
private static final long serialVersionUID = -3478285652359764540L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull private static final long serialVersionUID = -3478285652359764540L;
@Column(name = "sid", nullable = false) @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Integer sid; private Long prjctIdx;
@NotNull @NotNull
@Column(name = "list_hder_id", nullable = false) @Column(name = "sid", nullable = false)
private Integer listHderId; private Integer sid;
@Override @NotNull
public boolean equals(Object o) { @Column(name = "list_hder_id", nullable = false)
if (this == o) return true; private Integer listHderId;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListItemEntityId entity = (TListItemEntityId) o; @Override
return Objects.equals(this.prjctIdx, entity.prjctIdx) && public boolean equals(Object o) {
Objects.equals(this.listHderId, entity.listHderId) && if (this == o) {
Objects.equals(this.sid, entity.sid); return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, listHderId, sid);
} }
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.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_item_upload") @Table(name = "t_list_item_upload")
public class TListItemUploadEntity { public class TListItemUploadEntity {
@EmbeddedId
private TListItemUploadEntityId id;
@Size(max = 128) @EmbeddedId
@Column(name = "file_nm", length = 128) private TListItemUploadEntityId id;
private String fileNm;
@Column(name = "file_size") @Size(max = 128)
private Integer fileSize; @Column(name = "file_nm", length = 128)
private String fileNm;
@Size(max = 128) @Column(name = "file_size")
@Column(name = "file_path", length = 128) private Integer fileSize;
private String filePath;
@Size(max = 32) @Size(max = 128)
@NotNull @Column(name = "file_path", length = 128)
@Column(name = "reg_user", nullable = false, length = 32, updatable = false) private String filePath;
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false, updatable = false) @Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private LocalDateTime regDt; private String regUser;
@Size(max = 32) @NotNull
@Column(name = "mod_user", length = 32, insertable = false) @ColumnDefault("CURRENT_TIMESTAMP")
private String modUser; @Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false) @Size(max = 32)
private LocalDateTime modDt; @Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
public Long getPrjctIdx() { @Column(name = "mod_dt", insertable = false)
return id.getPrjctIdx(); private LocalDateTime modDt;
}
public Integer getSid() { public Long getPrjctIdx() {
return id.getSid(); return id.getPrjctIdx();
} }
public Integer getListHderId() { public Integer getSid() {
return id.getListHderId(); 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.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter @Getter
@Setter @Setter
@Embeddable @Embeddable
public class TListItemUploadEntityId implements Serializable { public class TListItemUploadEntityId implements Serializable {
private static final long serialVersionUID = -8073832649114843758L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull private static final long serialVersionUID = -8073832649114843758L;
@Column(name = "sid", nullable = false) @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Integer sid; private Long prjctIdx;
@NotNull @NotNull
@Column(name = "list_hder_id", nullable = false) @Column(name = "sid", nullable = false)
private Integer listHderId; private Integer sid;
@Override @NotNull
public boolean equals(Object o) { @Column(name = "list_hder_id", nullable = false)
if (this == o) return true; private Integer listHderId;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TListItemUploadEntityId entity = (TListItemUploadEntityId) o; @Override
return Objects.equals(this.prjctIdx, entity.prjctIdx) && public boolean equals(Object o) {
Objects.equals(this.listHderId, entity.listHderId) && if (this == o) {
Objects.equals(this.sid, entity.sid); return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, listHderId, sid);
} }
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; package com.kri.contact.server.persistence.entity;
import io.hypersistence.utils.hibernate.type.json.JsonType; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import java.time.LocalDateTime;
import java.util.Map;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_reset_log") @Table(name = "t_list_reset_log")
public class TListResetLogEntity { 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") @Id
private Long prjctIdx; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_reset_log_idx", columnDefinition = "int UNSIGNED not null")
private Long listResetLogIdx;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "mode", nullable = false) private Long prjctIdx;
private Short mode;
@NotNull @NotNull
@Column(name = "list_cnt", nullable = false) @Column(name = "mode", nullable = false)
private Integer listCnt; private Short mode;
@NotNull @NotNull
@Type(JsonType.class) @Column(name = "list_cnt", nullable = false)
@Column(name = "sid", nullable = false) private Integer listCnt;
private Map<String, Object> sid;
@Size(max = 128) @NotNull
@NotNull @Type(JsonType.class)
@Column(name = "backup_file_path", nullable = false, length = 128) @Column(name = "sid", nullable = false)
private String backupFilePath; private Map<String, Object> sid;
@Size(max = 128) @Size(max = 128)
@NotNull @NotNull
@Column(name = "backup_file_nm", nullable = false, length = 128) @Column(name = "backup_file_path", nullable = false, length = 128)
private String backupFileNm; private String backupFilePath;
@Size(max = 32) @Size(max = 128)
@NotNull @NotNull
@Column(name = "reg_user", nullable = false, length = 32) @Column(name = "backup_file_nm", nullable = false, length = 128)
private String regUser; private String backupFileNm;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; 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; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_resve") @Table(name = "t_list_resve")
public class TListResveEntity { 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") @Id
private Long prjctIdx; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_resve_idx", columnDefinition = "int UNSIGNED not null")
private Long listResveIdx;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "sid", nullable = false) private Long prjctIdx;
private Integer sid;
@Size(max = 2048) @NotNull
@NotNull @Column(name = "sid", nullable = false)
@Column(name = "memo", nullable = false, length = 2048) private Integer sid;
private String memo;
@NotNull @Size(max = 2048)
@ColumnDefault("0") @NotNull
@Column(name = "is_cnfirm", nullable = false) @Column(name = "memo", nullable = false, length = 2048)
private Boolean cnfirm = false; private String memo;
@NotNull @NotNull
@Column(name = "resve_dt", nullable = false) @ColumnDefault("0")
private LocalDateTime resveDt; @Column(name = "is_cnfirm", nullable = false)
private Boolean cnfirm = false;
@Size(max = 32) @NotNull
@NotNull @Column(name = "resve_dt", nullable = false)
@Column(name = "resve_user", nullable = false, length = 32) private LocalDateTime resveDt;
private String resveUser;
@Size(max = 32) @Size(max = 32)
@NotNull @NotNull
@Column(name = "reg_user", nullable = false, length = 32) @Column(name = "resve_user", nullable = false, length = 32)
private String regUser; private String resveUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; 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; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_update_hist") @Table(name = "t_list_update_hist")
public class TListUpdateHistEntity { 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") @Id
private Long prjctIdx; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_update_hist_idx", nullable = false)
private Long listUpdateHistIdx;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "sid", nullable = false) private Long prjctIdx;
private Integer sid;
@NotNull @NotNull
@Column(name = "list_hder_id", nullable = false) @Column(name = "sid", nullable = false)
private Integer listHderId; private Integer sid;
@NotNull @NotNull
@Lob @Column(name = "list_hder_id", nullable = false)
@Column(name = "before_val", nullable = false) private Integer listHderId;
private String beforeVal;
@NotNull @NotNull
@Lob @Lob
@Column(name = "after_val", nullable = false) @Column(name = "before_val", nullable = false)
private String afterVal; private String beforeVal;
@Size(max = 32) @NotNull
@NotNull @Lob
@Column(name = "reg_user", nullable = false, length = 32) @Column(name = "after_val", nullable = false)
private String regUser; private String afterVal;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; 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; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_list_upload_log") @Table(name = "t_list_upload_log")
public class TListUploadLogEntity { 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") @Id
private Long prjctIdx; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "list_upload_log_idx", nullable = false)
private Long listUploadLogIdx;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "wave", nullable = false) private Long prjctIdx;
private Integer wave;
@Size(max = 128) @NotNull
@NotNull @Column(name = "wave", nullable = false)
@Column(name = "file_nm", nullable = false, length = 128) private Integer wave;
private String fileNm;
@NotNull @Size(max = 128)
@Column(name = "list_cnt", nullable = false) @NotNull
private Integer listCnt; @Column(name = "file_nm", nullable = false, length = 128)
private String fileNm;
@NotNull @NotNull
@Column(name = "mode", nullable = false) @Column(name = "list_cnt", nullable = false)
private Short mode; private Integer listCnt;
@Size(max = 64) @NotNull
@NotNull @Column(name = "mode", nullable = false)
@Column(name = "optn", nullable = false, length = 64) private Short mode;
private String optn;
@NotNull @Size(max = 64)
@Column(name = "is_success", nullable = false) @NotNull
private Boolean success = false; @Column(name = "optn", nullable = false, length = 64)
private String optn;
@Size(max = 32) @NotNull
@NotNull @Column(name = "is_success", nullable = false)
@Column(name = "reg_user", nullable = false, length = 32) private Boolean success = false;
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; 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.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime; 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 @Getter
@Setter @Setter
@@ -19,32 +22,34 @@ import java.time.LocalDateTime;
@AllArgsConstructor @AllArgsConstructor
@Table(name = "t_prjct_assign") @Table(name = "t_prjct_assign")
public class TPrjctAssignEntity { public class TPrjctAssignEntity {
@EmbeddedId
private TPrjctAssignEntityId id;
@Size(max = 32) @EmbeddedId
@NotNull private TPrjctAssignEntityId id;
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; private String regUser;
public static TPrjctAssignEntity create(Long prjctIdx, String userId, String regUser, LocalDateTime regDt) { @NotNull
return TPrjctAssignEntity.builder() @ColumnDefault("CURRENT_TIMESTAMP")
.id(TPrjctAssignEntityId.create(prjctIdx, userId)) @Column(name = "reg_dt", nullable = false)
.regUser(regUser) private LocalDateTime regDt;
.regDt(regDt)
.build();
}
public Long getPrjctIdx() { public static TPrjctAssignEntity create(Long prjctIdx, String userId, String regUser,
return id.getPrjctIdx(); LocalDateTime regDt) {
} return TPrjctAssignEntity.builder()
.id(TPrjctAssignEntityId.create(prjctIdx, userId))
.regUser(regUser)
.regDt(regDt)
.build();
}
public String getUserId() { public Long getPrjctIdx() {
return id.getUserId(); 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.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.Hibernate;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter @Getter
@Setter @Setter
@@ -17,33 +20,38 @@ import java.util.Objects;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TPrjctAssignEntityId implements Serializable { 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) private static final long serialVersionUID = -263674621497298216L;
@NotNull @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Column(name = "user_id", nullable = false, length = 32) private Long prjctIdx;
private String userId;
@Override @Size(max = 32)
public boolean equals(Object o) { @NotNull
if (this == o) return true; @Column(name = "user_id", nullable = false, length = 32)
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; private String userId;
TPrjctAssignEntityId entity = (TPrjctAssignEntityId) o;
return Objects.equals(this.prjctIdx, entity.prjctIdx) && public static TPrjctAssignEntityId create(Long prjctIdx, String userId) {
Objects.equals(this.userId, entity.userId); return TPrjctAssignEntityId.builder()
.prjctIdx(prjctIdx)
.userId(userId)
.build();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, userId);
} }
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) { @Override
return TPrjctAssignEntityId.builder() public int hashCode() {
.prjctIdx(prjctIdx) return Objects.hash(prjctIdx, userId);
.userId(userId) }
.build();
}
} }

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.common.enums.SurveyType;
import com.kri.contact.server.dto.ProjectCreateRequestDto; import com.kri.contact.server.dto.ProjectCreateRequestDto;
import com.kri.contact.server.dto.ProjectInfoDto; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime; 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 @Getter
@Setter @Setter
@@ -21,146 +30,148 @@ import java.time.LocalDateTime;
@AllArgsConstructor @AllArgsConstructor
@Table(name = "t_prjct") @Table(name = "t_prjct")
public class TPrjctEntity { public class TPrjctEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@Size(max = 32) @Id
@NotNull @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "prjct_cd", nullable = false, length = 32) @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private String prjctCd; private Long prjctIdx;
@NotNull @Size(max = 32)
@ColumnDefault("0") @NotNull
@Column(name = "prjct_status", nullable = false) @Column(name = "prjct_cd", nullable = false, length = 32)
private Short prjctStatus; private String prjctCd;
@Size(max = 128) @NotNull
@NotNull @ColumnDefault("0")
@Column(name = "prjct_nm", nullable = false, length = 128) @Column(name = "prjct_status", nullable = false)
private String prjctNm; private Short prjctStatus;
@Size(max = 32) @Size(max = 128)
@NotNull @NotNull
@Column(name = "itrnt_prjct_cd", nullable = false, length = 32) @Column(name = "prjct_nm", nullable = false, length = 128)
private String itrntPrjctCd; private String prjctNm;
@Size(max = 32) @Size(max = 32)
@NotNull @NotNull
@Column(name = "owner_dept", nullable = false, length = 32) @Column(name = "itrnt_prjct_cd", nullable = false, length = 32)
private String ownerDept; private String itrntPrjctCd;
@Size(max = 16) @Size(max = 32)
@NotNull @NotNull
@Column(name = "owner_fw", nullable = false, length = 16) @Column(name = "owner_dept", nullable = false, length = 32)
private String ownerFw; private String ownerDept;
@NotNull @Size(max = 16)
@ColumnDefault("0") @NotNull
@Column(name = "survey_ty", nullable = false) @Column(name = "owner_fw", nullable = false, length = 16)
private Short surveyTy; private String ownerFw;
@Size(max = 32) @NotNull
@Column(name = "survey_prjct_cd", length = 32) @ColumnDefault("0")
private String surveyPrjctCd; @Column(name = "survey_ty", nullable = false)
private Short surveyTy;
@Size(max = 128) @Size(max = 32)
@Column(name = "survey_url", length = 128) @Column(name = "survey_prjct_cd", length = 32)
private String surveyUrl; private String surveyPrjctCd;
@NotNull @Size(max = 128)
@ColumnDefault("0") @Column(name = "survey_url", length = 128)
@Column(name = "is_ff", nullable = false) private String surveyUrl;
private Boolean ff;
@NotNull @NotNull
@ColumnDefault("0") @ColumnDefault("0")
@Column(name = "is_use_contact_senario", nullable = false) @Column(name = "is_ff", nullable = false)
private Boolean useContactSenario; private Boolean ff;
@Lob @NotNull
@Column(name = "contact_senario") @ColumnDefault("0")
private String contactSenario; @Column(name = "is_use_contact_senario", nullable = false)
private Boolean useContactSenario;
@Size(max = 32) @Lob
@NotNull @Column(name = "contact_senario")
@Column(name = "reg_user", nullable = false, length = 32, updatable = false) private String contactSenario;
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false, updatable = false) @Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private LocalDateTime regDt; private String regUser;
@Size(max = 32) @NotNull
@Column(name = "mod_user", length = 32, insertable = false) @ColumnDefault("CURRENT_TIMESTAMP")
private String modUser; @Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false) @Size(max = 32)
private LocalDateTime modDt; @Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@NotNull @Column(name = "mod_dt", insertable = false)
@ColumnDefault("0") private LocalDateTime modDt;
@Column(name = "is_del", nullable = false)
private Boolean del;
@Size(max = 32) @NotNull
@Column(name = "del_user", length = 32) @ColumnDefault("0")
private String delUser; @Column(name = "is_del", nullable = false)
private Boolean del;
@Column(name = "del_dt") @Size(max = 32)
private LocalDateTime delDt; @Column(name = "del_user", length = 32)
private String delUser;
public static TPrjctEntity fromDto(ProjectInfoDto dto) { @Column(name = "del_dt")
return TPrjctEntity.builder() private LocalDateTime delDt;
.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 static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser, LocalDateTime regDt) { public static TPrjctEntity fromDto(ProjectInfoDto dto) {
return TPrjctEntity.builder() return TPrjctEntity.builder()
.prjctCd(prjctCd) .prjctCd(dto.getPrjctCd())
.prjctStatus(ProjectStatus.STANDBY.getCode()) .prjctStatus(dto.getPrjctStatus().getCode())
.prjctNm(req.getPrjctName()) .prjctNm(dto.getPrjctName())
.itrntPrjctCd(req.getItrntPrjctCd()) .itrntPrjctCd(dto.getItrntPrjctCd())
.ownerDept(req.getOwnerDept()) .ownerDept(dto.getOwnerDept())
.ownerFw(req.getOwnerFw()) .ownerFw(dto.getOwnerFw())
.surveyTy(SurveyType.NONE.getCode()) .surveyTy(dto.getSurveyTy().getCode())
.ff(false) .surveyPrjctCd(dto.getSurveyPrjctCd())
.useContactSenario(false) .surveyUrl(dto.getSurveyUrl())
.regUser(regUser) .ff(dto.getFf())
.regDt(regDt) .useContactSenario(dto.getUseContactSenario())
.del(false) .contactSenario(dto.getContactSenario())
.build(); .regUser(dto.getRegUser())
} .regDt(DateTimeUtil.nowKstLocalDateTime())
.build();
}
public void updateFrom(ProjectInfoDto dto, String modUser, LocalDateTime modDt) { public static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser,
this.prjctNm = dto.getPrjctName(); LocalDateTime regDt) {
this.prjctStatus = dto.getPrjctStatus().getCode(); return TPrjctEntity.builder()
this.ownerDept = dto.getOwnerDept(); .prjctCd(prjctCd)
this.ownerFw = dto.getOwnerFw(); .prjctStatus(ProjectStatus.STANDBY.getCode())
this.surveyTy = dto.getSurveyTy().getCode(); .prjctNm(req.getPrjctName())
this.surveyPrjctCd = dto.getSurveyPrjctCd(); .itrntPrjctCd(req.getItrntPrjctCd())
this.surveyUrl = dto.getSurveyUrl(); .ownerDept(req.getOwnerDept())
this.ff = dto.getFf(); .ownerFw(req.getOwnerFw())
this.useContactSenario = dto.getUseContactSenario(); .surveyTy(SurveyType.NONE.getCode())
this.contactSenario = dto.getContactSenario(); .ff(false)
.useContactSenario(false)
.regUser(regUser)
.regDt(regDt)
.del(false)
.build();
}
this.modUser = modUser; public void updateFrom(ProjectInfoDto dto, String modUser, LocalDateTime modDt) {
this.modDt = 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.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime; 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 @Getter
@Setter @Setter
@@ -20,38 +23,40 @@ import java.time.LocalDateTime;
@Entity @Entity
@Table(name = "t_prjct_main_tmplat") @Table(name = "t_prjct_main_tmplat")
public class TPrjctMainTmplatEntity { public class TPrjctMainTmplatEntity {
@EmbeddedId
private TPrjctMainTmplatEntityId id;
@NotNull @EmbeddedId
@Column(name = "tmplat_idx", nullable = false) private TPrjctMainTmplatEntityId id;
private Long tmplatIdx;
@NotNull @NotNull
@Size(max = 32) @Column(name = "tmplat_idx", nullable = false)
@Column(name = "reg_user", nullable = false, length = 32) private Long tmplatIdx;
private String regUser;
@NotNull @NotNull
@ColumnDefault("CURRENT_TIMESTAMP") @Size(max = 32)
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; private String regUser;
// convenience @NotNull
public Long getPrjctIdx() { @ColumnDefault("CURRENT_TIMESTAMP")
return id != null ? id.getPrjctIdx() : null; @Column(name = "reg_dt", nullable = false)
} private LocalDateTime regDt;
public Short getChnnlTy() { public static TPrjctMainTmplatEntity create(ProjectMainTemplateUpdateRequestDto req,
return id != null ? id.getChnnlTy() : null; 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) { // convenience
return TPrjctMainTmplatEntity.builder() public Long getPrjctIdx() {
.id(TPrjctMainTmplatEntityId.create(req.getPrjctIdx(), req.getChnnlTy().getCode())) return id != null ? id.getPrjctIdx() : null;
.tmplatIdx(req.getTmplatIdx()) }
.regUser(regUser)
.regDt(regDt) public Short getChnnlTy() {
.build(); 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.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import lombok.*;
import org.hibernate.Hibernate;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter @Getter
@Setter @Setter
@@ -15,32 +18,37 @@ import java.util.Objects;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TPrjctMainTmplatEntityId implements Serializable { public class TPrjctMainTmplatEntityId implements Serializable {
private static final long serialVersionUID = -263674621497298216L;
@Column(name = "prjct_idx", nullable = false, columnDefinition = "INT UNSIGNED") private static final long serialVersionUID = -263674621497298216L;
private Long prjctIdx;
@Column(name = "chnnl_ty", nullable = false) @Column(name = "prjct_idx", nullable = false, columnDefinition = "INT UNSIGNED")
private Short chnnlTy; private Long prjctIdx;
@Override @Column(name = "chnnl_ty", nullable = false)
public boolean equals(Object o) { private Short chnnlTy;
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; public static TPrjctMainTmplatEntityId create(Long prjctIdx, Short chnnlTy) {
TPrjctMainTmplatEntityId entity = (TPrjctMainTmplatEntityId) o; return TPrjctMainTmplatEntityId.builder()
return Objects.equals(this.prjctIdx, entity.prjctIdx) && .prjctIdx(prjctIdx)
Objects.equals(this.chnnlTy, entity.chnnlTy); .chnnlTy(chnnlTy)
.build();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, chnnlTy);
} }
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) { @Override
return TPrjctMainTmplatEntityId.builder() public int hashCode() {
.prjctIdx(prjctIdx) return Objects.hash(prjctIdx, chnnlTy);
.chnnlTy(chnnlTy) }
.build();
}
} }

View File

@@ -1,6 +1,5 @@
package com.kri.contact.server.persistence.entity; 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.common.enums.ResultCodeType;
import com.kri.contact.server.dto.ResultCodeDto; import com.kri.contact.server.dto.ResultCodeDto;
import jakarta.persistence.Column; import jakarta.persistence.Column;
@@ -9,10 +8,13 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime; 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 @Getter
@Setter @Setter
@@ -22,57 +24,59 @@ import java.time.LocalDateTime;
@AllArgsConstructor @AllArgsConstructor
@Table(name = "t_result_code") @Table(name = "t_result_code")
public class TResultCodeEntity { public class TResultCodeEntity {
@EmbeddedId
private TResultCodeEntityId id;
@Size(max = 32) @EmbeddedId
@NotNull private TResultCodeEntityId id;
@Column(name = "result_cd_lbl", nullable = false, length = 32)
private String resultCdLbl;
@Size(max = 32) @Size(max = 32)
@NotNull @NotNull
@Column(name = "reg_user", nullable = false, length = 32) @Column(name = "result_cd_lbl", nullable = false, length = 32)
private String regUser; private String resultCdLbl;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; private String regUser;
public Long getPrjctIdx() { @NotNull
return id.getPrjctIdx(); @ColumnDefault("CURRENT_TIMESTAMP")
} @Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public ResultCodeType getResultCdTy() { public static TResultCodeEntity copyFromDefault(
return id.getResultCdTy(); 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() { public static TResultCodeEntity fromDto(Long prjctIdx, ResultCodeType resultCdTy,
return id.getResultCd(); 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) { public Long getPrjctIdx() {
return TResultCodeEntity.builder() return id.getPrjctIdx();
.id(TResultCodeEntityId.create(prjctIdx, resultCdTy, req.getResultCd())) }
.resultCdLbl(req.getResultCdLbl())
.regUser(regUser)
.regDt(regDt)
.build();
} 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; 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.enums.ResultCodeType;
import com.kri.contact.server.common.jpa.ResultCodeTypeConverter;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Convert; import jakarta.persistence.Convert;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.hibernate.Hibernate;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
@Getter @Getter
@Setter @Setter
@@ -19,39 +22,45 @@ import java.util.Objects;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TResultCodeEntityId implements Serializable { public class TResultCodeEntityId implements Serializable {
private static final long serialVersionUID = -1984612223940078355L;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
private Long prjctIdx;
@NotNull private static final long serialVersionUID = -1984612223940078355L;
@Column(name = "result_cd_ty", nullable = false) @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED not null")
@Convert(converter = ResultCodeTypeConverter.class) private Long prjctIdx;
private ResultCodeType resultCdTy;
@NotNull @NotNull
@Column(name = "result_cd", nullable = false) @Column(name = "result_cd_ty", nullable = false)
private Short resultCd; @Convert(converter = ResultCodeTypeConverter.class)
private ResultCodeType resultCdTy;
@Override @NotNull
public boolean equals(Object o) { @Column(name = "result_cd", nullable = false)
if (this == o) return true; private Short resultCd;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TResultCodeEntityId entity = (TResultCodeEntityId) o; public static TResultCodeEntityId create(Long prjctIdx, ResultCodeType resultCdTy,
return Objects.equals(this.prjctIdx, entity.prjctIdx) && Short resultCd) {
Objects.equals(this.resultCdTy, entity.resultCdTy) && return TResultCodeEntityId.builder()
Objects.equals(this.resultCd, entity.resultCd); .prjctIdx(prjctIdx)
.resultCdTy(resultCdTy)
.resultCd(resultCd)
.build();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(prjctIdx, resultCdTy, resultCd);
} }
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) { @Override
return TResultCodeEntityId.builder() public int hashCode() {
.prjctIdx(prjctIdx) return Objects.hash(prjctIdx, resultCdTy, resultCd);
.resultCdTy(resultCdTy) }
.resultCd(resultCd)
.build();
}
} }

View File

@@ -1,48 +1,52 @@
package com.kri.contact.server.persistence.entity; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_role") @Table(name = "t_role")
public class TRoleEntity { public class TRoleEntity {
@Id
@Column(name = "role_cd", nullable = false)
private Integer roleCd;
@Size(max = 16) @Id
@NotNull @Column(name = "role_cd", nullable = false)
@Column(name = "role_nm", nullable = false, length = 16) private Integer roleCd;
private String roleNm;
@NotNull @Size(max = 16)
@Lob @NotNull
@Column(name = "memo", nullable = false) @Column(name = "role_nm", nullable = false, length = 16)
private String memo; private String roleNm;
@Size(max = 32) @NotNull
@NotNull @Lob
@Column(name = "reg_user", nullable = false, length = 32, updatable = false) @Column(name = "memo", nullable = false)
private String regUser; private String memo;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false, updatable = false) @Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private LocalDateTime regDt; private String regUser;
@Size(max = 32) @NotNull
@Column(name = "mod_user", length = 32, insertable = false) @ColumnDefault("CURRENT_TIMESTAMP")
private String modUser; @Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Column(name = "mod_dt", insertable = false) @Size(max = 32)
private LocalDateTime modDt; @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.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Table(name = "t_role_func_map") @Table(name = "t_role_func_map")
public class TRoleFuncMapEntity { public class TRoleFuncMapEntity {
@EmbeddedId
private TRoleFuncMapEntityId id;
@Size(max = 32) @EmbeddedId
@NotNull private TRoleFuncMapEntityId id;
@Column(name = "reg_user", nullable = false, length = 32)
private String regUser;
@NotNull @Size(max = 32)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 32)
private LocalDateTime regDt; private String regUser;
public Integer getRoleCd() { @NotNull
return id.getRoleCd(); @ColumnDefault("CURRENT_TIMESTAMP")
} @Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
public Long getFuncCd() { public Integer getRoleCd() {
return id.getFuncCd(); 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.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import java.io.Serializable;
import java.util.Objects;
@Getter @Getter
@Setter @Setter
@Embeddable @Embeddable
public class TRoleFuncMapEntityId implements Serializable { public class TRoleFuncMapEntityId implements Serializable {
private static final long serialVersionUID = 5430666726716009453L;
@NotNull
@Column(name = "role_cd", nullable = false)
private Integer roleCd;
@NotNull private static final long serialVersionUID = 5430666726716009453L;
@Column(name = "func_cd", nullable = false) @NotNull
private Long funcCd; @Column(name = "role_cd", nullable = false)
private Integer roleCd;
@Override @NotNull
public boolean equals(Object o) { @Column(name = "func_cd", nullable = false)
if (this == o) return true; private Long funcCd;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
TRoleFuncMapEntityId entity = (TRoleFuncMapEntityId) o; @Override
return Objects.equals(this.roleCd, entity.roleCd) && public boolean equals(Object o) {
Objects.equals(this.funcCd, entity.funcCd); if (this == o) {
return true;
} }
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
@Override return false;
public int hashCode() {
return Objects.hash(roleCd, funcCd);
} }
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; package com.kri.contact.server.persistence.entity;
import com.kri.common.datetime.DateTimeUtil;
import com.kri.contact.server.common.enums.SystemEventType; import com.kri.contact.server.common.enums.SystemEventType;
import io.hypersistence.utils.hibernate.type.json.JsonType; 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.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Type;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Map; 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 @Getter
@Setter @Setter
@@ -21,60 +28,61 @@ import java.util.Map;
@AllArgsConstructor @AllArgsConstructor
@Table(name = "t_sys_event_log") @Table(name = "t_sys_event_log")
public class TSysEventLogEntity { public class TSysEventLogEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "sys_event_log_idx", nullable = false)
private Long sysEventLogIdx;
@NotNull @Id
@Column(name = "event_ty", nullable = false) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Short eventTy; @Column(name = "sys_event_log_idx", nullable = false)
private Long sysEventLogIdx;
@Size(max = 128) @NotNull
@NotNull @Column(name = "event_ty", nullable = false)
@Column(name = "log_title", nullable = false, length = 128) private Short eventTy;
private String logTitle;
@NotNull @Size(max = 128)
@Type(JsonType.class) @NotNull
@Column(name = "log_content", nullable = false) @Column(name = "log_title", nullable = false, length = 128)
private Map<String, Object> logContent; private String logTitle;
@Column(name = "prjct_idx", columnDefinition = "int UNSIGNED") @NotNull
private Long prjctIdx; @Type(JsonType.class)
@Column(name = "log_content", nullable = false)
private Map<String, Object> logContent;
@Size(max = 16) @Column(name = "prjct_idx", columnDefinition = "int UNSIGNED")
@NotNull private Long prjctIdx;
@Column(name = "ip", nullable = false, length = 16)
private String ip;
@Size(max = 16) @Size(max = 16)
@NotNull @NotNull
@Column(name = "reg_user", nullable = false, length = 16) @Column(name = "ip", nullable = false, length = 16)
private String regUser; private String ip;
@NotNull @Size(max = 16)
@ColumnDefault("CURRENT_TIMESTAMP") @NotNull
@Column(name = "reg_dt", nullable = false) @Column(name = "reg_user", nullable = false, length = 16)
private LocalDateTime regDt; private String regUser;
public static TSysEventLogEntity of( @NotNull
SystemEventType eventTy, @ColumnDefault("CURRENT_TIMESTAMP")
String logTitle, @Column(name = "reg_dt", nullable = false)
Map<String, Object> logContent, private LocalDateTime regDt;
Long prjctIdx,
String ip, public static TSysEventLogEntity of(
String regUser, SystemEventType eventTy,
LocalDateTime regDt String logTitle,
) { Map<String, Object> logContent,
return TSysEventLogEntity.builder() Long prjctIdx,
.eventTy(eventTy.getCode()) String ip,
.logTitle(logTitle) String regUser,
.logContent(logContent) LocalDateTime regDt
.prjctIdx(prjctIdx) ) {
.ip(ip) return TSysEventLogEntity.builder()
.regUser(regUser) .eventTy(eventTy.getCode())
.regDt(regDt) .logTitle(logTitle)
.build(); .logContent(logContent)
} .prjctIdx(prjctIdx)
.ip(ip)
.regUser(regUser)
.regDt(regDt)
.build();
}
} }

View File

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

View File

@@ -1,21 +1,22 @@
package com.kri.contact.server.persistence.query; package com.kri.contact.server.persistence.query;
import org.springframework.data.domain.*; import org.springframework.data.domain.Sort;
public class ProjectSorts { 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; public static Sort toSort(String sortBy, String sortDir) {
return Sort.by(dir, prop); 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 com.kri.contact.server.persistence.entity.TPrjctEntity;
import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import java.util.List;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.List;
public class ProjectSpecs { public class ProjectSpecs {
public static Specification<TPrjctEntity> isDelFalse() { public static Specification<TPrjctEntity> isDelFalse() {
return (root, query, cb) -> cb.equal(root.get("del"), false); return (root, query, cb) -> cb.equal(root.get("del"), false);
} }
public static Specification<TPrjctEntity> keywordLike(String searchText) { public static Specification<TPrjctEntity> keywordLike(String searchText) {
return (root, query, cb) -> { return (root, query, cb) -> {
if (!StringUtils.hasText(searchText)) return cb.conjunction(); if (!StringUtils.hasText(searchText)) {
String like = "%" + searchText.trim() + "%"; return cb.conjunction();
}
String like = "%" + searchText.trim() + "%";
return cb.or( return cb.or(
cb.like(root.get("prjctCd"), like), cb.like(root.get("prjctCd"), like),
cb.like(root.get("prjctNm"), like) // 엔티티 필드명에 맞추기 cb.like(root.get("prjctNm"), like) // 엔티티 필드명에 맞추기
); );
}; };
} }
public static Specification<TPrjctEntity> statusIn(List<Short> list) { public static Specification<TPrjctEntity> statusIn(List<Short> list) {
return (root, query, cb) -> { return (root, query, cb) -> {
if (list == null || list.isEmpty()) return cb.conjunction(); if (list == null || list.isEmpty()) {
return root.get("prjctStatus").in(list); return cb.conjunction();
}; }
} return root.get("prjctStatus").in(list);
};
}
public static Specification<TPrjctEntity> ownerDeptIn(List<String> list) { public static Specification<TPrjctEntity> ownerDeptIn(List<String> list) {
return (root, query, cb) -> { return (root, query, cb) -> {
if (list == null || list.isEmpty()) return cb.conjunction(); if (list == null || list.isEmpty()) {
return root.get("ownerDept").in(list); return cb.conjunction();
}; }
} return root.get("ownerDept").in(list);
};
}
public static Specification<TPrjctEntity> ownerFwIn(List<String> list) { public static Specification<TPrjctEntity> ownerFwIn(List<String> list) {
return (root, query, cb) -> { return (root, query, cb) -> {
if (list == null || list.isEmpty()) return cb.conjunction(); if (list == null || list.isEmpty()) {
return root.get("ownerFw").in(list); return cb.conjunction();
}; }
} return root.get("ownerFw").in(list);
};
}
public static Specification<TPrjctEntity> assignedToUserAndNotExcluded(String userId) { public static Specification<TPrjctEntity> assignedToUserAndNotExcluded(String userId) {
return (root, query, cb) -> { return (root, query, cb) -> {
if (userId == null || userId.isBlank()) { if (userId == null || userId.isBlank()) {
return cb.disjunction(); // 외부유저인데 userId 없으면 아무것도 안 보이게(안전) return cb.disjunction(); // 외부유저인데 userId 없으면 아무것도 안 보이게(안전)
} }
var sub = query.subquery(Integer.class); var sub = query.subquery(Integer.class);
Root<TPrjctAssignEntity> a = sub.from(TPrjctAssignEntity.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) // 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 p1 = cb.equal(a.get("id").get("prjctIdx"), root.get("prjctIdx"));
Predicate p2 = cb.equal(a.get("id").get("userId"), userId); 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.TPrjctAssignEntity;
import com.kri.contact.server.persistence.entity.TPrjctAssignEntityId; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; 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(""" @Modifying(clearAutomatically = true, flushAutomatically = true)
select a.id.userId @Query(value = """
from TPrjctAssignEntity a delete from TPrjctAssignEntity a
join TUserEntity u on u.userId = a.id.userId where a.id.prjctIdx = :prjctIdx
where a.id.prjctIdx = :prjctIdx and a.id.userId in (
and u.del = false select u.userId
and u.userRole >= :startRole from TUserEntity u
and u.userRole < :endRole where 1=1
""") and u.userRole >= :startRole
List<String> findAssignUserIdByPrjctIdxAndRoleRange(Long prjctIdx, int startRole, int endRole); and u.userRole < :endRole
)
@Modifying(clearAutomatically = true, flushAutomatically = true) """)
@Query(value = """ int deleteAssignByPrjctIdxAndRoleRange(Long prjctIdx, int startRole, int endRole);
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.TPrjctMainTmplatEntity;
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntityId; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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; package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TPrjctEntity; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import java.time.LocalDateTime; public interface ProjectRepository extends JpaRepository<TPrjctEntity, Long>,
import java.util.List; 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(""" @Query("""
select distinct p.ownerDept select distinct p.ownerFw
from TPrjctEntity p from TPrjctEntity p
where p.del = false where p.del = false
and (:statusList is null or p.prjctStatus in :statusList) and (:statusList is null or p.prjctStatus in :statusList)
order by p.ownerDept order by p.ownerDept
""") """)
List<String> findDistinctOwnerDept(List<Short> statusList); List<String> findDistinctOwnerFw(List<Short> statusList);
@Query(""" @Modifying(clearAutomatically = true, flushAutomatically = true)
select distinct p.ownerFw @Query("""
from TPrjctEntity p update TPrjctEntity u
where p.del = false set u.del = true,
and (:statusList is null or p.prjctStatus in :statusList) u.delUser = :delUser,
order by p.ownerDept u.delDt = :delDt
""") where u.prjctIdx = :prjctIdx
List<String> findDistinctOwnerFw(List<Short> statusList); and u.del = false
""")
@Modifying(clearAutomatically = true, flushAutomatically = true) int softDeleteByPrjctIdx(Long prjctIdx, String delUser, LocalDateTime delDt);
@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.common.enums.ResultCodeType;
import com.kri.contact.server.persistence.entity.TResultCodeEntity; import com.kri.contact.server.persistence.entity.TResultCodeEntity;
import com.kri.contact.server.persistence.entity.TResultCodeEntityId; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; 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("""
@Query(""" select r
select r from TResultCodeEntity r
from TResultCodeEntity r where r.id.prjctIdx = 0
where r.id.prjctIdx = 0 """)
""") List<TResultCodeEntity> findDefault();
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; package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TRoleEntity; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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; package com.kri.contact.server.persistence.repository;
import com.kri.contact.server.persistence.entity.TUserEntity; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import java.time.LocalDateTime; public interface UserRepository extends JpaRepository<TUserEntity, Long>,
import java.util.List; JpaSpecificationExecutor<TUserEntity> {
import java.util.Optional;
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(""" @Query("""
select u select u
from TUserEntity u from TUserEntity u
where u.del = false where u.del = false
and u.userRole >= :startRole and u.userRole >= :startRole
and u.userRole < :endRole and u.userRole < :endRole
""") """)
List<TUserEntity> findByRoleRangeAndDelFalse(int startRole, int endRole); List<TUserEntity> findByRoleRangeAndDelFalse(int startRole, int endRole);
@Query(""" @Query("""
select u.userId select u.userId
from TUserEntity u from TUserEntity u
where u.del = false where u.del = false
and u.userRole >= :startRole and u.userRole >= :startRole
and u.userRole < :endRole and u.userRole < :endRole
""") """)
List<TUserEntity> findUserIdByRoleRangeAndDelFalse(int startRole, int endRole); List<TUserEntity> findUserIdByRoleRangeAndDelFalse(int startRole, int endRole);
@Query(""" @Query("""
select distinct u.userCmpn select distinct u.userCmpn
from TUserEntity u from TUserEntity u
where u.userCmpn is not null and u.userCmpn <> '' 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 and u.del = false
order by u.userCmpn """)
""") int softDeleteByUserId(String userId, String delUser, LocalDateTime delDt);
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);
} }

View File

@@ -1,91 +1,92 @@
package com.kri.contact.server.scheduler; 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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; 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 @Slf4j
@Component @Component
public class TempFileCleanupScheduler { public class TempFileCleanupScheduler {
private final Path uploadBaseDir; private final Path uploadBaseDir;
private final Duration expireDuration; private final Duration expireDuration;
public TempFileCleanupScheduler( public TempFileCleanupScheduler(
@Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDirStr, @Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDirStr,
@Value("${kri.contact-senario.temp-expire-hours:24}") long expireHours @Value("${kri.contact-senario.temp-expire-hours:24}") long expireHours
) { ) {
this.uploadBaseDir = Paths.get(uploadBaseDirStr); this.uploadBaseDir = Paths.get(uploadBaseDirStr);
this.expireDuration = Duration.ofHours(expireHours); 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;
} }
/** Instant now = Instant.now();
* 매일 자정(00:00)에 실행. Instant threshold = now.minus(expireDuration);
* 필요하면 application.yml 에서 kri.contact-senario.temp-cleanup-cron 으로 변경 가능.
*/ log.info("[TempCleanup] 시작 - baseDir={}, threshold={}", uploadBaseDir, threshold);
@Scheduled(cron = "${kri.contact-senario.temp-cleanup-cron:0 0 0 * * *}")
public void cleanupOldTempFiles() { try (DirectoryStream<Path> projectDirs = Files.newDirectoryStream(uploadBaseDir)) {
if (!Files.isDirectory(uploadBaseDir)) { for (Path projectDir : projectDirs) {
log.warn("[TempCleanup] uploadBaseDir({}) 가 디렉토리가 아닙니다.", uploadBaseDir); if (!Files.isDirectory(projectDir)) {
return; continue;
} }
Path tempDir = projectDir.resolve("Temp"); // {prjctCd}/Temp
Instant now = Instant.now(); if (!Files.isDirectory(tempDir)) {
Instant threshold = now.minus(expireDuration); continue;
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);
} }
cleanupTempDir(tempDir, threshold);
log.info("[TempCleanup] 종료"); }
} catch (IOException e) {
log.error("[TempCleanup] baseDir 스캔 중 오류 - baseDir={}", uploadBaseDir, e);
} }
private void cleanupTempDir(Path tempDir, Instant threshold) { log.info("[TempCleanup] 종료");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(tempDir)) { }
for (Path file : stream) {
if (!Files.isRegularFile(file)) {
continue;
}
try { private void cleanupTempDir(Path tempDir, Instant threshold) {
BasicFileAttributes attrs = try (DirectoryStream<Path> stream = Files.newDirectoryStream(tempDir)) {
Files.readAttributes(file, BasicFileAttributes.class); for (Path file : stream) {
if (!Files.isRegularFile(file)) {
// 생성 시간(지원 안 하면 마지막 수정 시간)을 기준으로 비교 continue;
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);
} }
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; 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.common.consts.ContactConstant;
import com.kri.contact.server.persistence.entity.TPrjctAssignEntity; import com.kri.contact.server.persistence.entity.TPrjctAssignEntity;
import com.kri.contact.server.persistence.repository.ProjectAssignRepository; import com.kri.contact.server.persistence.repository.ProjectAssignRepository;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AssignService { public class AssignService {
private final ProjectAssignRepository projectAssignRepository; private final ProjectAssignRepository projectAssignRepository;
public List<String> getPrjctOutsourceAssign(Long prjctIdx) { public List<String> getPrjctOutsourceAssign(Long prjctIdx) {
return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange( return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange(
prjctIdx, prjctIdx,
ContactConstant.OUTSOURCE_USER_ROLE, ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000 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) { List<String> normalized = assignUserIdList.stream()
return projectAssignRepository.findAssignUserIdByPrjctIdxAndRoleRange( .filter(s -> s != null && !s.isBlank())
prjctIdx, .map(String::trim)
ContactConstant.FIELDWORK_USER_ROLE, .distinct()
ContactConstant.FIELDWORK_USER_ROLE + 1000 .toList();
);
if (normalized.isEmpty()) {
return;
} }
@Transactional List<TPrjctAssignEntity> entities = normalized.stream()
public void upsertPrjctOutsourceAssign(Long prjctIdx, List<String> assignUserIdList, String regUser, LocalDateTime regDt) { .map(uid -> TPrjctAssignEntity.create(prjctIdx, uid, regUser, regDt))
projectAssignRepository.deleteAssignByPrjctIdxAndRoleRange( .toList();
prjctIdx,
ContactConstant.OUTSOURCE_USER_ROLE,
ContactConstant.OUTSOURCE_USER_ROLE + 1000
);
insertPrjctAssign(prjctIdx, assignUserIdList, regUser, regDt); projectAssignRepository.saveAll(entities);
} }
@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);
}
} }

View File

@@ -1,11 +1,11 @@
package com.kri.contact.server.service; package com.kri.contact.server.service;
import com.kri.common.auth.jwt.JwtService;
import com.kri.common.auth.dto.JwtUserClaimsDto; import com.kri.common.auth.dto.JwtUserClaimsDto;
import com.kri.contact.server.dto.LoginRequestDto; import com.kri.common.auth.jwt.JwtService;
import com.kri.contact.server.dto.LoginResponseDto;
import com.kri.contact.server.common.external.intranet.IntranetExtensionApiClient; import com.kri.contact.server.common.external.intranet.IntranetExtensionApiClient;
import com.kri.contact.server.common.external.intranet.SearchLoginInfoResponseDto; 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 com.kri.contact.server.persistence.entity.TUserEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -13,36 +13,37 @@ import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AuthService { public class AuthService {
private final JwtService jwtService;
private final UserService userService; private final JwtService jwtService;
private final IntranetExtensionApiClient intranetExtensionApiClient; private final UserService userService;
private final IntranetExtensionApiClient intranetExtensionApiClient;
public LoginResponseDto tryLogin(LoginRequestDto request) { public LoginResponseDto tryLogin(LoginRequestDto request) {
SearchLoginInfoResponseDto loginInfoResponse = intranetExtensionApiClient.searchLoginInfo(request); SearchLoginInfoResponseDto loginInfoResponse = intranetExtensionApiClient.searchLoginInfo(
request);
JwtUserClaimsDto claims; JwtUserClaimsDto claims;
if(loginInfoResponse != null) { if (loginInfoResponse != null) {
claims = JwtUserClaimsDto.builder() claims = JwtUserClaimsDto.builder()
.userId(loginInfoResponse.getUserId()) .userId(loginInfoResponse.getUserId())
.userCmpn(loginInfoResponse.getUserCmpn()) .userCmpn(loginInfoResponse.getUserCmpn())
.userName(loginInfoResponse.getUserNm()) .userName(loginInfoResponse.getUserNm())
.userTeam(loginInfoResponse.getUserTeam()) .userTeam(loginInfoResponse.getUserTeam())
.userRole(loginInfoResponse.getUserRole()) .userRole(loginInfoResponse.getUserRole())
.build(); .build();
} } else {
else{ TUserEntity user = userService.getUser(request.getUserId(), request.getUserPw());
TUserEntity user = userService.getUser(request.getUserId(), request.getUserPw()); claims = JwtUserClaimsDto.builder()
claims = JwtUserClaimsDto.builder() .userId(user.getUserId())
.userId(user.getUserId()) .userCmpn(user.getUserCmpn())
.userCmpn(user.getUserCmpn()) .userName(user.getUserNm())
.userName(user.getUserNm()) .userTeam(user.getUserTeam())
.userTeam(user.getUserTeam()) .userRole(user.getUserRole())
.userRole(user.getUserRole()) .build();
.build();
}
String accessToken = jwtService.generateAccessToken(claims);
return LoginResponseDto.from(accessToken, claims);
} }
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.file.FileUtil;
import com.kri.common.util.CommonUtil; 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.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
@@ -12,155 +21,160 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.file.*;
import java.util.*;
@Service @Service
public class FileService { 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( private static final Logger log = LoggerFactory.getLogger(FileService.class);
@Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDir, private final Path uploadBaseDir; // ex) /data/upload-file/contact-senario
@Value("${kri.contact-senario.public-base-url}") String publicBaseUrlPrefix private final String publicBaseUrlPrefix; // ex) /upload-file/contact-senario
) {
this.uploadBaseDir = Paths.get(uploadBaseDir).toAbsolutePath().normalize(); public FileService(
this.publicBaseUrlPrefix = publicBaseUrlPrefix.endsWith("/") @Value("${kri.contact-senario.upload-base-dir}") String uploadBaseDir,
? publicBaseUrlPrefix.substring(0, publicBaseUrlPrefix.length() - 1) @Value("${kri.contact-senario.public-base-url}") String publicBaseUrlPrefix
: 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 = "";
} }
/** String returnHtml = rawHtml;
* Temp에 파일 저장 후, public URL 반환 try {
*/
public String storeTempFile(String prjctCd, MultipartFile file) {
try {
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
String ext = "";
int dot = original.lastIndexOf('.'); // body fragment로 파싱 (KriEditor가 body 없이 <p>...</p> 형태 저장하므로)
if (dot > 0 && dot < original.length() - 1) { Document doc = Jsoup.parseBodyFragment(rawHtml);
ext = original.substring(dot); Elements imgs = doc.select("img[src]");
}
String newName = CommonUtil.uuid32() + ext; Set<String> assetFileNamesToKeep = new HashSet<>();
Path tempDir = getTempDir(prjctCd); for (Element img : imgs) {
Files.createDirectories(tempDir); String src = img.attr("src");
if (src == null || src.isBlank()) {
Path target = tempDir.resolve(newName); continue;
file.transferTo(target.toFile());
// 브라우저에서 사용할 URL
return publicBaseUrlPrefix + "/" + prjctCd + "/Temp/" + newName;
} catch (IOException e) {
throw new RuntimeException("파일 저장 실패", e);
} }
} if (!src.contains("/" + prjctCd + "/")) {
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);
} }
return returnHtml; if (src.contains("/" + prjctCd + "/Temp/")) {
} // Temp → Asset 이동
String fileName = FileUtil.extractFileNameFromPath(src);
moveTempToAsset(prjctCd, fileName);
/***************************private************************************/ String assetSrc = src.replace("/Temp/", "/Asset/");
private String normalizeBaseUrl(String url) { img.attr("src", assetSrc);
if (url.endsWith("/")) {
return url.substring(0, url.length() - 1); 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 returnHtml;
return uploadBaseDir.resolve(prjctCd).resolve("Temp"); }
/***************************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) { Path tempDir = getTempDir(prjctCd);
return uploadBaseDir.resolve(prjctCd).resolve("Asset"); 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 { Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
if (fileName == null || fileName.isBlank()) return; }
Path tempDir = getTempDir(prjctCd); private void cleanupAssetDir(String prjctCd, Set<String> keepFileNames) throws IOException {
Path assetDir = getAssetDir(prjctCd); Path assetDir = getAssetDir(prjctCd);
Files.createDirectories(assetDir); if (!Files.exists(assetDir)) {
return;
}
Path source = tempDir.resolve(fileName).normalize(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(assetDir)) {
Path target = assetDir.resolve(fileName).normalize(); for (Path path : stream) {
if (!Files.isRegularFile(path)) {
if (!source.startsWith(tempDir) || !target.startsWith(assetDir)) { continue;
// 안전 체크
return;
} }
if (!Files.exists(source)) { String fileName = path.getFileName().toString();
return; if (!keepFileNames.contains(fileName)) {
} Files.deleteIfExists(path);
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);
}
}
} }
}
} }
}
} }

View File

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

View File

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

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

View File

@@ -1,162 +1,180 @@
package com.kri.contact.server.service; package com.kri.contact.server.service;
import static com.kri.common.json.JsonUtil.toMap;
import com.fasterxml.jackson.databind.ObjectMapper; 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.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.entity.TSysEventLogEntity;
import com.kri.contact.server.persistence.repository.SystemEventLogRepository; import com.kri.contact.server.persistence.repository.SystemEventLogRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.RequiredArgsConstructor;
import static com.kri.common.json.JsonUtil.toMap; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class SystemEventLogService { public class SystemEventLogService {
private final ObjectMapper objectMapper;
private final SystemEventLogRepository systemEventLogRepository;
public void writeLoginLog(String userId, LocalDateTime regDt, String clientIp) { private final ObjectMapper objectMapper;
writeSystemLog( private final SystemEventLogRepository systemEventLogRepository;
SystemEventType.LOGIN,
"Login",
null,
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeLogoutLog(String userId, LocalDateTime regDt, String clientIp) { public void writeLoginLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog( writeSystemLog(
SystemEventType.LOGOUT, SystemEventType.LOGIN,
"Logout", "Login",
null, null,
userId, userId,
regDt, regDt,
clientIp, clientIp,
"userId", "userId",
userId userId
); );
} }
public void writeCreateUserLog(String regId, LocalDateTime regDt, String clientIp, UserInfoDto userInfo) { public void writeLogoutLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, regDt, clientIp, userInfo); writeSystemLog(
} SystemEventType.LOGOUT,
"Logout",
null,
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeUploadUserLog(String regId, LocalDateTime regDt, String clientIp, UploadUserContentDto content) { public void writeCreateUserLog(String regId, LocalDateTime regDt, String clientIp,
writeSystemLog(SystemEventType.UPLOAD_USER, "Upload User", null, regId, regDt, clientIp, content); UserInfoDto userInfo) {
} writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, regDt, clientIp,
userInfo);
}
public void writeUpdateUserLog(String regId, LocalDateTime regDt, String clientIp, UserInfoDto userInfo) { public void writeUploadUserLog(String regId, LocalDateTime regDt, String clientIp,
writeSystemLog(SystemEventType.UPDATE_USER, "Update User", null, regId, regDt, clientIp, userInfo); UploadUserContentDto content) {
} writeSystemLog(SystemEventType.UPLOAD_USER, "Upload User", null, regId, regDt, clientIp,
content);
}
public void writeDeleteUserLog(String regId, LocalDateTime regDt, String clientIp, String userId) { public void writeUpdateUserLog(String regId, LocalDateTime regDt, String clientIp,
writeSystemLog( UserInfoDto userInfo) {
SystemEventType.DELETE_USER, writeSystemLog(SystemEventType.UPDATE_USER, "Update User", null, regId, regDt, clientIp,
"Delete User", userInfo);
null, }
regId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeCreateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, ProjectCreateRequestDto req) { public void writeDeleteUserLog(String regId, LocalDateTime regDt, String clientIp,
writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, regDt, clientIp, req); 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) { public void writeCreateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx,
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt, clientIp, req); ProjectCreateRequestDto req) {
} writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, regDt,
clientIp, req);
}
public void writeUpdateDefaultMessageTemplate(String regId, LocalDateTime regDt, String clientIp, ProjectMainTemplateUpdateRequestDto req) { public void writeUpdateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx,
writeSystemLog(SystemEventType.UPDATE_PROJECT_DEFAULT_TEMPLATE, "Update Project Default Message Template", req.getPrjctIdx(), regId, regDt, clientIp, req); ProjectUpdateRequestDto req) {
} writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt,
clientIp, req);
}
public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx) { public void writeUpdateDefaultMessageTemplate(String regId, LocalDateTime regDt, String clientIp,
writeSystemLog( ProjectMainTemplateUpdateRequestDto req) {
SystemEventType.DELETE_PROJECT, writeSystemLog(SystemEventType.UPDATE_PROJECT_DEFAULT_TEMPLATE,
"Delete Project", "Update Project Default Message Template", req.getPrjctIdx(), regId, regDt, clientIp, req);
prjctIdx, }
regId,
regDt,
clientIp,
"prjctIdx",
prjctIdx
);
}
public void writeAssignUserProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx, List<String> assignUserIdList) { public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp,
writeSystemLog( Long prjctIdx) {
SystemEventType.ASSIGN_PROJECT_USER, writeSystemLog(
"Assign Project FW User", SystemEventType.DELETE_PROJECT,
prjctIdx, "Delete Project",
regId, prjctIdx,
regDt, regId,
clientIp, regDt,
"assignUserIdList", clientIp,
assignUserIdList "prjctIdx",
); prjctIdx
} );
}
protected <T> void writeSystemLog( public void writeAssignUserProject(String regId, LocalDateTime regDt, String clientIp,
SystemEventType eventType, Long prjctIdx, List<String> assignUserIdList) {
String title, writeSystemLog(
Long prjctIdx, SystemEventType.ASSIGN_PROJECT_USER,
String regId, "Assign Project FW User",
LocalDateTime regDt, prjctIdx,
String clientIp, regId,
T content regDt,
) { clientIp,
Map<String, Object> contentMap = toMap(objectMapper, content); "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( saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
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);
}
private void saveLog( protected <T> void writeSystemLog(
SystemEventType eventType, SystemEventType eventType,
String title, String title,
Long prjctIdx, Long prjctIdx,
String regId, String regId,
LocalDateTime regDt, LocalDateTime regDt,
String clientIp, String clientIp,
Map<String, Object> contentMap String contentKey,
) { T content
TSysEventLogEntity log = TSysEventLogEntity.of( ) {
eventType, Map<String, Object> contentMap = Map.of(contentKey, content);
title, saveLog(eventType, title, prjctIdx, regId, regDt, clientIp, contentMap);
contentMap, }
prjctIdx,
clientIp,
regId,
regDt
);
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.dto.excel.UserUploadErrorDto;
import com.kri.contact.server.persistence.entity.TUserEntity; import com.kri.contact.server.persistence.entity.TUserEntity;
import com.kri.contact.server.persistence.repository.UserRepository; 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.io.ByteArrayOutputStream;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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 @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class UserService { public class UserService {
private final IntranetExtensionApiClient intranetExtensionApiClient;
private final RoleService roleService;
private final UserRepository userRepository;
@Transactional private final IntranetExtensionApiClient intranetExtensionApiClient;
public void createUser(UserInfoDto userInfo, String regUser, LocalDateTime regDt) { private final RoleService roleService;
List<RoleInfoDto> roleList = roleService.getRoleList(); private final UserRepository userRepository;
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
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(); userInfo.setUserId(userInfo.getUserId().toLowerCase());
if(!failList.isEmpty()) {
DataVerificationDto firstFail = failList.get(0);
throw BusinessException.badRequest("WRONG_USER_DATA", firstFail.getErrMessage());
}
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt); List<DataVerificationDto> failList = validateUserDto(userInfo, roleList,
intranetUserList).stream().filter(dto -> !dto.isSuccess()).toList();
userRepository.save(entity); if (!failList.isEmpty()) {
DataVerificationDto firstFail = failList.get(0);
throw BusinessException.badRequest("WRONG_USER_DATA", firstFail.getErrMessage());
} }
@Transactional TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt);
public ExcelUploadResponseDto createUsersFromExcel(MultipartFile file, String regUser, LocalDateTime regDt, String forceCmpn) {
if (file == null || file.isEmpty()) {
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
}
List<UserUploadDto> rows; userRepository.save(entity);
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());
}
int totalCount = rows.size(); @Transactional
int successCount = 0; public ExcelUploadResponseDto createUsersFromExcel(MultipartFile file, String regUser,
List<RoleInfoDto> roleList = roleService.getRoleList(); LocalDateTime regDt, String forceCmpn) {
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray(); if (file == null || file.isEmpty()) {
List<UserUploadErrorDto> errorList = new ArrayList<>(); throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
}
// 엑셀 1행 = 헤더, DTO 리스트는 2행부터라고 가정 List<UserUploadDto> rows;
for (int i = 0; i < rows.size(); i++) { try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
UserUploadDto uploadDto = rows.get(i); // DTO 매핑 (스트리밍 X, 일반 방식)
Integer roleCd = roleList.stream() rows = ExcelMapper.readFromWorkbook(workbook, UserUploadDto.class);
.filter(r -> java.util.Objects.equals(uploadDto.getUserRoleStr(), r.getRoleNm())) } catch (Exception e) {
.map(RoleInfoDto::getRoleCd) throw BusinessException.badRequest("INVALID_EXCEL", "엑셀 파일을 읽는 중 오류가 발생했습니다.")
.findFirst() .with("fileName", file.getOriginalFilename());
.orElse(null); }
UserInfoDto dto = UserInfoDto.from(uploadDto, roleCd, regUser); int totalCount = rows.size();
if(!forceCmpn.isBlank()) { int successCount = 0;
dto.setUserCmpn(forceCmpn); List<RoleInfoDto> roleList = roleService.getRoleList();
} List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
List<UserUploadErrorDto> errorList = new ArrayList<>();
int rowNumber = i + 2; // 엑셀 실제 행 번호 (헤더가 1행일 때) // 엑셀 1행 = 헤더, DTO 리스트는 2행부터라고 가정
// 1) 값 검증 for (int i = 0; i < rows.size(); i++) {
List<UserUploadErrorDto> rowErrors = validateUserDtoForExcel(dto, rowNumber, roleList, intranetUserList); UserUploadDto uploadDto = rows.get(i);
if (!rowErrors.isEmpty()) { Integer roleCd = roleList.stream()
errorList.addAll(rowErrors); .filter(r -> java.util.Objects.equals(uploadDto.getUserRoleStr(), r.getRoleNm()))
continue; // 이 행은 DB 저장 스킵 .map(RoleInfoDto::getRoleCd)
} .findFirst()
.orElse(null);
// 2) 실제 DB 저장 UserInfoDto dto = UserInfoDto.from(uploadDto, roleCd, regUser);
try { if (!forceCmpn.isBlank()) {
this.createUserInternal(dto, regUser, regDt); dto.setUserCmpn(forceCmpn);
successCount++; }
} catch (BusinessException ex) {
// 시스템/비즈니스 예외도 에러 목록에 추가
errorList.add(
UserUploadErrorDto.of(
rowNumber,
"SYSTEM",
ex.getMessage()
)
);
}
}
return ExcelUploadResultUtil.buildUploadResult( int rowNumber = i + 2; // 엑셀 실제 행 번호 (헤더가 1행일 때)
totalCount, // 1) 값 검증
successCount, List<UserUploadErrorDto> rowErrors = validateUserDtoForExcel(dto, rowNumber, roleList,
errorList, intranetUserList);
UserUploadErrorDto.class, if (!rowErrors.isEmpty()) {
"user_upload_errors.xlsx" 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() { return ExcelUploadResultUtil.buildUploadResult(
try (Workbook workbook = totalCount,
ExcelMapper.writeToWorkbook(Collections.emptyList(), UserUploadDto.class); successCount,
ByteArrayOutputStream out = new ByteArrayOutputStream()) { errorList,
UserUploadErrorDto.class,
"user_upload_errors.xlsx"
);
}
workbook.write(out); public byte[] exportUserTemplate() {
return out.toByteArray(); try (Workbook workbook =
} catch (Exception e) { ExcelMapper.writeToWorkbook(Collections.emptyList(), UserUploadDto.class);
throw BusinessException.internalError("사용자 업로드 템플릿 엑셀 생성 중 오류"); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
}
workbook.write(out);
return out.toByteArray();
} catch (Exception e) {
throw BusinessException.internalError("사용자 업로드 템플릿 엑셀 생성 중 오류");
} }
}
public DataVerificationDto checkUserId(String userId) { public DataVerificationDto checkUserId(String userId) {
List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray(); List<String> intranetUserList = intranetExtensionApiClient.getUserIdArray();
return this.verifyUserId(userId, intranetUserList); return this.verifyUserId(userId, intranetUserList);
} }
public UserInfoDto getUser(String userId) { public UserInfoDto getUser(String userId) {
TUserEntity user = userRepository.findByUserIdAndDelFalse(userId) TUserEntity user = userRepository.findByUserIdAndDelFalse(userId)
.orElseThrow(() -> .orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.") BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", userId) .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
); );
return userList.stream() UserInfoDto userInfoDto = UserInfoDto.from(user);
.map(UserInfoDto::from) userInfoDto.setUserPw(user.getUserPw());
.toList(); 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 userList.stream()
return userRepository.findDistinctUserCmpnAndDelFalse(); .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 return new DataVerificationDto();
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);// 기존 엔티티에 적용 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 // 2. userName 비어있는지 / 한글·영문 대소문자만 허용
public void deleteUser(String userId, String delUser) { String userName = dto.getUserName();
int deleteCount = userRepository.softDeleteByUserId(userId, delUser, DateTimeUtil.nowKstLocalDateTime()); if (userName == null || userName.isBlank()) {
result.add(new DataVerificationDto(
if(deleteCount == 0) { false,
throw BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.") "사용자 이름",
.with("userId", userId); "사용자 이름이 비어 있습니다."
} ));
} else if (!userName.matches("^[가-힣A-Za-z][가-힣A-Za-z0-9_ ()]*$")) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름은 한글/영문으로 시작해야 하며, 한글/영문/숫자와 공백, '(', ')', '_'만 입력 가능합니다."
));
} }
/*******************************private*******************************/ // 3. userCmpn 비어있는지 / 한글, 영문, 숫자, 공백, (, ) 만 허용
private DataVerificationDto verifyUserId(String userId, List<String> intranetUserList) { String userCmpn = dto.getUserCmpn();
if(userId == null || userId.isBlank()) { if (userCmpn == null || userCmpn.isBlank()) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID가 비었습니다."); result.add(new DataVerificationDto(
} false,
if (userId.length() < 3 || userId.length() > 16 ) { "사용자 소속 회사",
return new DataVerificationDto(false,"사용자 ID", "사용자 ID는 3~15 자리여야 합니다."); "사용자 소속 회사가 비어 있습니다."
} ));
if (!userId.matches("^[a-z가-힣][a-z0-9가-힣]+$")) { } else if (!userCmpn.matches("^[가-힣A-Za-z0-9() ]+$")) {
return new DataVerificationDto(false,"사용자 ID", "사용자 ID는 한글, 영소문자, 숫자만 허용합니다."); result.add(new DataVerificationDto(
} false,
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();
} }
private List<DataVerificationDto> validateUserDto( // 4. userRole 이 roleList의 roleNm에 존재하는지 체크
UserInfoDto dto, Integer userRole = dto.getUserRole();
List<RoleInfoDto> roleList, if (roleList != null && !roleList.isEmpty()) {
List<String> intranetUserList boolean exists = roleList.stream()
) { .anyMatch(r -> userRole.equals(r.getRoleCd()));
List<DataVerificationDto> result = new ArrayList<>();
// 0. userId 기본 검증 (기존 로직) if (!exists) {
result.add(this.verifyUserId(dto.getUserId(), intranetUserList)); result.add(new DataVerificationDto(
false,
// 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;
} }
private List<UserUploadErrorDto> validateUserDtoForExcel( return result;
UserInfoDto dto, }
int rowNumber,
List<RoleInfoDto> roleList,
List<String> intranetUserList
) {
List<UserUploadErrorDto> errors = new ArrayList<>();
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 -> { List<DataVerificationDto> validateUserList = this.validateUserDto(dto, roleList,
if(!validateResult.isSuccess()) { intranetUserList);
errors.add(UserUploadErrorDto.of(
rowNumber,
validateResult.getFieldName(),
validateResult.getErrMessage()
));
}
});
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) { return errors;
userInfo.setUserId(userInfo.getUserId().toLowerCase()); }
userInfo.setUserTeam("S101");
TUserEntity entity = TUserEntity.fromDto(userInfo, regUser, regDt); private void createUserInternal(UserInfoDto userInfo, String regUser, LocalDateTime regDt) {
userRepository.save(entity); 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: security:
enabled: true enabled: true
public-paths: # 인증 없이 열어둘 URL public-paths: # 인증 없이 열어둘 URL
- /v3/api-docs/** - /v3/api-docs/**
- /swagger-ui.html - /swagger-ui.html
- /swagger-ui/** - /swagger-ui/**

View File

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