260615_01_FST: First Commit

This commit is contained in:
2026-06-15 09:31:38 +09:00
commit 43743a4f08
87 changed files with 5500 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,11 @@
package com.kri.gwcf.review.back.common.consts;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public final class GwcfConstant {
public static final String SYSTEM_USER_NAME = "SYSTEM";
public static final Integer WRITTEN_USER_ROLE = 2021;
public static final Integer MONITORING_USER_ROLE = 9003;
}

View File

@@ -0,0 +1,41 @@
package com.kri.gwcf.review.back.common.enums;
import com.kri.common.feature.enums.CodeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
@Schema(description = "시스템 이벤트 타입")
public enum SystemEventType implements CodeEnum<Short> {
//1의 자리 1 insert, 2 update, 3 delete, 4 upload
//100의 자리 대분류, 10의 자리 소분류
LOGIN((short) 111), // 로그인
LOGOUT((short) 121), // 로그 아웃
UPDATE_USER((short) 312), // 사용자 수정
DELETE_USER((short) 313), // 사용자 삭제
UPLOAD_USER((short) 314), // 사용자 업로드
UPDATE_PERFORMANCE((short) 1022), //공연 수정
DELETE_PERFORMANCE((short) 1023), //공연 삭제
UPLOAD_PERFORMANCE((short) 1024), //공연 업로드
ASSIGN_PERFORMANCE_REQUEST((short) 1031), //공연 배정 요청
ASSIGN_PERFORMANCE_CONFIRM((short) 1032), //공연 배정 승인
ASSIGN_PERFORMANCE_REJECT((short) 1033), //공연 배정 거절
ASSIGN_PERFORMANCE_FORCE((short) 1034), //강제 공연 배정
VISIT_START((short) 2011), //모니터링 출발
VISIT_END((short) 2012), //모니터링 도착
UPLOAD_MONITORING_REVIEW((short) 2041), //모니터링 결과보고서 업로드
UPLOAD_LOCAL_GOV_REVIEW((short) 2042), //지자체 결과보고서 업로드
UPDATE_WRITTEN_REVIEW((short) 2043), //지자체 결과보고서 업로드
DUMMY((short) 9999);
private final Short code;
}

View File

@@ -0,0 +1,19 @@
package com.kri.gwcf.review.back.common.util;
import com.kri.common.feature.excel.ExcelMapper;
import com.kri.gwcf.review.back.dto.common.CodeDto;
import com.kri.gwcf.review.back.dto.excel.CodeSheetDto;
import java.util.List;
import lombok.NoArgsConstructor;
import org.apache.poi.ss.usermodel.Workbook;
@NoArgsConstructor
public final class AppendCodeSheet {
public static void appendCodeSheet(Workbook workbook, List<CodeDto> codeList, String sheetName) {
List<CodeSheetDto> sheetRows = codeList.stream()
.map(CodeSheetDto::from)
.toList();
ExcelMapper.appendSheetToWorkbook(workbook, sheetRows, CodeSheetDto.class, sheetName, 1);
}
}

View File

@@ -0,0 +1,22 @@
package com.kri.gwcf.review.back.common.util;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@NoArgsConstructor
public final class ExcelResponseBuilder {
public static ResponseEntity<byte[]> buildExcelResponse(String fileName, byte[] bytes) {
String contentDisposition = "attachment; filename*=UTF-8''" +
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
.contentType(MediaType.parseMediaType(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.body(bytes);
}
}

View File

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

View File

@@ -0,0 +1,58 @@
package com.kri.gwcf.review.back.common.util;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public final class MakeExtraFieldMap {
private MakeExtraFieldMap() {
}
public static Map<String, String> toExtraFieldMap(
Object source,
Class<?> targetClass,
Collection<String> ignoreList
) {
Set<String> targetFieldNames = getFieldNames(targetClass);
Set<String> ignoreFieldNames = ignoreList == null
? Set.of()
: new HashSet<>(ignoreList);
Map<String, String> result = new LinkedHashMap<>();
for (Field field : source.getClass().getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())
|| targetFieldNames.contains(field.getName())
|| ignoreFieldNames.contains(field.getName())) {
continue;
}
try {
field.setAccessible(true);
result.put(field.getName(), toDetailValue(field.get(source)));
} catch (IllegalAccessException e) {
throw new IllegalStateException("Failed to read field: " + field.getName(), e);
}
}
return result;
}
private static Set<String> getFieldNames(Class<?> type) {
Set<String> fieldNames = new HashSet<>();
for (Field field : type.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) {
fieldNames.add(field.getName());
}
}
return fieldNames;
}
private static String toDetailValue(Object value) {
return value == null ? "" : String.valueOf(value);
}
}

View File

@@ -0,0 +1,41 @@
package com.kri.gwcf.review.back.common.util;
import com.kri.common.feature.util.StringUtil;
public final class TelUtil {
private TelUtil() {
}
public static String normalizeTel(String value) {
String normalized = StringUtil.normalizeBlank(value);
if (normalized == null) {
return "";
}
normalized = normalized.replace("-", "");
if (!normalized.startsWith("0")) {
normalized = "0" + normalized;
}
return normalized;
}
public static boolean validateTel(String value) {
String normalized = normalizeTel(value);
if (!StringUtil.hasText(normalized) || !normalized.matches("^\\d+$")) {
return false;
}
int length = normalized.length();
if (normalized.startsWith("02")) {
return length >= 9 && length <= 10;
}
if (normalized.startsWith("010")) {
return length == 11;
}
return length >= 10 && length <= 11;
}
}

View File

@@ -0,0 +1,64 @@
package com.kri.gwcf.review.back.config;
import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
@Configuration
@EnableJpaRepositories(
basePackages = "com.kri.gwcf.review.back.persistence.repository",
entityManagerFactoryRef = "mainEntityManagerFactory",
transactionManagerRef = "mainTransactionManager"
)
public class DataSourceConfig {
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSourceProperties mainDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "mainDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.hikari")
public HikariDataSource mainDataSource(
@Qualifier("mainDataSourceProperties") DataSourceProperties properties
) {
return properties.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
@Bean(name = "mainEntityManagerFactory")
@Primary
public LocalContainerEntityManagerFactoryBean mainEntityManagerFactory(
EntityManagerFactoryBuilder builder,
@Qualifier("mainDataSource") DataSource dataSource
) {
return builder
.dataSource(dataSource)
.packages("com.kri.gwcf.review.back.persistence.entity")
.persistenceUnit("main")
.build();
}
@Bean(name = "mainTransactionManager")
@Primary
public PlatformTransactionManager mainTransactionManager(
@Qualifier("mainEntityManagerFactory")
LocalContainerEntityManagerFactoryBean entityManagerFactory
) {
return new JpaTransactionManager(entityManagerFactory.getObject());
}
}

View File

@@ -0,0 +1,13 @@
package com.kri.gwcf.review.back.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Getter
@Setter
@ConfigurationProperties(prefix = "kri.file")
public class FileStorageProperties {
private String visitBaseDir;
private String reviewBaseDir;
}

View File

@@ -0,0 +1,142 @@
package com.kri.gwcf.review.back.config;
import com.zaxxer.hikari.HikariDataSource;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.MybatisProperties;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
@Configuration
@MapperScan(
basePackages = "com.kri.gwcf.review.back.persistence.mapper.kon",
sqlSessionTemplateRef = "konSqlSessionTemplate"
)
public class KonMyBatisConfig {
@Bean
@ConfigurationProperties(prefix = "kon.datasource")
public DataSourceProperties konDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "konDataSource")
@ConfigurationProperties(prefix = "kon.datasource.hikari")
public HikariDataSource konDataSource(
@Qualifier("konDataSourceProperties") DataSourceProperties properties
) {
return properties.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
@Bean
@ConfigurationProperties(prefix = "kon.mybatis")
public KonMybatisProperties konMybatisProperties() {
return new KonMybatisProperties();
}
@Bean(name = "konSqlSessionFactory")
public SqlSessionFactory konSqlSessionFactory(
@Qualifier("konDataSource") DataSource dataSource,
@Qualifier("konMybatisProperties") KonMybatisProperties properties
) throws Exception {
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setDataSource(dataSource);
factoryBean.setMapperLocations(resolveMapperLocations(properties.getMapperLocations()));
factoryBean.setTypeAliasesPackage(properties.getTypeAliasesPackage());
factoryBean.setConfigurationProperties(properties.getConfigurationProperties());
if (properties.getConfiguration() != null) {
org.apache.ibatis.session.Configuration configuration =
new org.apache.ibatis.session.Configuration();
properties.getConfiguration().applyTo(configuration);
factoryBean.setConfiguration(configuration);
}
return factoryBean.getObject();
}
private Resource[] resolveMapperLocations(String[] mapperLocations) {
if (mapperLocations == null || mapperLocations.length == 0) {
return new Resource[0];
}
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
return java.util.Arrays.stream(mapperLocations)
.flatMap(location -> {
try {
return java.util.Arrays.stream(resolver.getResources(location));
} catch (Exception e) {
throw new IllegalStateException("Failed to resolve MyBatis mapper location: " + location, e);
}
})
.toArray(Resource[]::new);
}
@Bean(name = "konSqlSessionTemplate")
public SqlSessionTemplate konSqlSessionTemplate(
@Qualifier("konSqlSessionFactory") SqlSessionFactory sqlSessionFactory
) {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean(name = "konTransactionManager")
public PlatformTransactionManager konTransactionManager(
@Qualifier("konDataSource") DataSource dataSource
) {
return new DataSourceTransactionManager(dataSource);
}
public static class KonMybatisProperties {
private String[] mapperLocations;
private String typeAliasesPackage;
private Properties configurationProperties;
@NestedConfigurationProperty
private MybatisProperties.CoreConfiguration configuration;
public String[] getMapperLocations() {
return mapperLocations;
}
public void setMapperLocations(String[] mapperLocations) {
this.mapperLocations = mapperLocations;
}
public String getTypeAliasesPackage() {
return typeAliasesPackage;
}
public void setTypeAliasesPackage(String typeAliasesPackage) {
this.typeAliasesPackage = typeAliasesPackage;
}
public Properties getConfigurationProperties() {
return configurationProperties;
}
public void setConfigurationProperties(Properties configurationProperties) {
this.configurationProperties = configurationProperties;
}
public MybatisProperties.CoreConfiguration getConfiguration() {
return configuration;
}
public void setConfiguration(MybatisProperties.CoreConfiguration configuration) {
this.configuration = configuration;
}
}
}

View File

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

View File

@@ -0,0 +1,27 @@
package com.kri.gwcf.review.back.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebResourceConfig implements WebMvcConfigurer {
@Value("${kri.file.visit-base-dir}")
private String visitBaseDir;
@Value("${kri.file.review-base-dir}")
private String reviewBaseDir;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// /visit-file/** → /data/upload-file/visit/** 매핑
registry.addResourceHandler("/visit-file/**")
.addResourceLocations("file:" + visitBaseDir + "/");
// /review-file/** → /data/upload-file/review/** 매핑
registry.addResourceHandler("/review-file/**")
.addResourceLocations("file:" + reviewBaseDir + "/");
}
}

View File

@@ -0,0 +1,31 @@
package com.kri.gwcf.review.back.controller;
import com.kri.common.feature.datetime.DateTimeUtil;
import com.kri.common.feature.web.RequestUserContext;
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/assign")
@RequiredArgsConstructor
@Tag(name = "Assign", description = "배정 API")
public class AssignController {
private final SystemEventLogService systemEventLogService;
@Operation(summary = "참여 동의")
@PostMapping("/confirm/{userId}")
public boolean assignConfirm(@PathVariable String userId, RequestUserContext ctx) {
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
systemEventLogService.writeAssignConfirmLog(userId, now, ctx.getClientIp());
return false;
}
}

View File

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

View File

@@ -0,0 +1,112 @@
package com.kri.gwcf.review.back.controller;
import static com.kri.gwcf.review.back.common.util.ExcelResponseBuilder.buildExcelResponse;
import com.kri.common.feature.datetime.DateTimeUtil;
import com.kri.common.feature.web.RequestUserContext;
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
import com.kri.gwcf.review.back.dto.performance.PerformanceCompactDto;
import com.kri.gwcf.review.back.dto.performance.PerformanceFullDto;
import com.kri.gwcf.review.back.dto.systemlog.UploadContentDto;
import com.kri.gwcf.review.back.service.PerformanceService;
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/v1/performance")
@RequiredArgsConstructor
@Tag(name = "Performance", description = "Performance API")
public class PerformanceController {
private final SystemEventLogService systemEventLogService;
private final PerformanceService performanceService;
@Operation(summary = "공연 조회")
@GetMapping("/{performanceId}")
public PerformanceFullDto getPerformance(@PathVariable Integer performanceId) {
return performanceService.getPerformance(performanceId);
}
@Operation(summary = "공연 목록 조회")
@GetMapping("/list")
public List<PerformanceFullDto> getPerformanceList() {
return performanceService.getPerformanceList();
}
@Operation(summary = "공연 목록 조회(간소화된 정보)")
@GetMapping("/list/compact")
public List<PerformanceCompactDto> getPerformanceCompactList() {
return performanceService.getPerformanceCompactList();
}
@Operation(summary = "공연정보 일괄 생성 양식 다운로드")
@PostMapping("/excel/template")
public ResponseEntity<byte[]> exportPerformanceTemplate() {
byte[] bytes = performanceService.exportPerformanceTemplate();
return buildExcelResponse("performance_upload_template.xlsx", bytes);
}
@Operation(
summary = "공연 일괄 생성(엑셀 업로드)",
description = "성공하면 JSON, 실패가 있으면 실패 내역 엑셀(xlsx) 반환"
)
@PostMapping(value = "/excel/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ExcelUploadResultDto createPerformanceFromExcel(
@RequestParam("file") MultipartFile file,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
ExcelUploadResultDto result = performanceService.createPerformancesFromExcel(file, regId, now);
systemEventLogService.writeUploadPerformanceLog(regId, now, clientIp, UploadContentDto.from(file));
return result;
}
@Operation(summary = "공연 정보 수정")
@PatchMapping()
public void updatePerformance(
@Valid @RequestBody PerformanceCompactDto dto,
RequestUserContext ctx
) {
String modId = ctx.getUserId();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
performanceService.updatePerformance(dto, modId, now);
systemEventLogService.writeUpdatePerformanceLog(modId, now, ctx.getClientIp(), dto);
}
@Operation(summary = "공연 삭제")
@DeleteMapping("/{performanceId}")
public void deletePerformance(
@PathVariable Integer performanceId,
RequestUserContext ctx
) {
String delId = ctx.getUserId();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
performanceService.deletePerformance(performanceId, delId);
systemEventLogService.writeDeletePerformanceLog(delId, now, ctx.getClientIp(), performanceId);
}
}

View File

@@ -0,0 +1,107 @@
package com.kri.gwcf.review.back.controller;
import static com.kri.gwcf.review.back.common.util.ExcelResponseBuilder.buildExcelResponse;
import com.kri.common.feature.datetime.DateTimeUtil;
import com.kri.common.feature.web.RequestUserContext;
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
import com.kri.gwcf.review.back.dto.systemlog.UploadContentDto;
import com.kri.gwcf.review.back.dto.user.UserFullDto;
import com.kri.gwcf.review.back.service.UserService;
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/v1/user")
@RequiredArgsConstructor
@Tag(name = "User", description = "사용자 API")
public class UserController {
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "사용자 조회")
@GetMapping("{userId}")
public UserFullDto getUser(@PathVariable String userId) {
return userService.getUser(userId);
}
@Operation(summary = "사용자 목록 조회")
@GetMapping("/list/{userRole}")
public List<UserFullDto> getUserList(@PathVariable Integer userRole) {
return userService.getUserList(userRole);
}
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
@PostMapping("/excel/template/{userRole}")
public ResponseEntity<byte[]> exportUserTemplate(
@PathVariable Integer userRole
) {
byte[] bytes = userService.exportUserTemplate(userRole);
return buildExcelResponse("user_upload_template.xlsx", bytes);
}
@Operation(
summary = "사용자 일괄 생성(엑셀 업로드)",
description = "성공하면 JSON, 실패가 있으면 실패 내역 엑셀(xlsx) 반환"
)
@PostMapping(value = "/excel/upload/{userRole}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ExcelUploadResultDto createUserFromExcel(
@PathVariable Integer userRole,
@RequestParam("file") MultipartFile file,
RequestUserContext ctx
) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
ExcelUploadResultDto result = userService.createUsersFromExcel(userRole, file, regId, now);
systemEventLogService.writeUploadUserLog(regId, now, clientIp, UploadContentDto.from(file));
return result;
}
@Operation(summary = "사용자 정보 수정")
@PatchMapping()
public void updateUser(
@Valid @RequestBody UserFullDto 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

@@ -0,0 +1,17 @@
package com.kri.gwcf.review.back.dto.auth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Schema(description = "사용자 로그인 요청")
public class LoginRequestDto {
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 PW")
private String userPw;
}

View File

@@ -0,0 +1,26 @@
package com.kri.gwcf.review.back.dto.auth;
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
@Getter
@Builder
@Schema(description = "로그인 응답")
public class LoginResponseDto {
@Schema(description = "jwt access 토큰")
private String accessToken;
@Schema(description = "사용자 정보")
private UserCompactDto user;
public static LoginResponseDto from(String accessToken, UserCompactDto user) {
return LoginResponseDto.builder()
.accessToken(accessToken)
.user(user)
.build();
}
}

View File

@@ -0,0 +1,46 @@
package com.kri.gwcf.review.back.dto.common;
import com.kri.gwcf.review.back.persistence.entity.TCodeEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CodeDto {
@Schema(description = "코드 그룹")
private String codeGroup;
@Schema(description = "코드 값")
private Integer codeValue;
@Schema(description = "코드 그룹 라벨")
private String codeGroupLabel;
@Schema(description = "코드 라벨")
private String codeLabel;
@Schema(description = "메모")
private String memo;
public static CodeDto from(TCodeEntity entity) {
if (entity == null) {
return null;
}
return CodeDto.builder()
.codeGroup(entity.getCodeGroup())
.codeValue(entity.getCodeValue())
.codeGroupLabel(entity.getCodeGroupLabel())
.codeLabel(entity.getCodeLabel())
.memo(entity.getMemo())
.build();
}
}

View File

@@ -0,0 +1,30 @@
package com.kri.gwcf.review.back.dto.common;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
@AllArgsConstructor
@Schema(description = "데이터 검증에 대한 공용 Dto")
public class DataVerificationDto {
@Schema(description = "데이터 검증 통과 여부")
private boolean success;
@Schema(description = "검증 필드명")
private String fieldName;
@Schema(description = "검증 메시지(error)")
private String errMessage;
public DataVerificationDto() {
this.success = true;
this.fieldName = "";
this.errMessage = "";
}
}

View File

@@ -0,0 +1,34 @@
package com.kri.gwcf.review.back.dto.excel;
import com.kri.common.feature.excel.ExcelColumn;
import com.kri.gwcf.review.back.dto.common.CodeDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CodeSheetDto {
@ExcelColumn(header = "Code", order = 0, width = 10)
private Integer codeValue;
@ExcelColumn(header = "Label", order = 1, width = 20)
private String codeLabel;
public static CodeSheetDto from(CodeDto dto) {
if (dto == null) {
return null;
}
return CodeSheetDto.builder()
.codeValue(dto.getCodeValue())
.codeLabel(dto.getCodeLabel())
.build();
}
}

View File

@@ -0,0 +1,29 @@
package com.kri.gwcf.review.back.dto.excel;
import com.kri.common.feature.excel.ExcelColumn;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@Getter
@Setter
public class ExcelErrorDto {
@ExcelColumn(header = "행 번호", order = 0)
private int rowNumber;
@ExcelColumn(header = "필드명", order = 1)
private String fieldName;
@ExcelColumn(header = "에러 메시지", order = 2)
private String errorMessage;
public static ExcelErrorDto of(int rowNumber, String fieldName, String errorMessage) {
return ExcelErrorDto.builder()
.rowNumber(rowNumber)
.fieldName(fieldName)
.errorMessage(errorMessage)
.build();
}
}

View File

@@ -0,0 +1,40 @@
package com.kri.gwcf.review.back.dto.excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class ExcelUploadResultDto {
@Schema(description = "전체 읽은 행 수 (헤더 제외)")
private int totalCount;
@Schema(description = "DB에 실제로 insert/update 성공한 개수")
private int successCount;
@Schema(description = "실패(에러) 개수")
private int failCount;
@Schema(description = "에러 엑셀 파일이 있는지 여부")
private boolean hasErrorFile;
@Schema(description = "프론트가 저장용으로 쓸 파일명")
private String errorFileName;
@Schema(description = "에러 엑셀 파일 (xlsx)의 Base64 문자열 (hasErrorFile == true일 때만 세팅)")
private String errorFileBase64;
public static ExcelUploadResultDto success(int totalCount, int successCount) {
return ExcelUploadResultDto.builder()
.totalCount(totalCount)
.successCount(successCount)
.failCount(0)
.hasErrorFile(false)
.build();
}
}

View File

@@ -0,0 +1,57 @@
package com.kri.gwcf.review.back.dto.excel;
import com.kri.common.feature.excel.ExcelColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MonitoringUserUploadDto implements UserUploadBaseDto {
@ExcelColumn(header = "사용자 ID", order = 0, width = 11)
@Schema(description = "사용자 ID")
private String userId;
@ExcelColumn(header = "사용자 PW", order = 1, width = 11)
@Schema(description = "사용자 PW")
private String userPw;
@ExcelColumn(header = "사용자 이름", order = 2, width = 11)
@Schema(description = "사용자 이름")
private String userName;
@ExcelColumn(header = "지역", order = 3, width = 11)
@Schema(description = "지역")
private String userArea;
@ExcelColumn(header = "성별", order = 4, width = 11)
@Schema(description = "성별")
private String userGender;
@ExcelColumn(header = "연령", order = 5, width = 11)
@Schema(description = "연령")
private String userAge;
@ExcelColumn(header = "사용자 연락처", order = 6, width = 14)
@Schema(description = "사용자 연락처")
private String userTel;
@ExcelColumn(header = "사용자 이메일", order = 7, width = 14)
@Schema(description = "사용자 이메일")
private String userEmail;
@ExcelColumn(header = "자차 유무", order = 8, width = 11)
@Schema(description = "자차 유무")
private String userHasCar;
@ExcelColumn(header = "메모", order = 9, width = 20)
@Schema(description = "메모")
private String memo;
}

View File

@@ -0,0 +1,113 @@
package com.kri.gwcf.review.back.dto.excel;
import com.kri.common.feature.excel.ExcelColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceUploadDto {
@ExcelColumn(header = "연번", order = 0, width = 10)
@Schema(description = "연번")
private String performanceId;
@ExcelColumn(header = "사업유형", order = 1, width = 10)
@Schema(description = "사업유형")
private String businessType;
@ExcelColumn(header = "분야(장르)", order = 2, width = 10)
@Schema(description = "분야(장르)")
private String genre;
@ExcelColumn(header = "지역", order = 3, width = 10)
@Schema(description = "지역")
private String performanceArea;
@ExcelColumn(header = "단체(인) 명", order = 4, width = 11)
@Schema(description = "단체(인) 명")
private String artistName;
@ExcelColumn(header = "사업 명", order = 5, width = 10)
@Schema(description = "사업 명")
private String performanceName;
@ExcelColumn(header = "사업 수행 월", order = 6, width = 12)
@Schema(description = "사업 수행 월")
private String performanceStartMonth;
@ExcelColumn(header = "사업 일정", order = 7, width = 10)
@Schema(description = "사업 일정")
private String performanceDtInfo;
@ExcelColumn(header = "운영 시간", order = 8, width = 10)
@Schema(description = "운영 시간")
private String performanceTimeInfo;
@ExcelColumn(header = "티켓 예약", order = 9, width = 10)
@Schema(description = "티켓 예약")
private String ticketReservationStatus;
@ExcelColumn(header = "티켓 비고", order = 10, width = 10)
@Schema(description = "티켓 비고")
private String ticketReservationMemo;
@ExcelColumn(header = "모니터링 일정", order = 11, width = 14)
@Schema(description = "모니터링 일정")
private String monitoringDate;
@ExcelColumn(header = "모니터링 시간", order = 12, width = 14)
@Schema(description = "모니터링 시간")
private String monitoringTimeInfo;
@ExcelColumn(header = "모니터링 방문 장소", order = 13, width = 18)
@Schema(description = "모니터링 방문 장소")
private String monitoringAddress;
@ExcelColumn(header = "대표자 명", order = 14, width = 10)
@Schema(description = "대표자 명")
private String ownStaffName;
@ExcelColumn(header = "대표자 연락처1", order = 15, width = 14)
@Schema(description = "대표자 연락처1")
private String ownStaffTel1;
@ExcelColumn(header = "대표자 연락처2", order = 16, width = 14)
@Schema(description = "대표자 연락처2")
private String ownStaffTel2;
@ExcelColumn(header = "대표자 이메일", order = 17, width = 14)
@Schema(description = "대표자 이메일")
private String ownStaffEmail;
@ExcelColumn(header = "실무자 명", order = 18, width = 10)
@Schema(description = "실무자 명")
private String contactStaffName;
@ExcelColumn(header = "실무자 연락처1", order = 19, width = 14)
@Schema(description = "실무자 연락처1")
private String contactStaffTel1;
@ExcelColumn(header = "실무자 연락처2", order = 20, width = 14)
@Schema(description = "실무자 연락처2")
private String contactStaffTel2;
@ExcelColumn(header = "실무자 이메일", order = 21, width = 14)
@Schema(description = "실무자 이메일")
private String contactStaffEmail;
@ExcelColumn(header = "메모", order = 22, width = 10)
@Schema(description = "메모")
private String performanceMemo;
@ExcelColumn(header = "요원 비용지급일", order = 23, width = 16)
@Schema(description = "요원 비용지급일")
private String monitoringPaymentDate;
}

View File

@@ -0,0 +1,12 @@
package com.kri.gwcf.review.back.dto.excel;
public interface UserUploadBaseDto {
String getUserId();
String getUserPw();
String getUserName();
String getMemo();
}

View File

@@ -0,0 +1,45 @@
package com.kri.gwcf.review.back.dto.excel;
import com.kri.common.feature.excel.ExcelColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WrittenUserUploadDto implements UserUploadBaseDto {
@ExcelColumn(header = "사용자 ID", order = 0, width = 11)
@Schema(description = "사용자 ID")
private String userId;
@ExcelColumn(header = "사용자 PW", order = 1, width = 11)
@Schema(description = "사용자 PW")
private String userPw;
@ExcelColumn(header = "사용자 이름", order = 2, width = 11)
@Schema(description = "사용자 이름")
private String userName;
@ExcelColumn(header = "평가위원 장르", order = 3, width = 14)
@Schema(description = "평가위원 장르")
private String userGenre;
@ExcelColumn(header = "사용자 연락처", order = 4, width = 14)
@Schema(description = "사용자 연락처")
private String userTel;
@ExcelColumn(header = "사용자 이메일", order = 5, width = 14)
@Schema(description = "사용자 이메일")
private String userEmail;
@ExcelColumn(header = "메모", order = 6, width = 20)
@Schema(description = "메모")
private String memo;
}

View File

@@ -0,0 +1,51 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceAssignDto {
@Schema(description = "배정 인덱스")
private Long id;
@Schema(description = "사업고유id")
private Integer performanceId;
@Schema(description = "배정 타입 review_type중 1,2만 사용")
private Integer assignType;
@Schema(description = "배정 순서(모니터링에 의미가 있음)")
private Short assignOrder;
@Schema(description = "사용자 id")
private String assignUser;
@Schema(description = "사용자 컨펌 여부")
private Boolean assignConfirm;
public static PerformanceAssignDto from(TPerformanceAssignEntity entity) {
if (entity == null) {
return null;
}
return PerformanceAssignDto.builder()
.id(entity.getId())
.performanceId(entity.getPerformanceId())
.assignType(entity.getAssignType())
.assignOrder(entity.getAssignOrder())
.assignUser(entity.getAssignUser())
.assignConfirm(entity.getAssignConfirm())
.build();
}
}

View File

@@ -0,0 +1,75 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.experimental.SuperBuilder;
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceBaseDto {
@Schema(description = "사업고유id")
private Integer id;
@Schema(description = "사업유형")
private Integer businessType;
@Schema(description = "분야(장르)")
private Integer performanceGenre;
@Schema(description = "시도")
private Integer performanceArea;
@Schema(description = "단체(인) 명")
private String artistName;
@Schema(description = "사업 명")
private String performanceName;
@Schema(description = "사업 수행 월")
private Integer performanceStartMonth;
@Schema(description = "사업 일정 정보")
private String performanceDtInfo;
@Schema(description = "운영 시간 정보")
private String performanceTimeInfo;
@Schema(description = "티켓 예약")
private Integer ticketReservationStatus;
@Schema(description = "티켓 비고")
private String ticketReservationMemo;
@Schema(description = "메모")
private String performanceMemo;
public static PerformanceBaseDto from(TPerformanceEntity entity) {
if (entity == null) {
return null;
}
return PerformanceBaseDto.builder()
.id(entity.getId())
.businessType(entity.getBusinessType())
.performanceGenre(entity.getPerformanceGenre())
.performanceArea(entity.getPerformanceArea())
.artistName(entity.getArtistName())
.performanceName(entity.getPerformanceName())
.performanceStartMonth(entity.getPerformanceStartMonth())
.performanceDtInfo(entity.getPerformanceDtInfo())
.performanceTimeInfo(entity.getPerformanceTimeInfo())
.ticketReservationStatus(entity.getTicketReservationStatus())
.ticketReservationMemo(entity.getTicketReservationMemo())
.performanceMemo(entity.getPerformanceMemo())
.build();
}
}

View File

@@ -0,0 +1,72 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceCompactDto extends PerformanceBaseDto {
@Schema(description = "공연 상세 정보")
private Map<String, String> performanceDetail;
@Schema(description = "공연 관계자 정보")
private List<PerformanceStaffDto> performanceStaff;
@Schema(description = "공연 방문 일정 정보")
private PerformanceMonitoringScheduleDto performanceMonitoringSchedule;
public static PerformanceCompactDto from(
TPerformanceEntity performance,
Map<String, String> performanceDetail,
List<PerformanceStaffDto> performanceStaff,
PerformanceMonitoringScheduleDto performanceMonitoringSchedule
) {
return of(
PerformanceBaseDto.from(performance),
performanceDetail,
performanceStaff,
performanceMonitoringSchedule
);
}
public static PerformanceCompactDto of(
PerformanceBaseDto performance,
Map<String, String> performanceDetail,
List<PerformanceStaffDto> performanceStaff,
PerformanceMonitoringScheduleDto performanceMonitoringSchedule
) {
if (performance == null) {
return null;
}
return PerformanceCompactDto.builder()
.id(performance.getId())
.businessType(performance.getBusinessType())
.performanceGenre(performance.getPerformanceGenre())
.performanceArea(performance.getPerformanceArea())
.artistName(performance.getArtistName())
.performanceName(performance.getPerformanceName())
.performanceStartMonth(performance.getPerformanceStartMonth())
.performanceDtInfo(performance.getPerformanceDtInfo())
.performanceTimeInfo(performance.getPerformanceTimeInfo())
.ticketReservationStatus(performance.getTicketReservationStatus())
.ticketReservationMemo(performance.getTicketReservationMemo())
.performanceMemo(performance.getPerformanceMemo())
.performanceDetail(performanceDetail)
.performanceStaff(performanceStaff)
.performanceMonitoringSchedule(performanceMonitoringSchedule)
.build();
}
}

View File

@@ -0,0 +1,92 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceFullDto extends PerformanceBaseDto {
@Schema(description = "공연 상세 정보")
private Map<String, String> performanceDetail;
@Schema(description = "공연 관계자 정보")
private List<PerformanceStaffDto> performanceStaff;
@Schema(description = "공연 방문 일정 정보")
private PerformanceMonitoringScheduleDto performanceMonitoringSchedule;
@Schema(description = "공연 배정 정보")
private List<PerformanceAssignDto> performanceAssignList;
@Schema(description = "userID 별 방문 정보")
private Map<String, List<PerformanceMonitoringVisitDto>> performanceMonitoringVisitMap;
@Schema(description = "userID 별 평가 정보")
private Map<String, List<PerformanceReviewDto>> performanceReviewMap;
public static PerformanceFullDto from(
TPerformanceEntity performance,
Map<String, String> performanceDetail,
List<PerformanceStaffDto> performanceStaff,
PerformanceMonitoringScheduleDto performanceMonitoringSchedule,
List<PerformanceAssignDto> performanceAssignList,
Map<String, List<PerformanceMonitoringVisitDto>> performanceMonitoringVisitMap,
Map<String, List<PerformanceReviewDto>> performanceReviewMap
) {
return of(
PerformanceBaseDto.from(performance),
performanceDetail,
performanceStaff,
performanceMonitoringSchedule,
performanceAssignList,
performanceMonitoringVisitMap,
performanceReviewMap
);
}
public static PerformanceFullDto of(
PerformanceBaseDto performance,
Map<String, String> performanceDetail,
List<PerformanceStaffDto> performanceStaff,
PerformanceMonitoringScheduleDto performanceMonitoringSchedule,
List<PerformanceAssignDto> performanceAssignList,
Map<String, List<PerformanceMonitoringVisitDto>> performanceMonitoringVisitMap,
Map<String, List<PerformanceReviewDto>> performanceReviewMap
) {
if (performance == null) {
return null;
}
return PerformanceFullDto.builder()
.id(performance.getId())
.businessType(performance.getBusinessType())
.performanceGenre(performance.getPerformanceGenre())
.performanceArea(performance.getPerformanceArea())
.artistName(performance.getArtistName())
.performanceName(performance.getPerformanceName())
.performanceStartMonth(performance.getPerformanceStartMonth())
.performanceDtInfo(performance.getPerformanceDtInfo())
.performanceTimeInfo(performance.getPerformanceTimeInfo())
.ticketReservationStatus(performance.getTicketReservationStatus())
.ticketReservationMemo(performance.getTicketReservationMemo())
.performanceMemo(performance.getPerformanceMemo())
.performanceDetail(performanceDetail)
.performanceStaff(performanceStaff)
.performanceMonitoringSchedule(performanceMonitoringSchedule)
.performanceAssignList(performanceAssignList)
.performanceMonitoringVisitMap(performanceMonitoringVisitMap)
.performanceReviewMap(performanceReviewMap)
.build();
}
}

View File

@@ -0,0 +1,48 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceMonitoringScheduleDto {
@Schema(description = "사업 방문 스케쥴 인덱스")
private Long id;
@Schema(description = "사업고유id")
private Integer performanceId;
@Schema(description = "모니터링 일정")
private LocalDate monitoringDate;
@Schema(description = "모니터링 시간")
private String monitoringTimeInfo;
@Schema(description = "모니터링 방문 장소 주소")
private String monitoringAddress;
public static PerformanceMonitoringScheduleDto from(TPerformanceMonitoringScheduleEntity entity) {
if (entity == null) {
return null;
}
return PerformanceMonitoringScheduleDto.builder()
.id(entity.getId())
.performanceId(entity.getPerformanceId())
.monitoringDate(entity.getMonitoringDate())
.monitoringTimeInfo(entity.getMonitoringTimeInfo())
.monitoringAddress(entity.getMonitoringAddress())
.build();
}
}

View File

@@ -0,0 +1,61 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringVisitEntity;
import java.math.BigDecimal;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceMonitoringVisitDto {
@Schema(description = "모니터링 방문 인덱스")
private Long id;
@Schema(description = "사업고유id")
private Integer performanceId;
@Schema(description = "모니터링 방문 상태")
private Integer monitoringVisitStatus;
@Schema(description = "|로 이어붙인 파일명")
private String evidenceImg;
@Schema(description = "GPS 위도")
private BigDecimal gpsLatitude;
@Schema(description = "GPS 경도")
private BigDecimal gpsLongitude;
@Schema(description = "GPS 신뢰 반경(m)")
private BigDecimal gpsAccuracyM;
@Schema(description = "GPS Raw Data")
private Map<String, Object> gpsRaw;
public static PerformanceMonitoringVisitDto from(TPerformanceMonitoringVisitEntity entity) {
if (entity == null) {
return null;
}
return PerformanceMonitoringVisitDto.builder()
.id(entity.getId())
.performanceId(entity.getPerformanceId())
.monitoringVisitStatus(entity.getMonitoringVisitStatus())
.evidenceImg(entity.getEvidenceImg())
.gpsLatitude(entity.getGpsLatitude())
.gpsLongitude(entity.getGpsLongitude())
.gpsAccuracyM(entity.getGpsAccuracyM())
.gpsRaw(entity.getGpsRaw())
.build();
}
}

View File

@@ -0,0 +1,51 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceReviewDto {
@Schema(description = "사업고유id")
private Integer performanceId;
@Schema(description = "평가 타입")
private Integer reviewType;
@Schema(description = "평가 상태")
private Integer reviewStatus;
@Schema(description = "업로드 파일명")
private String uploadFileName;
@Schema(description = "pdf로 변환성공 여부")
private Boolean pdfConvert;
@Schema(description = "pdf로 변환된 파일명")
private String pdfFileName;
public static PerformanceReviewDto from(TPerformanceReviewEntity entity) {
if (entity == null) {
return null;
}
return PerformanceReviewDto.builder()
.performanceId(entity.getPerformanceId())
.reviewType(entity.getReviewType())
.reviewStatus(entity.getReviewStatus())
.uploadFileName(entity.getUploadFileName())
.pdfConvert(entity.getPdfConvert())
.pdfFileName(entity.getPdfFileName())
.build();
}
}

View File

@@ -0,0 +1,55 @@
package com.kri.gwcf.review.back.dto.performance;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceStaffEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PerformanceStaffDto {
@Schema(description = "사업 관계자 인덱스")
private Long id;
@Schema(description = "사업고유id")
private Integer performanceId;
@Schema(description = "관계자 타입")
private Integer staffType;
@Schema(description = "관계자 이름")
private String staffName;
@Schema(description = "관계자 연락처1")
private String staffTel1;
@Schema(description = "관계자 연락처2")
private String staffTel2;
@Schema(description = "관계자 이메일")
private String staffEmail;
public static PerformanceStaffDto from(TPerformanceStaffEntity entity) {
if (entity == null) {
return null;
}
return PerformanceStaffDto.builder()
.id(entity.getId())
.performanceId(entity.getPerformanceId())
.staffType(entity.getStaffType())
.staffName(entity.getStaffName())
.staffTel1(entity.getStaffTel1())
.staffTel2(entity.getStaffTel2())
.staffEmail(entity.getStaffEmail())
.build();
}
}

View File

@@ -0,0 +1,28 @@
package com.kri.gwcf.review.back.dto.systemlog;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.web.multipart.MultipartFile;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UploadContentDto {
String fileName;
String fileType;
Long fileSize;
public static UploadContentDto from(MultipartFile file){
return UploadContentDto.builder()
.fileName(file.getOriginalFilename())
.fileType(file.getContentType())
.fileSize(file.getSize())
.build();
}
}

View File

@@ -0,0 +1,51 @@
package com.kri.gwcf.review.back.dto.user;
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserCompactDto {
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 소속 회사")
private String userCmpn;
@Schema(description = "팀 코드")
private String userTeam;
@Schema(description = "사용자 이름")
private String userName;
@Schema(description = "권한 코드")
private Integer userRole;
@Schema(description = "사용자 상세 정보")
private Map<String, String> userDetail;
public static UserCompactDto from(TUserEntity entity, Map<String, String> userDetail) {
if (entity == null) {
return null;
}
return UserCompactDto.builder()
.userId(entity.getUserId())
.userName(entity.getUserName())
.userCmpn(entity.getUserCmpn())
.userTeam(entity.getUserTeam())
.userRole(entity.getUserRole())
.userDetail(userDetail)
.build();
}
}

View File

@@ -0,0 +1,83 @@
package com.kri.gwcf.review.back.dto.user;
import static com.kri.gwcf.review.back.common.util.MakeExtraFieldMap.toExtraFieldMap;
import com.kri.gwcf.review.back.dto.excel.UserUploadBaseDto;
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
import java.util.Collection;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import io.swagger.v3.oas.annotations.media.Schema;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserFullDto {
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "PW")
private String userPw;
@Schema(description = "이름")
private String userName;
@Schema(description = "소속 회사")
private String userCmpn;
@Schema(description = "팀")
private String userTeam;
@Schema(description = "권한")
private Integer userRole;
@Schema(description = "메모")
private String memo;
@Schema(description = "사용자 상세 정보")
private Map<String, String> userDetail;
public static UserFullDto from(TUserEntity entity, Map<String, String> userDetail) {
if (entity == null) {
return null;
}
return UserFullDto.builder()
.userId(entity.getUserId())
.userPw(entity.getUserPw())
.userName(entity.getUserName())
.userCmpn(entity.getUserCmpn())
.userTeam(entity.getUserTeam())
.userRole(entity.getUserRole())
.memo(entity.getMemo())
.userDetail(userDetail)
.build();
}
public static UserFullDto from(
UserUploadBaseDto dto,
Integer userRole,
Collection<String> ignoreList
) {
Map<String, String> userDetail = toExtraFieldMap(dto, UserFullDto.class, ignoreList);
return UserFullDto.builder()
.userId(dto.getUserId())
.userPw(dto.getUserPw())
.userName(dto.getUserName())
.userCmpn("")
.userTeam("")
.userRole(userRole)
.memo(dto.getMemo())
.userDetail(userDetail)
.build();
}
}

View File

@@ -0,0 +1,68 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.common.CodeDto;
import com.kri.gwcf.review.back.persistence.entity.id.TCodeEntityId;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_code")
public class TCodeEntity {
@EmbeddedId
private TCodeEntityId id;
@Size(max = 64)
@NotNull
@Column(name = "code_group_label", nullable = false, length = 64)
private String codeGroupLabel;
@Size(max = 2048)
@NotNull
@Column(name = "code_label", nullable = false, length = 2048)
private String codeLabel;
@NotNull
@Lob
@Column(name = "memo", nullable = false)
private String memo;
public String getCodeGroup() {
return id.getCodeGroup();
}
public Integer getCodeValue() {
return id.getCodeValue();
}
public static TCodeEntity from(CodeDto dto) {
if (dto == null) {
return null;
}
TCodeEntity entity = new TCodeEntity();
entity.setId(TCodeEntityId.builder()
.codeGroup(dto.getCodeGroup())
.codeValue(dto.getCodeValue())
.build());
entity.setCodeGroupLabel(dto.getCodeGroupLabel());
entity.setCodeLabel(dto.getCodeLabel());
entity.setMemo(dto.getMemo());
return entity;
}
}

View File

@@ -0,0 +1,75 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.performance.PerformanceAssignDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "t_performance_assign")
public class TPerformanceAssignEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "performance_assign_idx", nullable = false, updatable = false)
private Long id;
@NotNull
@Column(name = "performance_id", nullable = false)
private Integer performanceId;
@NotNull
@Column(name = "assign_type", nullable = false)
private Integer assignType;
@NotNull
@Column(name = "assign_order", nullable = false)
private Short assignOrder;
@Size(max = 32)
@NotNull
@Column(name = "assign_user", nullable = false, length = 32)
private String assignUser;
@NotNull
@Column(name = "is_assign_confirm", nullable = false)
private Boolean assignConfirm;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
public static TPerformanceAssignEntity from(PerformanceAssignDto dto) {
if (dto == null) {
return null;
}
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
entity.setId(dto.getId());
entity.setPerformanceId(dto.getPerformanceId());
entity.setAssignType(dto.getAssignType());
entity.setAssignOrder(dto.getAssignOrder());
entity.setAssignUser(dto.getAssignUser());
entity.setAssignConfirm(dto.getAssignConfirm());
return entity;
}
}

View File

@@ -0,0 +1,77 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.persistence.entity.id.TPerformanceDetailEntityId;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_performance_detail")
public class TPerformanceDetailEntity {
@EmbeddedId
private TPerformanceDetailEntityId id;
@Size(max = 2048)
@NotNull
@Column(name = "performance_detail_value", nullable = false, length = 2048)
private String performanceDetailValue;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public Integer getPerformanceId() {
return id.getPerformanceId();
}
public String getPerformanceDetailKey() {
return id.getPerformanceDetailKey();
}
public static TPerformanceDetailEntity update(
Integer performanceId,
String performanceDetailKey,
String performanceDetailValue,
String modUser,
LocalDateTime modDt
) {
return TPerformanceDetailEntity.builder()
.id(TPerformanceDetailEntityId.builder()
.performanceId(performanceId)
.performanceDetailKey(performanceDetailKey)
.build())
.performanceDetailValue(performanceDetailValue)
.regUser(modUser)
.regDt(modDt)
.modUser(modUser)
.modDt(modDt)
.build();
}
}

View File

@@ -0,0 +1,137 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.performance.PerformanceBaseDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_performance")
public class TPerformanceEntity {
@Id
@Column(name = "performance_id", nullable = false, updatable = false)
private Integer id;
@NotNull
@Column(name = "business_type", nullable = false)
private Integer businessType;
@NotNull
@Column(name = "performance_genre", nullable = false)
private Integer performanceGenre;
@NotNull
@Column(name = "performance_area", nullable = false)
private Integer performanceArea;
@Size(max = 128)
@NotNull
@Column(name = "artist_name", nullable = false, length = 128)
private String artistName;
@Size(max = 128)
@NotNull
@Column(name = "performance_name", nullable = false, length = 128)
private String performanceName;
@NotNull
@Column(name = "performance_start_month", nullable = false)
private Integer performanceStartMonth;
@Size(max = 256)
@NotNull
@Column(name = "performance_dt_info", nullable = false, length = 256)
private String performanceDtInfo;
@Size(max = 256)
@NotNull
@Column(name = "performance_time_info", nullable = false, length = 256)
private String performanceTimeInfo;
@NotNull
@Column(name = "ticket_reservation_status", nullable = false)
private Integer ticketReservationStatus;
@NotNull
@Lob
@Column(name = "ticket_reservation_memo", nullable = false)
private String ticketReservationMemo;
@NotNull
@Lob
@Column(name = "performance_memo", nullable = false)
private String performanceMemo;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public static TPerformanceEntity from(PerformanceBaseDto dto) {
if (dto == null) {
return null;
}
TPerformanceEntity entity = new TPerformanceEntity();
entity.setId(dto.getId());
entity.setBusinessType(dto.getBusinessType());
entity.setPerformanceGenre(dto.getPerformanceGenre());
entity.setPerformanceArea(dto.getPerformanceArea());
entity.setArtistName(dto.getArtistName());
entity.setPerformanceName(dto.getPerformanceName());
entity.setPerformanceStartMonth(dto.getPerformanceStartMonth());
entity.setPerformanceDtInfo(dto.getPerformanceDtInfo());
entity.setPerformanceTimeInfo(dto.getPerformanceTimeInfo());
entity.setTicketReservationStatus(dto.getTicketReservationStatus());
entity.setTicketReservationMemo(dto.getTicketReservationMemo());
entity.setPerformanceMemo(dto.getPerformanceMemo());
return entity;
}
public void updateFromDto(PerformanceBaseDto dto, String modUser, LocalDateTime modDt) {
this.businessType = dto.getBusinessType();
this.performanceGenre = dto.getPerformanceGenre();
this.performanceArea = dto.getPerformanceArea();
this.artistName = dto.getArtistName();
this.performanceName = dto.getPerformanceName();
this.performanceStartMonth = dto.getPerformanceStartMonth();
this.performanceDtInfo = dto.getPerformanceDtInfo();
this.performanceTimeInfo = dto.getPerformanceTimeInfo();
this.ticketReservationStatus = dto.getTicketReservationStatus();
this.ticketReservationMemo = dto.getTicketReservationMemo();
this.performanceMemo = dto.getPerformanceMemo();
this.modUser = modUser;
this.modDt = modDt;
}
}

View File

@@ -0,0 +1,97 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringScheduleDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_performance_monitoring_schedule")
public class TPerformanceMonitoringScheduleEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "performance_monitoring_schedule_idx", nullable = false, updatable = false)
private Long id;
@NotNull
@Column(name = "performance_id", nullable = false)
private Integer performanceId;
@NotNull
@Column(name = "monitoring_date", nullable = false)
private LocalDate monitoringDate;
@Size(max = 256)
@NotNull
@Column(name = "monitoring_time_info", nullable = false, length = 256)
private String monitoringTimeInfo;
@Size(max = 2048)
@NotNull
@Column(name = "monitoring_address", nullable = false, length = 2048)
private String monitoringAddress;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public static TPerformanceMonitoringScheduleEntity from(PerformanceMonitoringScheduleDto dto) {
if (dto == null) {
return null;
}
TPerformanceMonitoringScheduleEntity entity = new TPerformanceMonitoringScheduleEntity();
entity.setId(dto.getId());
entity.setPerformanceId(dto.getPerformanceId());
entity.setMonitoringDate(dto.getMonitoringDate());
entity.setMonitoringTimeInfo(dto.getMonitoringTimeInfo());
entity.setMonitoringAddress(dto.getMonitoringAddress());
return entity;
}
public void updateFromDto(
PerformanceMonitoringScheduleDto dto,
String modUser,
LocalDateTime modDt
) {
this.monitoringDate = dto.getMonitoringDate();
this.monitoringTimeInfo = dto.getMonitoringTimeInfo();
this.monitoringAddress = dto.getMonitoringAddress();
this.modUser = modUser;
this.modDt = modDt;
}
}

View File

@@ -0,0 +1,92 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringVisitDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_performance_monitoring_visit")
public class TPerformanceMonitoringVisitEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "performance_monitoring_visit_idx", nullable = false, updatable = false)
private Long id;
@NotNull
@Column(name = "performance_id", nullable = false)
private Integer performanceId;
@NotNull
@Column(name = "monitoring_visit_status", nullable = false)
private Integer monitoringVisitStatus;
@Size(max = 2048)
@NotNull
@Column(name = "evidence_img", nullable = false, length = 2048)
private String evidenceImg;
@Column(name = "gps_latitude", precision = 10, scale = 7)
private BigDecimal gpsLatitude;
@Column(name = "gps_longitude", precision = 10, scale = 7)
private BigDecimal gpsLongitude;
@Column(name = "gps_accuracy_m", precision = 8, scale = 2)
private BigDecimal gpsAccuracyM;
@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "gps_raw")
private Map<String, Object> gpsRaw;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
public static TPerformanceMonitoringVisitEntity from(PerformanceMonitoringVisitDto dto) {
if (dto == null) {
return null;
}
TPerformanceMonitoringVisitEntity entity = new TPerformanceMonitoringVisitEntity();
entity.setId(dto.getId());
entity.setPerformanceId(dto.getPerformanceId());
entity.setMonitoringVisitStatus(dto.getMonitoringVisitStatus());
entity.setEvidenceImg(dto.getEvidenceImg());
entity.setGpsLatitude(dto.getGpsLatitude());
entity.setGpsLongitude(dto.getGpsLongitude());
entity.setGpsAccuracyM(dto.getGpsAccuracyM());
entity.setGpsRaw(dto.getGpsRaw());
return entity;
}
}

View File

@@ -0,0 +1,90 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
import com.kri.gwcf.review.back.persistence.entity.id.TPerformanceReviewEntityId;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_performance_review")
public class TPerformanceReviewEntity {
@EmbeddedId
private TPerformanceReviewEntityId id;
@NotNull
@Column(name = "review_status", nullable = false)
private Integer reviewStatus;
@Size(max = 512)
@NotNull
@Column(name = "upload_file_name", nullable = false, length = 512)
private String uploadFileName;
@NotNull
@Column(name = "is_pdf_convert", nullable = false)
private Boolean pdfConvert;
@Size(max = 512)
@NotNull
@Column(name = "pdf_file_name", nullable = false, length = 512)
private String pdfFileName;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public Integer getPerformanceId() {
return id.getPerformanceId();
}
public Integer getReviewType() {
return id.getReviewType();
}
public static TPerformanceReviewEntity from(PerformanceReviewDto dto) {
if (dto == null) {
return null;
}
TPerformanceReviewEntity entity = new TPerformanceReviewEntity();
entity.setId(TPerformanceReviewEntityId.builder()
.performanceId(dto.getPerformanceId())
.reviewType(dto.getReviewType())
.build());
entity.setReviewStatus(dto.getReviewStatus());
entity.setUploadFileName(dto.getUploadFileName());
entity.setPdfConvert(dto.getPdfConvert());
entity.setPdfFileName(dto.getPdfFileName());
return entity;
}
}

View File

@@ -0,0 +1,84 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.performance.PerformanceStaffDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_performance_staff")
public class TPerformanceStaffEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "performance_staff_idx", nullable = false, updatable = false)
private Long id;
@NotNull
@Column(name = "performance_id", nullable = false)
private Integer performanceId;
@NotNull
@Column(name = "staff_type", nullable = false)
private Integer staffType;
@Size(max = 32)
@NotNull
@Column(name = "staff_name", nullable = false, length = 32)
private String staffName;
@Size(max = 32)
@Column(name = "staff_tel1", length = 32)
private String staffTel1;
@Size(max = 32)
@Column(name = "staff_tel2", length = 32)
private String staffTel2;
@Size(max = 128)
@Column(name = "staff_email", length = 128)
private String staffEmail;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
public static TPerformanceStaffEntity from(PerformanceStaffDto dto) {
if (dto == null) {
return null;
}
TPerformanceStaffEntity entity = new TPerformanceStaffEntity();
entity.setId(dto.getId());
entity.setPerformanceId(dto.getPerformanceId());
entity.setStaffType(dto.getStaffType());
entity.setStaffName(dto.getStaffName());
entity.setStaffTel1(dto.getStaffTel1());
entity.setStaffTel2(dto.getStaffTel2());
entity.setStaffEmail(dto.getStaffEmail());
return entity;
}
}

View File

@@ -0,0 +1,83 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.common.enums.SystemEventType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
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.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_sys_event_log")
public class TSysEventLogEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "sys_event_log_idx", nullable = false, updatable = false)
private Long id;
@NotNull
@Column(name = "event_ty", nullable = false)
private Short eventTy;
@Size(max = 128)
@NotNull
@Column(name = "log_title", nullable = false, length = 128)
private String logTitle;
@NotNull
@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "log_content", nullable = false)
private Map<String, Object> logContent;
@Size(max = 16)
@NotNull
@Column(name = "ip", nullable = false, length = 16)
private String ip;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
public static TSysEventLogEntity of(
SystemEventType eventType,
String title,
Map<String, Object> logContent,
String clientIp,
String regId,
LocalDateTime regDt
) {
return TSysEventLogEntity.builder()
.eventTy(eventType.getCode())
.logTitle(title)
.logContent(logContent)
.ip(clientIp)
.regUser(regId)
.regDt(regDt)
.build();
}
}

View File

@@ -0,0 +1,93 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.persistence.entity.id.TUserDetailEntityId;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_user_detail")
public class TUserDetailEntity {
@EmbeddedId
private TUserDetailEntityId id;
@Size(max = 2048)
@NotNull
@Column(name = "user_detail_value", nullable = false, length = 2048)
private String userDetailValue;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public String getUserId() {
return id.getUserId();
}
public String getUserDetailKey() {
return id.getUserDetailKey();
}
public static TUserDetailEntity create(
String userId,
String userDetailKey,
String userDetailValue,
String regUser,
LocalDateTime regDt
) {
return TUserDetailEntity.builder()
.id(TUserDetailEntityId.builder()
.userId(userId)
.userDetailKey(userDetailKey)
.build())
.userDetailValue(userDetailValue)
.regUser(regUser)
.regDt(regDt)
.build();
}
public static TUserDetailEntity update(
String userId,
String userDetailKey,
String userDetailValue,
String modUser,
LocalDateTime modDt
) {
return TUserDetailEntity.builder()
.id(TUserDetailEntityId.builder()
.userId(userId)
.userDetailKey(userDetailKey)
.build())
.userDetailValue(userDetailValue)
.modUser(modUser)
.modDt(modDt)
.build();
}
}

View File

@@ -0,0 +1,107 @@
package com.kri.gwcf.review.back.persistence.entity;
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
import com.kri.gwcf.review.back.dto.user.UserFullDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "t_user")
public class TUserEntity {
@Id
@Size(max = 32)
@Column(name = "user_id", nullable = false, length = 32, updatable = false)
private String userId;
@Size(max = 64)
@NotNull
@Column(name = "user_pw", nullable = false, length = 64)
private String userPw;
@Size(max = 32)
@NotNull
@Column(name = "user_name", nullable = false, length = 32)
private String userName;
@Size(max = 32)
@NotNull
@Column(name = "user_cmpn", nullable = false, length = 32, updatable = false)
private String userCmpn;
@Size(max = 32)
@NotNull
@Column(name = "user_team", nullable = false, length = 32, updatable = false)
private String userTeam;
@NotNull
@Column(name = "user_role", nullable = false, updatable = false)
private Integer userRole;
@NotNull
@Lob
@Column(name = "memo", nullable = false)
private String memo;
@Size(max = 32)
@NotNull
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
private String regUser;
@NotNull
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "reg_dt", nullable = false, updatable = false)
private LocalDateTime regDt;
@Size(max = 32)
@Column(name = "mod_user", length = 32, insertable = false)
private String modUser;
@Column(name = "mod_dt", insertable = false)
private LocalDateTime modDt;
public static TUserEntity from(UserFullDto dto, String regUser, LocalDateTime regDt) {
if (dto == null) {
return null;
}
TUserEntity entity = new TUserEntity();
entity.setUserId(dto.getUserId());
entity.setUserPw(dto.getUserPw());
entity.setUserName(dto.getUserName());
entity.setUserCmpn(dto.getUserCmpn());
entity.setUserTeam(dto.getUserTeam());
entity.setUserRole(dto.getUserRole());
entity.setMemo(dto.getMemo());
entity.setRegUser(regUser);
entity.setRegDt(regDt);
return entity;
}
public void updateFromDto(UserFullDto dto, String modUser, LocalDateTime modDt) {
this.userPw = dto.getUserPw();
this.userName = dto.getUserName();
this.memo = dto.getMemo();
this.modUser = modUser;
this.modDt = modDt;
}
}

View File

@@ -0,0 +1,33 @@
package com.kri.gwcf.review.back.persistence.entity.id;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Embeddable
public class TCodeEntityId implements Serializable {
private static final long serialVersionUID = -9057953927282658386L;
@Size(max = 64)
@NotNull
@Column(name = "code_group", nullable = false, length = 64, updatable = false)
private String codeGroup;
@NotNull
@Column(name = "code_value", nullable = false, updatable = false)
private Integer codeValue;
}

View File

@@ -0,0 +1,33 @@
package com.kri.gwcf.review.back.persistence.entity.id;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Embeddable
public class TPerformanceDetailEntityId implements Serializable {
private static final long serialVersionUID = -1521954237684220097L;
@NotNull
@Column(name = "performance_id", nullable = false, updatable = false)
private Integer performanceId;
@Size(max = 64)
@NotNull
@Column(name = "performance_detail_key", nullable = false, length = 64, updatable = false)
private String performanceDetailKey;
}

View File

@@ -0,0 +1,31 @@
package com.kri.gwcf.review.back.persistence.entity.id;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Embeddable
public class TPerformanceReviewEntityId implements Serializable {
private static final long serialVersionUID = -9155600163233276903L;
@NotNull
@Column(name = "performance_id", nullable = false, updatable = false)
private Integer performanceId;
@NotNull
@Column(name = "review_type", nullable = false, updatable = false)
private Integer reviewType;
}

View File

@@ -0,0 +1,34 @@
package com.kri.gwcf.review.back.persistence.entity.id;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Setter @Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Embeddable
public class TUserDetailEntityId implements Serializable {
private static final long serialVersionUID = -4305521523225680291L;
@Size(max = 32)
@NotNull
@Column(name = "user_id", nullable = false, length = 32, updatable = false)
private String userId;
@Size(max = 64)
@NotNull
@Column(name = "user_detail_key", nullable = false, length = 64, updatable = false)
private String userDetailKey;
}

View File

@@ -0,0 +1,11 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TCodeEntity;
import com.kri.gwcf.review.back.persistence.entity.id.TCodeEntityId;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface CodeRepository extends JpaRepository<TCodeEntity, TCodeEntityId> {
List<TCodeEntity> findByIdCodeGroup(String codeGroup);
}

View File

@@ -0,0 +1,14 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceAssignRepository extends JpaRepository<TPerformanceAssignEntity, Long> {
boolean existsByAssignUser(String assignUser);
boolean existsByPerformanceId(Integer performanceId);
List<TPerformanceAssignEntity> findByPerformanceId(Integer performanceId);
}

View File

@@ -0,0 +1,13 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceDetailEntity;
import com.kri.gwcf.review.back.persistence.entity.id.TPerformanceDetailEntityId;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceDetailRepository extends JpaRepository<TPerformanceDetailEntity, TPerformanceDetailEntityId> {
List<TPerformanceDetailEntity> findByIdPerformanceId(Integer performanceId);
Integer deleteByIdPerformanceId(Integer performanceId);
}

View File

@@ -0,0 +1,12 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceMonitoringScheduleRepository extends JpaRepository<TPerformanceMonitoringScheduleEntity, Long> {
Optional<TPerformanceMonitoringScheduleEntity> findFirstByPerformanceId(Integer performanceId);
Integer deleteByPerformanceId(Integer performanceId);
}

View File

@@ -0,0 +1,14 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringVisitEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceMonitoringVisitRepository extends JpaRepository<TPerformanceMonitoringVisitEntity, Long> {
boolean existsByRegUser(String regUser);
boolean existsByPerformanceId(Integer performanceId);
List<TPerformanceMonitoringVisitEntity> findByPerformanceId(Integer performanceId);
}

View File

@@ -0,0 +1,7 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceRepository extends JpaRepository<TPerformanceEntity, Integer> {
}

View File

@@ -0,0 +1,15 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
import com.kri.gwcf.review.back.persistence.entity.id.TPerformanceReviewEntityId;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceReviewRepository extends JpaRepository<TPerformanceReviewEntity, TPerformanceReviewEntityId> {
boolean existsByRegUserOrModUser(String regUser, String modUser);
boolean existsByIdPerformanceId(Integer performanceId);
List<TPerformanceReviewEntity> findByIdPerformanceId(Integer performanceId);
}

View File

@@ -0,0 +1,12 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceStaffEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PerformanceStaffRepository extends JpaRepository<TPerformanceStaffEntity, Long> {
List<TPerformanceStaffEntity> findByPerformanceId(Integer performanceId);
Integer deleteByPerformanceId(Integer performanceId);
}

View File

@@ -0,0 +1,7 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TSysEventLogEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysEventLogRepository extends JpaRepository<TSysEventLogEntity, Long> {
}

View File

@@ -0,0 +1,14 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TUserDetailEntity;
import com.kri.gwcf.review.back.persistence.entity.id.TUserDetailEntityId;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserDetailRepository extends JpaRepository<TUserDetailEntity, TUserDetailEntityId> {
List<TUserDetailEntity> findByIdUserId(String userId);
Integer deleteByIdUserId(String userId);
}

View File

@@ -0,0 +1,16 @@
package com.kri.gwcf.review.back.persistence.repository;
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepository extends JpaRepository<TUserEntity, String> {
Optional<TUserEntity> findByUserIdAndUserPw(String userId, String userPw);
Optional<TUserEntity> findByUserId(String userId);
boolean existsByUserId(String userId);
Integer deleteByUserId(String userId);
}

View File

@@ -0,0 +1,28 @@
package com.kri.gwcf.review.back.service;
import com.kri.gwcf.review.back.dto.performance.PerformanceAssignDto;
import com.kri.gwcf.review.back.persistence.repository.PerformanceAssignRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class AssignService {
private final PerformanceAssignRepository performanceAssignRepository;
public boolean hasAssignWithUser(String userId) {
return performanceAssignRepository.existsByAssignUser(userId);
}
public boolean hasAssignWithPerformance(Integer performanceId) {
return performanceAssignRepository.existsByPerformanceId(performanceId);
}
public List<PerformanceAssignDto> findByPerformanceId(Integer performanceId) {
return performanceAssignRepository.findByPerformanceId(performanceId).stream()
.map(PerformanceAssignDto::from)
.toList();
}
}

View File

@@ -0,0 +1,34 @@
package com.kri.gwcf.review.back.service;
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
import com.kri.common.feature.auth.jwt.JwtService;
import com.kri.gwcf.review.back.dto.auth.LoginRequestDto;
import com.kri.gwcf.review.back.dto.auth.LoginResponseDto;
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class AuthService {
private final JwtService jwtService;
private final UserService userService;
public LoginResponseDto tryLogin(LoginRequestDto req) {
UserCompactDto user = userService.getUserWithLoginRequest(req);
JwtUserClaimsDto claims = JwtUserClaimsDto.builder()
.userId(user.getUserId())
.userCmpn(user.getUserCmpn())
.userName(user.getUserName())
.userTeam(user.getUserTeam())
.userRole(user.getUserRole())
.build();
String accessToken = jwtService.generateAccessToken(claims);
return LoginResponseDto.from(accessToken, user);
}
}

View File

@@ -0,0 +1,21 @@
package com.kri.gwcf.review.back.service;
import com.kri.gwcf.review.back.dto.common.CodeDto;
import com.kri.gwcf.review.back.persistence.entity.TCodeEntity;
import com.kri.gwcf.review.back.persistence.repository.CodeRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class CodeService {
private final CodeRepository codeRepository;
public List<CodeDto> findByCodeGroup(String codeGroup) {
return codeRepository.findByIdCodeGroup(codeGroup).stream()
.map(CodeDto::from)
.toList();
}
}

View File

@@ -0,0 +1,593 @@
package com.kri.gwcf.review.back.service;
import static com.kri.gwcf.review.back.common.util.AppendCodeSheet.appendCodeSheet;
import static java.util.stream.Collectors.toMap;
import com.kri.common.feature.datetime.DateTimeUtil;
import com.kri.common.feature.excel.ExcelMapper;
import com.kri.common.feature.util.NumericUtil;
import com.kri.common.feature.util.StringUtil;
import com.kri.common.feature.web.BusinessException;
import com.kri.gwcf.review.back.common.util.ExcelUploadResultUtil;
import com.kri.gwcf.review.back.common.util.TelUtil;
import com.kri.gwcf.review.back.dto.common.CodeDto;
import com.kri.gwcf.review.back.dto.excel.ExcelErrorDto;
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
import com.kri.gwcf.review.back.dto.excel.PerformanceUploadDto;
import com.kri.gwcf.review.back.dto.performance.PerformanceCompactDto;
import com.kri.gwcf.review.back.dto.performance.PerformanceFullDto;
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringScheduleDto;
import com.kri.gwcf.review.back.dto.performance.PerformanceStaffDto;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceDetailEntity;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceStaffEntity;
import com.kri.gwcf.review.back.persistence.repository.PerformanceDetailRepository;
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringScheduleRepository;
import com.kri.gwcf.review.back.persistence.repository.PerformanceRepository;
import com.kri.gwcf.review.back.persistence.repository.PerformanceStaffRepository;
import java.io.ByteArrayOutputStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@Service
@RequiredArgsConstructor
public class PerformanceService {
private final PerformanceRepository performanceRepository;
private final PerformanceDetailRepository performanceDetailRepository;
private final PerformanceStaffRepository performanceStaffRepository;
private final PerformanceMonitoringScheduleRepository performanceMonitoringScheduleRepository;
private final CodeService codeService;
private final AssignService assignService;
private final ReviewService reviewService;
private final VisitService visitService;
public PerformanceFullDto getPerformance(Integer performanceId) {
TPerformanceEntity performance = getPerformanceEntity(performanceId);
return toFullDto(performance);
}
public List<PerformanceFullDto> getPerformanceList() {
return performanceRepository.findAll().stream()
.map(this::toFullDto)
.toList();
}
public List<PerformanceCompactDto> getPerformanceCompactList() {
return performanceRepository.findAll().stream()
.map(this::toCompactDto)
.toList();
}
@Transactional
public ExcelUploadResultDto createPerformancesFromExcel(
MultipartFile file,
String regUser,
LocalDateTime regDt
) {
if (file == null || file.isEmpty()) {
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
}
String fileName = file.getOriginalFilename();
String errorFileName = fileName != null && fileName.endsWith(".xlsx")
? fileName.substring(0, fileName.length() - 5) + "_error.xlsx"
: fileName + "_error.xlsx";
List<PerformanceUploadDto> rows;
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
rows = ExcelMapper.readFromWorkbook(workbook, PerformanceUploadDto.class);
} catch (Exception e) {
throw BusinessException.badRequest("INVALID_EXCEL", "엑셀 파일을 읽는 중 오류가 발생했습니다.")
.with("fileName", fileName);
}
List<CodeDto> businessTypeList = codeService.findByCodeGroup("business_type");
List<CodeDto> genreList = codeService.findByCodeGroup("genre");
List<CodeDto> areaList = codeService.findByCodeGroup("area");
List<CodeDto> ticketReservationStatusList =
codeService.findByCodeGroup("ticket_reservation_status");
int totalCount = rows.size();
int successCount = 0;
List<ExcelErrorDto> errorList = new ArrayList<>();
for (int i = 0; i < rows.size(); i++) {
PerformanceUploadDto row = rows.get(i);
int rowNumber = i + 2;
List<ExcelErrorDto> rowErrors = validatePerformanceUploadRow(
row,
rowNumber,
businessTypeList,
genreList,
areaList,
ticketReservationStatusList
);
if (!rowErrors.isEmpty()) {
errorList.addAll(rowErrors);
continue;
}
try {
createPerformanceInternal(row, regUser, regDt);
successCount++;
} catch (BusinessException e) {
errorList.add(ExcelErrorDto.of(rowNumber, "SYSTEM", e.getMessage()));
}
}
int failCount = errorList.stream()
.map(ExcelErrorDto::getRowNumber)
.distinct()
.toList()
.size();
return ExcelUploadResultUtil.buildUploadResult(
totalCount,
successCount,
failCount,
errorList,
ExcelErrorDto.class,
errorFileName
);
}
@Transactional
public void updatePerformance(
PerformanceCompactDto dto,
String modUser,
LocalDateTime modDt
) {
TPerformanceEntity entity = getPerformanceEntity(dto.getId());
entity.updateFromDto(dto, modUser, modDt);
updatePerformanceDetail(dto.getId(), dto.getPerformanceDetail(), modUser, modDt);
updatePerformanceStaff(dto.getId(), dto.getPerformanceStaff(), modUser, modDt);
upsertPerformanceMonitoringSchedule(
dto.getId(),
dto.getPerformanceMonitoringSchedule(),
modUser,
modDt
);
}
@Transactional
public void deletePerformance(Integer performanceId, String delUser) {
TPerformanceEntity performance = getPerformanceEntity(performanceId);
validatePerformanceDeletable(performanceId);
performanceDetailRepository.deleteByIdPerformanceId(performanceId);
performanceStaffRepository.deleteByPerformanceId(performanceId);
performanceMonitoringScheduleRepository.deleteByPerformanceId(performanceId);
performanceRepository.delete(performance);
}
public byte[] exportPerformanceTemplate() {
List<CodeDto> businessTypeList = codeService.findByCodeGroup("business_type");
List<CodeDto> genreList = codeService.findByCodeGroup("genre");
List<CodeDto> areaList = codeService.findByCodeGroup("area");
List<CodeDto> ticketReservationStatusList =
codeService.findByCodeGroup("ticket_reservation_status");
try (Workbook workbook =
ExcelMapper.writeToWorkbook(Collections.emptyList(), PerformanceUploadDto.class);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
appendCodeSheet(workbook, businessTypeList, "사업유형");
appendCodeSheet(workbook, genreList, "장르");
appendCodeSheet(workbook, areaList, "지역");
appendCodeSheet(workbook, ticketReservationStatusList, "티켓 예약");
workbook.write(out);
return out.toByteArray();
} catch (Exception e) {
throw BusinessException.internalError("공연 업로드 템플릿 엑셀 생성 중 오류");
}
}
private PerformanceFullDto toFullDto(TPerformanceEntity performance) {
Integer performanceId = performance.getId();
return PerformanceFullDto.from(
performance,
getPerformanceDetailMap(performanceId),
getPerformanceStaffList(performanceId),
getPerformanceMonitoringSchedule(performanceId),
assignService.findByPerformanceId(performanceId),
visitService.findMapByPerformanceId(performanceId),
reviewService.findMapByPerformanceId(performanceId)
);
}
private PerformanceCompactDto toCompactDto(TPerformanceEntity performance) {
Integer performanceId = performance.getId();
return PerformanceCompactDto.from(
performance,
getPerformanceDetailMap(performanceId),
getPerformanceStaffList(performanceId),
getPerformanceMonitoringSchedule(performanceId)
);
}
private List<ExcelErrorDto> validatePerformanceUploadRow(
PerformanceUploadDto row,
int rowNumber,
List<CodeDto> businessTypeList,
List<CodeDto> genreList,
List<CodeDto> areaList,
List<CodeDto> ticketReservationStatusList
) {
List<ExcelErrorDto> errors = new ArrayList<>();
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
if (performanceId == null) {
errors.add(ExcelErrorDto.of(rowNumber, "연번", "연번은 숫자여야 합니다."));
} else if (performanceRepository.existsById(performanceId)) {
errors.add(ExcelErrorDto.of(rowNumber, "연번", "이미 등록된 공연 ID입니다."));
}
validateCode(errors, rowNumber, "사업유형", row.getBusinessType(), businessTypeList);
validateCode(errors, rowNumber, "분야(장르)", row.getGenre(), genreList);
validateCode(errors, rowNumber, "지역", row.getPerformanceArea(), areaList);
validateCode(
errors,
rowNumber,
"티켓 예약",
row.getTicketReservationStatus(),
ticketReservationStatusList
);
Integer performanceStartMonth = NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth());
if (performanceStartMonth == null || performanceStartMonth < 1 || performanceStartMonth > 12) {
errors.add(ExcelErrorDto.of(rowNumber, "사업 수행 월", "사업 수행 월은 1~12 사이 숫자여야 합니다."));
}
String md = row.getMonitoringDate();
if (DateTimeUtil.parseLocalDate(row.getMonitoringDate()) == null) {
errors.add(ExcelErrorDto.of(rowNumber, "모니터링 일정", "모니터링 일정은 yyyy-MM-dd 형식이어야 합니다."));
}
validateRequired(errors, rowNumber, "단체(인) 명", row.getArtistName());
validateRequired(errors, rowNumber, "사업 명", row.getPerformanceName());
validateRequired(errors, rowNumber, "사업 일정", row.getPerformanceDtInfo());
validateRequired(errors, rowNumber, "운영 시간", row.getPerformanceTimeInfo());
validateRequired(errors, rowNumber, "모니터링 시간", row.getMonitoringTimeInfo());
validateRequired(errors, rowNumber, "모니터링 방문 장소", row.getMonitoringAddress());
validateStaff(errors, rowNumber, "대표자", row.getOwnStaffName(),
row.getOwnStaffTel1(), row.getOwnStaffTel2(), row.getOwnStaffEmail());
validateStaff(errors, rowNumber, "실무자", row.getContactStaffName(),
row.getContactStaffTel1(), row.getContactStaffTel2(), row.getContactStaffEmail());
return errors;
}
private void createPerformanceInternal(
PerformanceUploadDto row,
String regUser,
LocalDateTime regDt
) {
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
TPerformanceEntity performance = TPerformanceEntity.builder()
.id(performanceId)
.businessType(NumericUtil.parseOnlyInteger(row.getBusinessType()))
.performanceGenre(NumericUtil.parseOnlyInteger(row.getGenre()))
.performanceArea(NumericUtil.parseOnlyInteger(row.getPerformanceArea()))
.artistName(Objects.toString(StringUtil.normalizeBlank(row.getArtistName()), ""))
.performanceName(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceName()), ""))
.performanceStartMonth(NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth()))
.performanceDtInfo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceDtInfo()), ""))
.performanceTimeInfo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceTimeInfo()), ""))
.ticketReservationStatus(NumericUtil.parseOnlyInteger(row.getTicketReservationStatus()))
.ticketReservationMemo(Objects.toString(StringUtil.normalizeBlank(row.getTicketReservationMemo()), ""))
.performanceMemo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceMemo()), ""))
.regUser(regUser)
.regDt(regDt)
.build();
performanceRepository.save(performance);
savePerformanceUploadDetail(performanceId, row, regUser, regDt);
savePerformanceUploadStaff(performanceId, row, regUser, regDt);
savePerformanceUploadMonitoringSchedule(performanceId, row, regUser, regDt);
}
private void savePerformanceUploadDetail(
Integer performanceId,
PerformanceUploadDto row,
String regUser,
LocalDateTime regDt
) {
Map<String, String> detail = new LinkedHashMap<>();
detail.put("monitoringPaymentDate", Objects.toString(StringUtil.normalizeBlank(row.getMonitoringPaymentDate()), ""));
List<TPerformanceDetailEntity> detailEntities = detail.entrySet().stream()
.map(entry -> TPerformanceDetailEntity.update(
performanceId,
entry.getKey(),
entry.getValue(),
regUser,
regDt
))
.toList();
performanceDetailRepository.saveAll(detailEntities);
}
private void savePerformanceUploadStaff(
Integer performanceId,
PerformanceUploadDto row,
String regUser,
LocalDateTime regDt
) {
List<TPerformanceStaffEntity> staffEntities = new ArrayList<>();
if (hasAnyText(row.getOwnStaffName(), row.getOwnStaffTel1(), row.getOwnStaffTel2(),
row.getOwnStaffEmail())) {
staffEntities.add(buildPerformanceStaff(
performanceId,
1,
row.getOwnStaffName(),
row.getOwnStaffTel1(),
row.getOwnStaffTel2(),
row.getOwnStaffEmail(),
regUser,
regDt
));
}
if (hasAnyText(row.getContactStaffName(), row.getContactStaffTel1(), row.getContactStaffTel2(),
row.getContactStaffEmail())) {
staffEntities.add(buildPerformanceStaff(
performanceId,
2,
row.getContactStaffName(),
row.getContactStaffTel1(),
row.getContactStaffTel2(),
row.getContactStaffEmail(),
regUser,
regDt
));
}
performanceStaffRepository.saveAll(staffEntities);
}
private TPerformanceStaffEntity buildPerformanceStaff(
Integer performanceId,
Integer staffType,
String staffName,
String staffTel1,
String staffTel2,
String staffEmail,
String regUser,
LocalDateTime regDt
) {
return TPerformanceStaffEntity.builder()
.performanceId(performanceId)
.staffType(staffType)
.staffName(Objects.toString(StringUtil.normalizeBlank(staffName), ""))
.staffTel1(TelUtil.normalizeTel(staffTel1))
.staffTel2(TelUtil.normalizeTel(staffTel2))
.staffEmail(Objects.toString(StringUtil.normalizeBlank(staffEmail), ""))
.regUser(regUser)
.regDt(regDt)
.build();
}
private void savePerformanceUploadMonitoringSchedule(
Integer performanceId,
PerformanceUploadDto row,
String regUser,
LocalDateTime regDt
) {
TPerformanceMonitoringScheduleEntity schedule =
TPerformanceMonitoringScheduleEntity.builder()
.performanceId(performanceId)
.monitoringDate(DateTimeUtil.parseLocalDate(row.getMonitoringDate()))
.monitoringTimeInfo(Objects.toString(StringUtil.normalizeBlank(row.getMonitoringTimeInfo()), ""))
.monitoringAddress(Objects.toString(StringUtil.normalizeBlank(row.getMonitoringAddress()), ""))
.regUser(regUser)
.regDt(regDt)
.build();
performanceMonitoringScheduleRepository.save(schedule);
}
private void validateCode(
List<ExcelErrorDto> errors,
int rowNumber,
String fieldName,
String value,
List<CodeDto> codeList
) {
Integer codeValue = NumericUtil.parseOnlyInteger(value);
if (codeValue == null || codeList.stream().noneMatch(code -> code.getCodeValue().equals(codeValue))) {
errors.add(ExcelErrorDto.of(rowNumber, fieldName, fieldName + " 코드가 유효하지 않습니다."));
}
}
private void validateRequired(
List<ExcelErrorDto> errors,
int rowNumber,
String fieldName,
String value
) {
if (!StringUtil.hasText(value)) {
errors.add(ExcelErrorDto.of(rowNumber, fieldName, fieldName + " 값이 비어 있습니다."));
}
}
private void validateStaff(
List<ExcelErrorDto> errors,
int rowNumber,
String staffLabel,
String staffName,
String staffTel1,
String staffTel2,
String staffEmail
) {
if (!hasAnyText(staffName, staffTel1, staffTel2, staffEmail)) {
return;
}
validateRequired(errors, rowNumber, staffLabel + " 명", staffName);
validateTel(errors, rowNumber, staffLabel + " 연락처1", staffTel1);
validateTel(errors, rowNumber, staffLabel + " 연락처2", staffTel2);
}
private void validateTel(
List<ExcelErrorDto> errors,
int rowNumber,
String fieldName,
String value
) {
if (!StringUtil.hasText(value)) {
return;
}
if (!TelUtil.validateTel(value)) {
errors.add(ExcelErrorDto.of(rowNumber, fieldName, fieldName + " 형식이 올바르지 않습니다."));
}
}
private boolean hasAnyText(String... values) {
return Arrays.stream(values).anyMatch(StringUtil::hasText);
}
private Map<String, String> getPerformanceDetailMap(Integer performanceId) {
return performanceDetailRepository.findByIdPerformanceId(performanceId).stream()
.collect(toMap(
TPerformanceDetailEntity::getPerformanceDetailKey,
TPerformanceDetailEntity::getPerformanceDetailValue
));
}
private List<PerformanceStaffDto> getPerformanceStaffList(Integer performanceId) {
return performanceStaffRepository.findByPerformanceId(performanceId).stream()
.map(PerformanceStaffDto::from)
.toList();
}
private PerformanceMonitoringScheduleDto getPerformanceMonitoringSchedule(Integer performanceId) {
return performanceMonitoringScheduleRepository.findFirstByPerformanceId(performanceId)
.map(PerformanceMonitoringScheduleDto::from)
.orElse(null);
}
private void updatePerformanceDetail(
Integer performanceId,
Map<String, String> performanceDetail,
String modUser,
LocalDateTime modDt
) {
Map<String, String> detail = performanceDetail == null
? Collections.emptyMap()
: performanceDetail;
List<TPerformanceDetailEntity> detailEntities = detail.entrySet().stream()
.map(entry -> TPerformanceDetailEntity.update(
performanceId,
entry.getKey(),
entry.getValue(),
modUser,
modDt
))
.toList();
performanceDetailRepository.saveAll(detailEntities);
}
private void updatePerformanceStaff(
Integer performanceId,
List<PerformanceStaffDto> performanceStaff,
String modUser,
LocalDateTime modDt
) {
performanceStaffRepository.deleteByPerformanceId(performanceId);
if (performanceStaff == null || performanceStaff.isEmpty()) {
return;
}
List<TPerformanceStaffEntity> staffEntities = performanceStaff.stream()
.map(dto -> {
TPerformanceStaffEntity entity = TPerformanceStaffEntity.from(dto);
entity.setId(null);
entity.setPerformanceId(performanceId);
entity.setRegUser(modUser);
entity.setRegDt(modDt);
return entity;
})
.toList();
performanceStaffRepository.saveAll(staffEntities);
}
private void upsertPerformanceMonitoringSchedule(
Integer performanceId,
PerformanceMonitoringScheduleDto dto,
String modUser,
LocalDateTime modDt
) {
if (dto == null) {
return;
}
performanceMonitoringScheduleRepository.findFirstByPerformanceId(performanceId)
.ifPresentOrElse(
entity -> entity.updateFromDto(dto, modUser, modDt),
() -> {
TPerformanceMonitoringScheduleEntity entity =
TPerformanceMonitoringScheduleEntity.from(dto);
entity.setId(null);
entity.setPerformanceId(performanceId);
entity.setRegUser(modUser);
entity.setRegDt(modDt);
performanceMonitoringScheduleRepository.save(entity);
}
);
}
private void validatePerformanceDeletable(Integer performanceId) {
if (assignService.hasAssignWithPerformance(performanceId)) {
throw BusinessException.conflict("PERFORMANCE_HAS_ASSIGN", "배정 정보가 있는 공연은 삭제할 수 없습니다.")
.with("performanceId", performanceId);
}
if (visitService.hasVisitWithPerformance(performanceId)) {
throw BusinessException.conflict("PERFORMANCE_HAS_VISIT", "방문 정보가 있는 공연은 삭제할 수 없습니다.")
.with("performanceId", performanceId);
}
if (reviewService.hasReviewWithPerformance(performanceId)) {
throw BusinessException.conflict("PERFORMANCE_HAS_REVIEW", "평가 결과가 있는 공연은 삭제할 수 없습니다.")
.with("performanceId", performanceId);
}
}
private TPerformanceEntity getPerformanceEntity(Integer performanceId) {
return performanceRepository.findById(performanceId)
.orElseThrow(() ->
BusinessException.notFound("PERFORMANCE_NOT_FOUND", "공연을 찾을 수 없습니다.")
.with("performanceId", performanceId)
);
}
}

View File

@@ -0,0 +1,33 @@
package com.kri.gwcf.review.back.service;
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
import com.kri.gwcf.review.back.persistence.repository.PerformanceReviewRepository;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class ReviewService {
private final PerformanceReviewRepository performanceReviewRepository;
public boolean hasReviewWithUser(String userId) {
return performanceReviewRepository.existsByRegUserOrModUser(userId, userId);
}
public boolean hasReviewWithPerformance(Integer performanceId) {
return performanceReviewRepository.existsByIdPerformanceId(performanceId);
}
public Map<String, List<PerformanceReviewDto>> findMapByPerformanceId(Integer performanceId) {
return performanceReviewRepository.findByIdPerformanceId(performanceId).stream()
.collect(Collectors.groupingBy(
TPerformanceReviewEntity::getRegUser,
Collectors.mapping(PerformanceReviewDto::from, Collectors.toList())
));
}
}

View File

@@ -0,0 +1,519 @@
package com.kri.gwcf.review.back.service;
import static com.kri.gwcf.review.back.common.consts.GwcfConstant.MONITORING_USER_ROLE;
import static com.kri.gwcf.review.back.common.consts.GwcfConstant.SYSTEM_USER_NAME;
import static com.kri.gwcf.review.back.common.util.AppendCodeSheet.appendCodeSheet;
import static java.util.stream.Collectors.toMap;
import com.kri.common.feature.excel.ExcelMapper;
import com.kri.common.feature.util.NumericUtil;
import com.kri.common.feature.util.StringUtil;
import com.kri.common.feature.web.BusinessException;
import com.kri.gwcf.review.back.common.util.ExcelUploadResultUtil;
import com.kri.gwcf.review.back.common.util.TelUtil;
import com.kri.gwcf.review.back.dto.auth.LoginRequestDto;
import com.kri.gwcf.review.back.dto.common.CodeDto;
import com.kri.gwcf.review.back.dto.common.DataVerificationDto;
import com.kri.gwcf.review.back.dto.excel.ExcelErrorDto;
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
import com.kri.gwcf.review.back.dto.excel.MonitoringUserUploadDto;
import com.kri.gwcf.review.back.dto.excel.UserUploadBaseDto;
import com.kri.gwcf.review.back.dto.excel.WrittenUserUploadDto;
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
import com.kri.gwcf.review.back.dto.user.UserFullDto;
import com.kri.gwcf.review.back.persistence.entity.TUserDetailEntity;
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
import com.kri.gwcf.review.back.persistence.repository.UserDetailRepository;
import com.kri.gwcf.review.back.persistence.repository.UserRepository;
import java.io.ByteArrayOutputStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.poi.ss.usermodel.Workbook;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@Service
@RequiredArgsConstructor
public class UserService {
private final UserRepository userRepository;
private final UserDetailRepository userDetailRepository;
private final CodeService codeService;
private final AssignService assignService;
private final ReviewService reviewService;
private final VisitService visitService;
public UserCompactDto getUserWithLoginRequest(LoginRequestDto req){
TUserEntity userEntity = userRepository.findByUserIdAndUserPw(req.getUserId(), req.getUserPw())
.orElseThrow(() ->
BusinessException
.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", req.getUserId())
);
Map<String, String> userDetailMap = userDetailRepository.findByIdUserId(req.getUserId())
.stream()
.collect(toMap(TUserDetailEntity::getUserDetailKey, TUserDetailEntity::getUserDetailValue));
return UserCompactDto.from(userEntity, userDetailMap);
}
public UserFullDto getUser(String userId) {
Map<String, String> userDetail = userDetailRepository.findByIdUserId(userId)
.stream()
.collect(toMap(TUserDetailEntity::getUserDetailKey, TUserDetailEntity::getUserDetailValue));
return UserFullDto.from(getUserEntity(userId), userDetail);
}
public List<UserFullDto> getUserList(Integer userRole) {
validateUserRole(userRole);
Map<String, Map<String, String>> userDetailMap = userDetailRepository.findAll()
.stream()
.collect(Collectors.groupingBy(
TUserDetailEntity::getUserId,
toMap(TUserDetailEntity::getUserDetailKey, TUserDetailEntity::getUserDetailValue)
));
return userRepository.findAll()
.stream()
.filter(user -> Objects.equals(user.getUserRole(), userRole))
.map(user -> UserFullDto.from(
user,
userDetailMap.getOrDefault(user.getUserId(), Collections.emptyMap())
))
.toList();
}
public byte[] exportUserTemplate(Integer userRole) {
validateUserRole(userRole);
return exportUserTemplate(userRole, getUserUploadClass(userRole));
}
private Class<? extends UserUploadBaseDto> getUserUploadClass(Integer userRole) {
if (Objects.equals(userRole, MONITORING_USER_ROLE)) {
return MonitoringUserUploadDto.class;
}
return WrittenUserUploadDto.class;
}
private <T> byte[] exportUserTemplate(Integer userRole, Class<T> clazz) {
List<CodeDto> genreList = codeService.findByCodeGroup("genre");
List<CodeDto> areaList = codeService.findByCodeGroup("area");
List<CodeDto> genderList = codeService.findByCodeGroup("gender");
List<CodeDto> hasCarList = codeService.findByCodeGroup("has_car");
try (Workbook workbook =
ExcelMapper.writeToWorkbook(Collections.emptyList(), clazz);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
if (Objects.equals(userRole, MONITORING_USER_ROLE)) {
appendCodeSheet(workbook, areaList, "지역");
appendCodeSheet(workbook, genderList, "성별");
appendCodeSheet(workbook, hasCarList, "자차유무");
} else {
appendCodeSheet(workbook, genreList, "장르");
}
workbook.write(out);
return out.toByteArray();
} catch (Exception e) {
throw BusinessException.internalError("사용자 업로드 템플릿 엑셀 생성 중 오류");
}
}
private <T extends UserUploadBaseDto> List<T> readUserUploadRows(
Workbook workbook,
Class<T> clazz
) {
return ExcelMapper.readFromWorkbook(workbook, clazz);
}
@Transactional
public ExcelUploadResultDto createUsersFromExcel(Integer userRole, MultipartFile file, String regUser, LocalDateTime regDt) {
if (file == null || file.isEmpty()) {
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
}
String fileName = file.getOriginalFilename();
String errorFileName = fileName != null && fileName.endsWith(".xlsx")
? fileName.substring(0, fileName.length() - 5) + "_error.xlsx"
: fileName + "_error.xlsx";
validateUserRole(userRole);
List<? extends UserUploadBaseDto> rows;
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
// DTO 매핑 (스트리밍 X, 일반 방식)
rows = readUserUploadRows(workbook, getUserUploadClass(userRole));
} catch (Exception e) {
throw BusinessException.badRequest("INVALID_EXCEL", "엑셀 파일을 읽는 중 오류가 발생했습니다.")
.with("fileName", fileName);
}
List<CodeDto> genreList = codeService.findByCodeGroup("genre");
List<CodeDto> areaList = codeService.findByCodeGroup("area");
List<CodeDto> genderList = codeService.findByCodeGroup("gender");
List<CodeDto> hasCarList = codeService.findByCodeGroup("has_car");
int totalCount = rows.size();
int successCount = 0;
List<ExcelErrorDto> errorList = new ArrayList<>();
for (int i = 0; i < rows.size(); i++) {
UserUploadBaseDto uploadDto = rows.get(i);
UserFullDto dto = UserFullDto.from(uploadDto, userRole, List.of("userRoleStr"));
int rowNumber = i + 2; // 엑셀 실제 행 번호 (헤더가 1행일 때)
// 1) 값 검증
List<ExcelErrorDto> rowErrors = validateUserDtoForExcel(
dto,
rowNumber,
userRole,
genreList,
areaList,
genderList,
hasCarList
);
if (!rowErrors.isEmpty()) {
errorList.addAll(rowErrors);
continue; // 이 행은 DB 저장 스킵
}
// 2) 실제 DB 저장
try {
createUserInternal(dto, regUser, regDt);
successCount++;
} catch (BusinessException ex) {
// 시스템/비즈니스 예외도 에러 목록에 추가
errorList.add(
ExcelErrorDto.of(
rowNumber,
SYSTEM_USER_NAME,
ex.getMessage()
)
);
}
}
int failCount = errorList.stream()
.map(ExcelErrorDto::getRowNumber)
.distinct()
.toList()
.size();
return ExcelUploadResultUtil.buildUploadResult(
totalCount,
successCount,
failCount,
errorList,
ExcelErrorDto.class,
errorFileName
);
}
@Transactional
public void updateUser(UserFullDto dto, String modUser, LocalDateTime modDt) {
// dirty checking 업데이트
TUserEntity entity = getUserEntity(dto.getUserId());
Map<String, String> userDetail = dto.getUserDetail() == null
? Collections.emptyMap()
: dto.getUserDetail();
List<TUserDetailEntity> detailEntities = userDetail
.entrySet()
.stream()
.map(entry -> TUserDetailEntity.update(
dto.getUserId(),
entry.getKey(),
entry.getValue(),
modUser,
modDt
))
.toList();
entity.updateFromDto(dto, modUser, modDt);// 기존 엔티티에 적용
userDetailRepository.saveAll(detailEntities);
}
@Transactional
public void deleteUser(String userId, String delUser) {
TUserEntity user = getUserEntity(userId);
validateUserDeletable(userId);
userDetailRepository.deleteByIdUserId(userId);
userRepository.delete(user);
}
private void validateUserDeletable(String userId) {
if (assignService.hasAssignWithUser(userId)) {
throw BusinessException.conflict("USER_HAS_ASSIGN", "배정된 사용자는 삭제할 수 없습니다.")
.with("userId", userId);
}
if (reviewService.hasReviewWithUser(userId)) {
throw BusinessException.conflict("USER_HAS_REVIEW", "평가 결과가 있는 사용자는 삭제할 수 없습니다.")
.with("userId", userId);
}
if (visitService.hasVisitWithUser(userId)) {
throw BusinessException.conflict("USER_HAS_VISIT", "방문 정보가 있는 사용자는 삭제할 수 없습니다.")
.with("userId", userId);
}
}
private TUserEntity getUserEntity(String userId) {
return userRepository.findByUserId(userId)
.orElseThrow(() ->
BusinessException.notFound("USER_NOT_FOUND", "사용자를 찾을 수 없습니다.")
.with("userId", userId)
);
}
private void validateUserRole(Integer userRole) {
List<CodeDto> roleList = codeService.findByCodeGroup("user_role");
if (roleList.stream().noneMatch(role -> role.getCodeValue().equals(userRole))) {
throw BusinessException.badRequest("INVALID_USER_ROLE", "유효하지 않은 사용자 역할입니다.")
.with("userRole", userRole);
}
}
private List<ExcelErrorDto> validateUserDtoForExcel(
UserFullDto dto,
int rowNumber,
Integer userRole,
List<CodeDto> genreList,
List<CodeDto> areaList,
List<CodeDto> genderList,
List<CodeDto> hasCarList
) {
List<ExcelErrorDto> errors = new ArrayList<>();
List<DataVerificationDto> validateUserList = validateUserDto(
dto,
userRole,
genreList,
areaList,
genderList,
hasCarList
);
validateUserList.forEach(validateResult -> {
if (!validateResult.isSuccess()) {
errors.add(ExcelErrorDto.of(
rowNumber,
validateResult.getFieldName(),
validateResult.getErrMessage()
));
}
});
return errors;
}
private List<DataVerificationDto> validateUserDto(
UserFullDto dto,
Integer userRole,
List<CodeDto> genreList,
List<CodeDto> areaList,
List<CodeDto> genderList,
List<CodeDto> hasCarList
) {
List<DataVerificationDto> result = new ArrayList<>();
// 0. userId 기본 검증 (기존 로직)
result.add(this.verifyUserId(dto.getUserId()));
// 1. userPw 비어있는지 / PW 정규식 검사
String userPw = dto.getUserPw();
if (StringUtil.isNullOrBlank(userPw)) {
result.add(new DataVerificationDto(
false,
"사용자 PW",
"비밀번호가 비어 있습니다."
));
} else {
// 4~20자, 허용 문자만 입력 가능
String pwPattern = "^[A-Za-z\\d!@#$%^&*()_+\\-={}\\[\\]:;\"'<>,.?/]{4,20}$";
if (!userPw.matches(pwPattern)) {
result.add(new DataVerificationDto(
false,
"사용자 PW",
"비밀번호는 허용 문자로 4~20자로 입력해야 합니다."
));
}
}
// 2. userName 비어있는지 / 한글·영문 대소문자만 허용
String userName = dto.getUserName();
if (StringUtil.isNullOrBlank(userName)) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름이 비어 있습니다."
));
} else if (!userName.matches("^[가-힣A-Za-z][가-힣A-Za-z0-9_ ()]*$")) {
result.add(new DataVerificationDto(
false,
"사용자 이름",
"사용자 이름은 한글/영문으로 시작해야 하며, 한글/영문/숫자와 공백, '(', ')', '_'만 입력 가능합니다."
));
}
result.add(verifyUserTel(dto));
if (Objects.equals(userRole, MONITORING_USER_ROLE)) {
result.addAll(verifyMonitoringUser(dto, areaList, genderList, hasCarList));
} else {
result.addAll(verifyWrittenUser(dto, genreList));
}
return result;
}
private DataVerificationDto verifyUserId(String userId) {
if (StringUtil.isNullOrBlank(userId)) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID가 비었습니다.");
}
if (!userId.matches("^[a-z가-힣][a-z0-9가-힣]+$")) {
return new DataVerificationDto(false, "사용자 ID", "사용자 ID는 한글, 영소문자, 숫자만 허용합니다.");
}
if (userRepository.existsByUserId(userId)) {
return new DataVerificationDto(false, "사용자 ID", "이미 사용중인 ID입니다.");
}
return new DataVerificationDto();
}
private DataVerificationDto verifyUserTel(UserFullDto userInfo) {
Map<String, String> userDetail = getUserDetail(userInfo);
String userTel = userDetail.get("userTel");
if (!StringUtil.hasText(userTel)) {
return new DataVerificationDto(false, "사용자 연락처", "사용자 연락처가 비어 있습니다.");
}
if (!TelUtil.validateTel(userTel)) {
return new DataVerificationDto(
false,
"사용자 연락처",
"사용자 연락처 형식이 올바르지 않습니다."
);
}
userDetail.put("userTel", TelUtil.normalizeTel(userTel));
return new DataVerificationDto();
}
private List<DataVerificationDto> verifyMonitoringUser(
UserFullDto userInfo,
List<CodeDto> areaList,
List<CodeDto> genderList,
List<CodeDto> hasCarList
) {
List<DataVerificationDto> result = new ArrayList<>();
Map<String, String> userDetail = getUserDetail(userInfo);
String userArea = userDetail.get("userArea");
if (StringUtil.isNullOrBlank(userArea)) {
result.add(new DataVerificationDto(false, "지역", "지역이 비어 있습니다."));
} else if (!existsCodeValue(areaList, userArea)) {
result.add(new DataVerificationDto(false, "지역", "지역 코드가 유효하지 않습니다."));
}
String userGender = userDetail.get("userGender");
if (StringUtil.isNullOrBlank(userGender)) {
result.add(new DataVerificationDto(false, "성별", "성별이 비어 있습니다."));
} else if (!existsCodeValue(genderList, userGender)) {
result.add(new DataVerificationDto(false, "성별", "성별 코드가 유효하지 않습니다."));
}
String userAge = userDetail.get("userAge");
if (StringUtil.isNullOrBlank(userAge)) {
result.add(new DataVerificationDto(false, "연령", "연령이 비어 있습니다."));
} else if (!isIntegerInRange(userAge, 0, 99)) {
result.add(new DataVerificationDto(false, "연령", "연령은 0~99 사이의 숫자여야 합니다."));
}
String userHasCar = userDetail.get("userHasCar");
if (StringUtil.isNullOrBlank(userHasCar)) {
result.add(new DataVerificationDto(false, "자차 유무", "자차 유무가 비어 있습니다."));
} else if (!existsCodeValue(hasCarList, userHasCar)) {
result.add(new DataVerificationDto(false, "자차 유무", "자차 유무 코드가 유효하지 않습니다."));
}
return result;
}
private List<DataVerificationDto> verifyWrittenUser(UserFullDto userInfo, List<CodeDto> genreList) {
List<DataVerificationDto> result = new ArrayList<>();
Map<String, String> userDetail = getUserDetail(userInfo);
String userGenre = userDetail.get("userGenre");
if (StringUtil.isNullOrBlank(userGenre)) {
result.add(new DataVerificationDto(false, "평가위원 장르", "평가위원 장르가 비어 있습니다."));
} else if (!existsCodeValue(genreList, userGenre)) {
result.add(new DataVerificationDto(false, "평가위원 장르", "평가위원 장르 코드가 유효하지 않습니다."));
}
return result;
}
private Map<String, String> getUserDetail(UserFullDto userInfo) {
return userInfo.getUserDetail() == null
? Collections.emptyMap()
: userInfo.getUserDetail();
}
private boolean existsCodeValue(List<CodeDto> codeList, String value) {
Integer codeValue = NumericUtil.parseOnlyInteger(value);
if (codeValue == null || codeList == null) {
return false;
}
return codeList.stream()
.anyMatch(code -> Objects.equals(code.getCodeValue(), codeValue));
}
private boolean isIntegerInRange(String value, int min, int max) {
Integer number = NumericUtil.parseOnlyInteger(value);
return number != null && number >= min && number <= max;
}
private void createUserInternal(UserFullDto userInfo, String regUser, LocalDateTime regDt) {
userInfo.setUserId(userInfo.getUserId().toLowerCase());
userInfo.setUserCmpn("");
userInfo.setUserTeam("");
userInfo.setMemo(Objects.toString(userInfo.getMemo(), ""));
TUserEntity entity = TUserEntity.from(userInfo, regUser, regDt);
Map<String, String> userDetail = userInfo.getUserDetail() == null
? Collections.emptyMap()
: userInfo.getUserDetail();
List<TUserDetailEntity> detailEntities = userDetail
.entrySet()
.stream()
.map(entry -> TUserDetailEntity.create(
userInfo.getUserId(),
entry.getKey(),
entry.getValue(),
regUser,
regDt
))
.toList();
userRepository.save(entity);
userDetailRepository.saveAll(detailEntities);
}
}

View File

@@ -0,0 +1,33 @@
package com.kri.gwcf.review.back.service;
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringVisitDto;
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringVisitEntity;
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringVisitRepository;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class VisitService {
private final PerformanceMonitoringVisitRepository performanceMonitoringVisitRepository;
public boolean hasVisitWithUser(String userId) {
return performanceMonitoringVisitRepository.existsByRegUser(userId);
}
public boolean hasVisitWithPerformance(Integer performanceId) {
return performanceMonitoringVisitRepository.existsByPerformanceId(performanceId);
}
public Map<String, List<PerformanceMonitoringVisitDto>> findMapByPerformanceId(Integer performanceId) {
return performanceMonitoringVisitRepository.findByPerformanceId(performanceId).stream()
.collect(Collectors.groupingBy(
TPerformanceMonitoringVisitEntity::getRegUser,
Collectors.mapping(PerformanceMonitoringVisitDto::from, Collectors.toList())
));
}
}

View File

@@ -0,0 +1,278 @@
package com.kri.gwcf.review.back.service.common;
import static com.kri.common.feature.json.JsonUtil.toMap;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kri.gwcf.review.back.common.enums.SystemEventType;
import com.kri.gwcf.review.back.dto.performance.PerformanceCompactDto;
import com.kri.gwcf.review.back.dto.systemlog.UploadContentDto;
import com.kri.gwcf.review.back.dto.user.UserFullDto;
import com.kri.gwcf.review.back.persistence.entity.TSysEventLogEntity;
import com.kri.gwcf.review.back.persistence.repository.SysEventLogRepository;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class SystemEventLogService {
private final ObjectMapper objectMapper;
private final SysEventLogRepository sysEventLogRepository;
public void writeLoginLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.LOGIN,
"Login",
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeLogoutLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.LOGOUT,
"Logout",
userId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeUploadUserLog(
String regId, LocalDateTime regDt,
String clientIp, UploadContentDto content) {
writeSystemLog(
SystemEventType.UPLOAD_USER,
"Upload User",
regId,
regDt,
clientIp,
content
);
}
public void writeUpdateUserLog(String regId, LocalDateTime regDt, String clientIp,
UserFullDto userInfo) {
writeSystemLog(
SystemEventType.UPDATE_USER,
"Update User",
regId,
regDt,
clientIp,
userInfo
);
}
public void writeDeleteUserLog(String regId, LocalDateTime regDt, String clientIp,
String userId) {
writeSystemLog(
SystemEventType.DELETE_USER,
"Delete User",
regId,
regDt,
clientIp,
"userId",
userId
);
}
public void writeUploadPerformanceLog(String regId, LocalDateTime regDt, String clientIp
, UploadContentDto content) {
writeSystemLog(
SystemEventType.UPLOAD_PERFORMANCE,
"Upload Performance",
regId,
regDt,
clientIp,
content
);
}
public void writeUpdatePerformanceLog(String regId, LocalDateTime regDt, String clientIp
, PerformanceCompactDto dto) {
writeSystemLog(
SystemEventType.UPDATE_PERFORMANCE,
"Update Performance",
regId,
regDt,
clientIp,
dto
);
}
public void writeDeletePerformanceLog(String regId, LocalDateTime regDt, String clientIp, Integer performanceId) {
writeSystemLog(
SystemEventType.DELETE_USER,
"Delete User",
regId,
regDt,
clientIp,
"performanceId",
performanceId
);
}
public void writeAssignConfirmLog(String userId, LocalDateTime regDt, String clientIp) {
writeSystemLog(
SystemEventType.ASSIGN_PERFORMANCE_CONFIRM,
"Assign Confirm",
userId,
regDt,
clientIp,
"userId",
userId
);
}
/*
public void writeCreateUserLog(String regId, LocalDateTime regDt, String clientIp,
UserInfoDto userInfo) {
writeSystemLog(SystemEventType.CREATE_USER, "Create User", null, regId, regDt, clientIp,
userInfo);
}
public void writeCreateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx,
ProjectCreateRequestDto req) {
writeSystemLog(SystemEventType.CREATE_PROJECT, "Create Project", prjctIdx, regId, regDt,
clientIp, req);
}
public void writeUpdateProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx,
ProjectUpdateRequestDto req) {
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt,
clientIp, req);
}
public void writeUpdateDefaultMessageTemplate(String regId, LocalDateTime regDt, String clientIp,
ProjectMainTemplateUpdateRequestDto req) {
writeSystemLog(SystemEventType.UPDATE_PROJECT_DEFAULT_TEMPLATE,
"Update Project Default Message Template", req.getPrjctIdx(), regId, regDt, clientIp, req);
}
public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx) {
writeSystemLog(
SystemEventType.DELETE_PROJECT,
"Delete Project",
prjctIdx,
regId,
regDt,
clientIp,
"prjctIdx",
prjctIdx
);
}
public void writeAssignUserProject(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx, List<String> assignUserIdList) {
writeSystemLog(
SystemEventType.ASSIGN_PROJECT_USER,
"Assign Project FW User",
prjctIdx,
regId,
regDt,
clientIp,
"assignUserIdList",
assignUserIdList
);
}
public void writeUpsertListHeader(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx, List<ListHeaderDto> headerList) {
writeSystemLog(
SystemEventType.UPSERT_LIST_HEADER,
"Upsert List Header",
prjctIdx,
regId,
regDt,
clientIp,
"headerList",
headerList
);
}
public void writeUploadList(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx, String uploadFileName){
writeSystemLog(
SystemEventType.UPLOAD_LIST,
"Upload List",
prjctIdx,
regId,
regDt,
clientIp,
"uploadFileName",
uploadFileName
);
}
public void writeUpdateList(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx, ListUpdateRequestDto req){
writeSystemLog(SystemEventType.UPDATE_LIST,
"Update List Info", prjctIdx, regId, regDt, clientIp, req);
}
public void writeUploadListItemFiles(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx,Map<String, String> fileNames){
writeSystemLog(SystemEventType.UPLOAD_LIST_ITEM_FILE,
"Upload List Item File", prjctIdx, regId, regDt, clientIp, fileNames);
}
public void writeResetList(String regId, LocalDateTime regDt, String clientIp,
Long prjctIdx, ListResetRequestDto req){
writeSystemLog(SystemEventType.RESET_LIST,
"Reset List", prjctIdx, regId, regDt, clientIp, req);
}
*/
protected <T> void writeSystemLog(
SystemEventType eventType,
String title,
String regId,
LocalDateTime regDt,
String clientIp,
T content
) {
Map<String, Object> contentMap = toMap(objectMapper, content);
saveLog(eventType, title, regId, regDt, clientIp, contentMap);
}
protected <T> void writeSystemLog(
SystemEventType eventType,
String title,
String regId,
LocalDateTime regDt,
String clientIp,
String contentKey,
T content
) {
Map<String, Object> contentMap = Map.of(contentKey, content);
saveLog(eventType, title, regId, regDt, clientIp, contentMap);
}
private void saveLog(
SystemEventType eventType,
String title,
String regId,
LocalDateTime regDt,
String clientIp,
Map<String, Object> contentMap
) {
TSysEventLogEntity log = TSysEventLogEntity.of(
eventType,
title,
contentMap,
clientIp,
regId,
regDt
);
sysEventLogRepository.save(log);
}
}

View File

@@ -0,0 +1,133 @@
package com.kri.gwcf.review.back.service.file;
import com.kri.common.feature.datetime.DateTimeUtil;
import com.kri.common.feature.util.CommonUtil;
import com.kri.common.feature.util.StringUtil;
import com.kri.common.feature.web.BusinessException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Optional;
import org.springframework.web.multipart.MultipartFile;
public abstract class AbstractFileService {
protected abstract Path getBaseDir();
protected String extractExtension(String originalFileName) {
if (StringUtil.isNullOrBlank(originalFileName)) {
return "";
}
int dot = originalFileName.lastIndexOf('.');
if (dot > -1 && dot < originalFileName.length() - 1) {
return originalFileName.substring(dot);
}
return "";
}
protected String extractBaseName(String originalFileName) {
if (StringUtil.isNullOrBlank(originalFileName)) {
return "file";
}
String fileName = java.nio.file.Paths.get(originalFileName).getFileName().toString();
int dot = fileName.lastIndexOf('.');
if (dot > 0) {
return fileName.substring(0, dot);
}
return fileName;
}
protected String buildFileName(MultipartFile file) {
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
return CommonUtil.uuid32() + extractExtension(original);
}
protected String buildFileNameWithTime(MultipartFile file, String prefix) {
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
String baseName = extractBaseName(original);
String ext = extractExtension(original);
String timestamp = DateTimeUtil.nowKstLocalDateTime()
.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
return prefix + "_" + timestamp + "_" + baseName + ext;
}
protected Path createDirectories(Path dir) throws IOException {
return Files.createDirectories(dir.toAbsolutePath().normalize());
}
protected String saveFile(Path dir, MultipartFile file) throws IOException {
if (file == null || file.isEmpty()) {
throw BusinessException.forbidden("EMPTY_FILE","업로드할 파일이 없습니다.");
}
Path normalizedDir = createDirectories(dir);
String fileName = buildFileName(file);
Path target = normalizedDir.resolve(fileName).normalize();
if (!target.startsWith(normalizedDir)) {
throw new IllegalStateException("잘못된 파일 경로입니다.");
}
file.transferTo(target.toFile());
return fileName;
}
protected void saveFile(Path dir, MultipartFile file, String fileName) throws IOException {
if (file == null || file.isEmpty()) {
throw BusinessException.forbidden("EMPTY_FILE","업로드할 파일이 없습니다.");
}
Path normalizedDir = createDirectories(dir);
Path target = normalizedDir.resolve(fileName).normalize();
if (!target.startsWith(normalizedDir)) {
throw BusinessException.internalError("WRONG_DIRECTORY","잘못된 파일 경로입니다.");
}
file.transferTo(target.toFile());
}
protected void moveFile(Path sourceDir, Path targetDir, String fileName) throws IOException {
if (StringUtil.isNullOrBlank(fileName)) {
return;
}
Path normalizedSourceDir = sourceDir.toAbsolutePath().normalize();
Path normalizedTargetDir = createDirectories(targetDir);
Path source = normalizedSourceDir.resolve(fileName).normalize();
Path target = normalizedTargetDir.resolve(fileName).normalize();
if (!source.startsWith(normalizedSourceDir) || !target.startsWith(normalizedTargetDir)) {
throw new IllegalStateException("잘못된 파일 경로입니다.");
}
if (!Files.exists(source)) {
return;
}
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
}
protected void deleteFile(Path dir, String fileName) throws IOException {
if (StringUtil.isNullOrBlank(fileName)) {
return;
}
Path normalizedDir = dir.toAbsolutePath().normalize();
Path target = normalizedDir.resolve(fileName).normalize();
if (!target.startsWith(normalizedDir)) {
throw new IllegalStateException("잘못된 파일 경로입니다.");
}
Files.deleteIfExists(target);
}
}

View File

@@ -0,0 +1,7 @@
spring:
datasource:
#private 도메인
url: jdbc:mysql://db-md87m.vpc-cdb.ntruss.com:3306/test_gwcf_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
username: prjct_gwcf
password: gwcf#260608
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@@ -0,0 +1,25 @@
spring:
datasource:
#public 도메인
url: jdbc:mysql://db-md87m-kr.vpc-pub-cdb.ntruss.com:3306/test_gwcf_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
username: prjct_gwcf
password: gwcf#260608
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: none # 필요에 따라 update / validate 등으로 변경
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
format_sql: true
show_sql: false
generate_statistics: true
open-in-view: false
logging:
level:
org.hibernate.SQL: DEBUG
#org.hibernate.orm.jdbc.bind: TRACE
#org.hibernate.orm.jdbc.extract: TRACE
org.hibernate.engine.jdbc.batch.internal: DEBUG

View File

@@ -0,0 +1,7 @@
spring:
datasource:
#private 도메인
url: jdbc:mysql://db-md87m.vpc-cdb.ntruss.com:3306/prjct_gwcf_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
username: prjct_gwcf
password: gwcf#260608
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@@ -0,0 +1,76 @@
server:
port: 6105
forward-headers-strategy: framework
tomcat:
max-http-form-post-size: 100MB
max-swallow-size: -1
spring:
application:
name: gwcf-review-back
jpa:
properties:
hibernate:
jdbc:
batch_size: 1000
order_inserts: true
order_updates: true
profiles:
# 아무 설정 없을 때 기본으로 쓸 프로파일
default: local
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
logging:
file:
path: ./logs
kon:
datasource:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://1.235.195.8:20022;databaseName=KON;encrypt=false;loginTimeout=5
username: kon
password: kon#51304
mybatis:
mapper-locations: classpath*:mybatis/mapper/kon/*.xml
type-aliases-package: com.kri.gwcf.review.back.dto.kon
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
kri:
security:
enabled: true
public-paths: # 인증 없이 열어둘 URL
- /v3/api-docs/**
- /swagger-ui.html
- /swagger-ui/**
- /ping
- /api/v1/auth/login
- /api/v1/admin-cache/**
- /api/v1/assign/confirm/*
- /api/v1/performance/list/compact
swagger:
enabled: true
allowed-ips:
- 211.254.145.130
title: "GWCF Review"
description: "강원문화예술지원사업 모니터링 및 종합평가 서버스"
version: "v1.0.0"
base-package: "com.kri.gwcf.review.back"
file:
visit-base-dir: ./upload-file/visit
review-base-dir: ./upload-file/review
web:
enabled: true # 공통 Web 구성 사용 여부 (기본 true)
redis:
enabled: false # RedisQueueHelper 사용 시 true
scheduling:
enabled: false # @Scheduled 사용 시 true