260908_01_fst: First Commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.kri.kmusical.manage.back;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ConfigurationPropertiesScan
|
||||
public class KMusicalManageBackApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(KMusicalManageBackApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.kri.kmusical.manage.back.common.consts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class KmusicalConstant {
|
||||
public static final String SYSTEM_USER_NAME = "SYSTEM";
|
||||
public static final Integer MONITORING_USER_ROLE = 9003;
|
||||
public static final Integer MONITORING_REVIEW_TYPE = 1;
|
||||
public static final Integer CONSULTING_REVIEW_TYPE = 2;
|
||||
public static final List<Integer> REVIEW_TYPE = List.of(
|
||||
MONITORING_REVIEW_TYPE,
|
||||
CONSULTING_REVIEW_TYPE
|
||||
);
|
||||
public static final Integer COMPLETE_STATUS = 10;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.kri.kmusical.manage.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_CANCEL((short) 1033), //공연 배정 거절
|
||||
ASSIGN_PERFORMANCE_FORCE((short) 1034), //강제 공연 배정
|
||||
ASSIGN_PERFORMANCE_REJECT((short) 1039), //공연 배정 거절
|
||||
|
||||
VISIT_START((short) 2011), //모니터링 출발
|
||||
VISIT_END((short) 2012), //모니터링 도착
|
||||
VISIT_RESET((short) 2099), //모니터링 출발.도착 초기화
|
||||
|
||||
UPLOAD_REVIEW((short) 2041), //평가 결과 파일 업로드
|
||||
START_REVIEW((short) 2044), //평가 시작
|
||||
|
||||
DUMMY((short) 9999);
|
||||
|
||||
private final Short code;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.kri.kmusical.manage.back.common.util;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelMapper;
|
||||
import com.kri.kmusical.manage.back.dto.common.CodeDto;
|
||||
import com.kri.kmusical.manage.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.kri.kmusical.manage.back.common.util;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
public final class DownloadHeaderUtil {
|
||||
|
||||
public static String attachmentContentDisposition(String fileName) {
|
||||
return "attachment; filename*=UTF-8''" +
|
||||
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.kri.kmusical.manage.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.kri.kmusical.manage.back.common.util;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelMapper;
|
||||
import com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.kri.kmusical.manage.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kmusical.manage.back.common.util;
|
||||
|
||||
public final class StringNormalizer {
|
||||
|
||||
private StringNormalizer() {
|
||||
}
|
||||
|
||||
public static String trimToNull(String value) {
|
||||
if (value == null) return null;
|
||||
String normalized = value.trim();
|
||||
return normalized.isEmpty() ? null : normalized;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.kri.kmusical.manage.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 프로젝트 전용 Bean Validation annotation과 validator를 배치합니다.
|
||||
*/
|
||||
package com.kri.kmusical.manage.back.common.validation;
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.kri.kmusical.manage.back.config;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class AsyncConfig {
|
||||
|
||||
@Bean(name = "pdfConvertTaskExecutor")
|
||||
public Executor pdfConvertTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(1);
|
||||
executor.setMaxPoolSize(1);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setThreadNamePrefix("pdf-convert-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.kri.kmusical.manage.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.kmusical.manage.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.kmusical.manage.back.persistence.entity")
|
||||
.persistenceUnit("main")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean(name = "mainTransactionManager")
|
||||
@Primary
|
||||
public PlatformTransactionManager mainTransactionManager(
|
||||
@Qualifier("mainEntityManagerFactory")
|
||||
LocalContainerEntityManagerFactoryBean entityManagerFactory
|
||||
) {
|
||||
return new JpaTransactionManager(entityManagerFactory.getObject());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kmusical.manage.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 reviewBaseDir;
|
||||
private String reviewTemplateBaseDir;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.kri.kmusical.manage.back.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
@Configuration
|
||||
public class JdbcConfig {
|
||||
|
||||
@Bean
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
|
||||
return new JdbcTemplate(dataSource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.kri.kmusical.manage.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.kmusical.manage.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.kri.kmusical.manage.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.kri.kmusical.manage.back.config;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.review-base-dir}")
|
||||
private String reviewBaseDir;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// /review-file/** → /data/upload-file/review/** 매핑
|
||||
registry.addResourceHandler("/review-file/**")
|
||||
.addResourceLocations("file:" + reviewBaseDir + "/");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.kri.kmusical.manage.back.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kmusical.manage.back.dto.assign.AssignUserCountDto;
|
||||
import com.kri.kmusical.manage.back.dto.assign.MonitoringApplyUserDto;
|
||||
import com.kri.kmusical.manage.back.dto.assign.PerformanceAssignSaveRequestDto;
|
||||
import com.kri.kmusical.manage.back.dto.kon.PerformanceApplyCountDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceAssignDto;
|
||||
import com.kri.kmusical.manage.back.service.AssignService;
|
||||
import com.kri.kmusical.manage.back.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.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/assign")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Assign", description = "배정 API")
|
||||
public class AssignController {
|
||||
|
||||
private final AssignService assignService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "사용자별 확정 건수 조회")
|
||||
@GetMapping("/users/count")
|
||||
public List<AssignUserCountDto> findAssignUserCounts() {
|
||||
return assignService.findAssignUserCounts();
|
||||
}
|
||||
|
||||
@Operation(summary = "공연별 모니터링 신청자 목록 조회")
|
||||
@GetMapping("/monitoring/apply-users/{performanceId}")
|
||||
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(
|
||||
@PathVariable String performanceId
|
||||
) {
|
||||
return assignService.findMonitoringApplyUsers(performanceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "공연별 모니터링 신청자 수 조회")
|
||||
@GetMapping("/monitoring/apply-users/count")
|
||||
public List<PerformanceApplyCountDto> findMonitoringApplyUsersCount() {
|
||||
return assignService.findMonitoringApplyUsersCount();
|
||||
}
|
||||
|
||||
@Operation(summary = "평가 슬롯 담당자 확정 또는 교체")
|
||||
@PostMapping
|
||||
public PerformanceAssignDto confirmAssign(
|
||||
@RequestBody PerformanceAssignSaveRequestDto dto,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
PerformanceAssignDto result = assignService.confirmAssign(
|
||||
dto.getPerformanceId(),
|
||||
dto.getReviewSlot(),
|
||||
dto.getUserId(),
|
||||
ctx.getUserId(),
|
||||
now
|
||||
);
|
||||
systemEventLogService.writeAssignConfirmByAdminLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
dto.getPerformanceId(),
|
||||
dto.getReviewSlot(),
|
||||
dto.getUserId()
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "평가 슬롯 담당자 확정 취소")
|
||||
@DeleteMapping("/{performanceId}/{reviewSlot}")
|
||||
public void cancelAssign(
|
||||
@PathVariable String performanceId,
|
||||
@PathVariable Integer reviewSlot,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
PerformanceAssignDto assign = assignService.findByPerformanceId(performanceId).stream()
|
||||
.filter(item -> reviewSlot.equals(item.getReviewSlot()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
assignService.cancelAssign(performanceId, reviewSlot);
|
||||
if (assign != null) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
systemEventLogService.writeAssignCancelLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
reviewSlot,
|
||||
assign.getAssignUser()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.kri.kmusical.manage.back.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kmusical.manage.back.dto.auth.LoginRequestDto;
|
||||
import com.kri.kmusical.manage.back.dto.auth.LoginResponseDto;
|
||||
import com.kri.kmusical.manage.back.service.AuthService;
|
||||
import com.kri.kmusical.manage.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.kri.kmusical.manage.back.controller;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.common.CodeDto;
|
||||
import com.kri.kmusical.manage.back.service.CodeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/code")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Code", description = "코드 API")
|
||||
public class CodeController {
|
||||
|
||||
private final CodeService codeService;
|
||||
|
||||
@Operation(summary = "코드 조회")
|
||||
@GetMapping("/{codeGroup}")
|
||||
public List<CodeDto> getCodeList(@PathVariable String codeGroup) {
|
||||
return codeService.findByCodeGroup(codeGroup);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.kri.kmusical.manage.back.controller;
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kmusical.manage.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceCompactDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceFullDto;
|
||||
import com.kri.kmusical.manage.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.kmusical.manage.back.service.PerformanceService;
|
||||
import com.kri.kmusical.manage.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 String 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 = "공연정보 엑셀 다운로드")
|
||||
@PostMapping("/excel/download")
|
||||
public ResponseEntity<byte[]> exportPerformance(
|
||||
@RequestBody String[] performanceIds
|
||||
) {
|
||||
byte[] bytes = performanceService.exportPerformance(performanceIds);
|
||||
|
||||
return buildExcelResponse("performance.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, regId));
|
||||
|
||||
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 String performanceId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String delId = ctx.getUserId();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
performanceService.deletePerformance(performanceId, delId);
|
||||
systemEventLogService.writeDeletePerformanceLog(delId, now, ctx.getClientIp(), performanceId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.kri.kmusical.manage.back.controller;
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.util.DownloadHeaderUtil.attachmentContentDisposition;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.kmusical.manage.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.kmusical.manage.back.service.ReviewService;
|
||||
import com.kri.kmusical.manage.back.service.ReviewTemplateService;
|
||||
import com.kri.kmusical.manage.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.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/review")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Review", description = "평가 API")
|
||||
public class ReviewController {
|
||||
|
||||
private final ReviewService reviewService;
|
||||
private final ReviewTemplateService reviewTemplateService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "평가 파일 업로드")
|
||||
@PostMapping(value = "/{performanceId}/{reviewSlot}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public PerformanceReviewDto uploadReviewFile(
|
||||
@PathVariable String performanceId,
|
||||
@PathVariable Integer reviewSlot,
|
||||
@RequestParam(required = false) String paramUserId,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
String userId = paramUserId != null ? paramUserId : ctx.getUserId();
|
||||
|
||||
PerformanceReviewDto result = reviewService.uploadReviewFile(performanceId, reviewSlot, file, userId, now);
|
||||
systemEventLogService.writeUploadReviewFileLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
reviewSlot,
|
||||
UploadContentDto.from(file, userId)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "평가 파일 조회")
|
||||
@GetMapping("/{performanceId}/{reviewSlot}")
|
||||
public PerformanceReviewDto getReviewFile(
|
||||
@PathVariable String performanceId,
|
||||
@PathVariable Integer reviewSlot
|
||||
) {
|
||||
return reviewService.getReviewFile(performanceId, reviewSlot);
|
||||
}
|
||||
|
||||
@Operation(summary = "평가 원본 파일 다운로드")
|
||||
@GetMapping("/download/{performanceId}/{reviewSlot}")
|
||||
public ResponseEntity<Resource> downloadOriginalFile(
|
||||
@PathVariable String performanceId,
|
||||
@PathVariable Integer reviewSlot
|
||||
) {
|
||||
return download(reviewService.getOriginalFileResource(performanceId, reviewSlot));
|
||||
}
|
||||
|
||||
@Operation(summary = "PDF 변환 파일 조회/다운로드")
|
||||
@GetMapping("/pdf/{performanceId}/{reviewSlot}")
|
||||
public ResponseEntity<Resource> downloadPdfOrOriginalFile(
|
||||
@PathVariable String performanceId,
|
||||
@PathVariable Integer reviewSlot
|
||||
) {
|
||||
return download(reviewService.getPdfOrOriginalFileResource(performanceId, reviewSlot));
|
||||
}
|
||||
|
||||
@Operation(summary = "평가양식 업로드")
|
||||
@PostMapping(value = "/template/upload/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public String uploadReviewTemplate(
|
||||
@PathVariable Integer reviewType,
|
||||
@RequestParam("file") MultipartFile file
|
||||
) {
|
||||
return reviewTemplateService.uploadReviewTemplate(reviewType, file);
|
||||
}
|
||||
|
||||
@Operation(summary = "평가양식 다운로드")
|
||||
@GetMapping("/template/download/{reviewType}")
|
||||
public ResponseEntity<Resource> downloadReviewTemplate(
|
||||
@PathVariable Integer reviewType
|
||||
) {
|
||||
return download(reviewTemplateService.getReviewTemplateResource(reviewType));
|
||||
}
|
||||
|
||||
@Operation(summary = "평가양식 pdf 다운로드")
|
||||
@GetMapping("/template/pdf/{reviewType}")
|
||||
public ResponseEntity<Resource> downloadReviewPdfTemplate(
|
||||
@PathVariable Integer reviewType
|
||||
) {
|
||||
return download(reviewTemplateService.getReviewTemplatePdfResource(reviewType));
|
||||
}
|
||||
|
||||
private ResponseEntity<Resource> download(Resource resource) {
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, attachmentContentDisposition(resource.getFilename()))
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(resource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.kri.kmusical.manage.back.controller;
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kmusical.manage.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.kmusical.manage.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.kmusical.manage.back.dto.user.UserFullDto;
|
||||
import com.kri.kmusical.manage.back.service.UserService;
|
||||
import com.kri.kmusical.manage.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 = "사용자 엑셀 다운로드")
|
||||
@PostMapping("/excel/download/{userRole}")
|
||||
public ResponseEntity<byte[]> exportUser(
|
||||
@PathVariable Integer userRole,
|
||||
@RequestBody String[] userIds
|
||||
) {
|
||||
byte[] bytes = userService.exportUser(userRole, userIds);
|
||||
|
||||
return buildExcelResponse("user.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, regId));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.kri.kmusical.manage.back.dto.assign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AssignUserCountDto {
|
||||
|
||||
@Schema(description = "배정 사용자 ID")
|
||||
private String assignUser;
|
||||
|
||||
@Schema(description = "배정 건수")
|
||||
private Long assignCount;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.kri.kmusical.manage.back.dto.assign;
|
||||
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.user.UserCompactDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
@Schema(description = "모니터링 신청자")
|
||||
public class MonitoringApplyUserDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "신청자 ID")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "서비스 DB 사용자 정보")
|
||||
private UserCompactDto user;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.kri.kmusical.manage.back.dto.assign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PerformanceAssignSaveRequestDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "평가 슬롯")
|
||||
private Integer reviewSlot;
|
||||
|
||||
@Schema(description = "확정할 사용자 ID")
|
||||
private String userId;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.kmusical.manage.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;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.kri.kmusical.manage.back.dto.auth;
|
||||
|
||||
import com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.kri.kmusical.manage.back.dto.common;
|
||||
|
||||
import com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.kri.kmusical.manage.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 = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.kri.kmusical.manage.back.dto.excel;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kri.kmusical.manage.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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.kri.kmusical.manage.back.dto.excel.performance;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceDownloadDto extends PerformanceUploadDto {
|
||||
|
||||
@ExcelColumn(header = "모니터링1 평가자", order = 29, width = 16)
|
||||
@Schema(description = "모니터링1 평가자")
|
||||
private String monitoringReviewUser1;
|
||||
|
||||
@ExcelColumn(header = "모니터링1 평가 상태", order = 30, width = 16)
|
||||
@Schema(description = "모니터링1 평가 상태")
|
||||
private String monitoringReviewStatus1;
|
||||
|
||||
@ExcelColumn(header = "모니터링1 평가 일시", order = 31, width = 16)
|
||||
@Schema(description = "모니터링1 평가 일시")
|
||||
private String monitoringReviewDt1;
|
||||
|
||||
@ExcelColumn(header = "모니터링2 평가자", order = 32, width = 16)
|
||||
@Schema(description = "모니터링2 평가자")
|
||||
private String monitoringReviewUser2;
|
||||
|
||||
@ExcelColumn(header = "모니터링2 평가 상태", order = 33, width = 16)
|
||||
@Schema(description = "모니터링2 평가 상태")
|
||||
private String monitoringReviewStatus2;
|
||||
|
||||
@ExcelColumn(header = "모니터링2 평가 일시", order = 34, width = 16)
|
||||
@Schema(description = "모니터링2 평가 일시")
|
||||
private String monitoringReviewDt2;
|
||||
|
||||
@ExcelColumn(header = "모니터링3 평가자", order = 35, width = 16)
|
||||
@Schema(description = "모니터링3 평가자")
|
||||
private String monitoringReviewUser3;
|
||||
|
||||
@ExcelColumn(header = "모니터링3 평가 상태", order = 36, width = 16)
|
||||
@Schema(description = "모니터링3 평가 상태")
|
||||
private String monitoringReviewStatus3;
|
||||
|
||||
@ExcelColumn(header = "모니터링3 평가 일시", order = 37, width = 16)
|
||||
@Schema(description = "모니터링3 평가 일시")
|
||||
private String monitoringReviewDt3;
|
||||
|
||||
@ExcelColumn(header = "컨설팅1 평가자", order = 38, width = 16)
|
||||
@Schema(description = "컨설팅1 평가자")
|
||||
private String consultingReviewUser1;
|
||||
|
||||
@ExcelColumn(header = "컨설팅1 평가 상태", order = 39, width = 16)
|
||||
@Schema(description = "컨설팅1 평가 상태")
|
||||
private String consultingReviewStatus1;
|
||||
|
||||
@ExcelColumn(header = "컨설팅1 평가 일시", order = 40, width = 16)
|
||||
@Schema(description = "컨설팅1 평가 일시")
|
||||
private String consultingReviewDt1;
|
||||
|
||||
@ExcelColumn(header = "컨설팅2 평가자", order = 41, width = 16)
|
||||
@Schema(description = "컨설팅2 평가자")
|
||||
private String consultingReviewUser2;
|
||||
|
||||
@ExcelColumn(header = "컨설팅2 평가 상태", order = 42, width = 16)
|
||||
@Schema(description = "컨설팅2 평가 상태")
|
||||
private String consultingReviewStatus2;
|
||||
|
||||
@ExcelColumn(header = "컨설팅2 평가 일시", order = 43, width = 16)
|
||||
@Schema(description = "컨설팅2 평가 일시")
|
||||
private String consultingReviewDt2;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.kri.kmusical.manage.back.dto.excel.performance;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceUploadDto {
|
||||
|
||||
@ExcelColumn(header = "NO", order = 0, width = 10)
|
||||
@Schema(description = "NO")
|
||||
private String performanceNo;
|
||||
|
||||
@ExcelColumn(header = "연번", order = 1, width = 10)
|
||||
@Schema(description = "연번")
|
||||
private String performanceId;
|
||||
|
||||
@ExcelColumn(header = "사업유형", order = 2, width = 10)
|
||||
@Schema(description = "사업유형")
|
||||
private String businessType;
|
||||
|
||||
@ExcelColumn(header = "지역", order = 3, width = 10)
|
||||
@Schema(description = "지역")
|
||||
private String performanceArea;
|
||||
|
||||
@ExcelColumn(header = "지역 세부", order = 4, width = 10)
|
||||
@Schema(description = "지역 세부")
|
||||
private String performanceAreaDetail;
|
||||
|
||||
@ExcelColumn(header = "단체명", order = 5, width = 11)
|
||||
@Schema(description = "단체명")
|
||||
private String artistName;
|
||||
|
||||
@ExcelColumn(header = "작품명", order = 6, width = 10)
|
||||
@Schema(description = "작품명")
|
||||
private String performanceName;
|
||||
|
||||
@ExcelColumn(header = "사업 수행 월", order = 7, width = 12)
|
||||
@Schema(description = "사업 수행 월")
|
||||
private String performanceStartMonth;
|
||||
|
||||
@ExcelColumn(header = "사업 일정", order = 8, width = 10)
|
||||
@Schema(description = "사업 일정")
|
||||
private String performanceDtInfo;
|
||||
|
||||
@ExcelColumn(header = "운영 시간", order = 9, width = 10)
|
||||
@Schema(description = "운영 시간")
|
||||
private String performanceTimeInfo;
|
||||
|
||||
@ExcelColumn(header = "티켓 예약", order = 10, width = 10)
|
||||
@Schema(description = "티켓 예약")
|
||||
private String ticketReservationStatus;
|
||||
|
||||
@ExcelColumn(header = "티켓 비고", order = 11, width = 10)
|
||||
@Schema(description = "티켓 비고")
|
||||
private String ticketReservationMemo;
|
||||
|
||||
@ExcelColumn(header = "모니터링 일정", order = 12, width = 14)
|
||||
@Schema(description = "모니터링 일정")
|
||||
private String monitoringDate;
|
||||
|
||||
@ExcelColumn(header = "모니터링 시간", order = 13, width = 14)
|
||||
@Schema(description = "모니터링 시간")
|
||||
private String monitoringTimeInfo;
|
||||
|
||||
@ExcelColumn(header = "모니터링 방문장소", order = 14, width = 14)
|
||||
@Schema(description = "모니터링 방문장소")
|
||||
private String monitoringAddress;
|
||||
|
||||
@ExcelColumn(header = "컨설팅 진행여부", order = 15, width = 14)
|
||||
@Schema(description = "컨설팅 진행여부")
|
||||
private String consultingStatus;
|
||||
|
||||
@ExcelColumn(header = "교부여부", order = 16, width = 14)
|
||||
@Schema(description = "교부여부")
|
||||
private String checkDeliver;
|
||||
|
||||
@ExcelColumn(header = "메모", order = 17, width = 10)
|
||||
@Schema(description = "메모")
|
||||
private String performanceMemo;
|
||||
|
||||
@ExcelColumn(header = "보고서 확인여부", order = 18, width = 10)
|
||||
@Schema(description = "보고서 확인여부")
|
||||
private String checkReport;
|
||||
|
||||
@ExcelColumn(header = "요원 비용지급일", order = 19, width = 16)
|
||||
@Schema(description = "요원 비용지급일")
|
||||
private String monitoringPaymentDate;
|
||||
|
||||
@ExcelColumn(header = "대표자 명", order = 20, width = 10)
|
||||
@Schema(description = "대표자 명")
|
||||
private String ownStaffName;
|
||||
|
||||
@ExcelColumn(header = "대표자 연락처1", order = 21, width = 14)
|
||||
@Schema(description = "대표자 연락처1")
|
||||
private String ownStaffTel1;
|
||||
|
||||
@ExcelColumn(header = "대표자 연락처2", order = 22, width = 14)
|
||||
@Schema(description = "대표자 연락처2")
|
||||
private String ownStaffTel2;
|
||||
|
||||
@ExcelColumn(header = "대표자 이메일", order = 23, width = 14)
|
||||
@Schema(description = "대표자 이메일")
|
||||
private String ownStaffEmail;
|
||||
|
||||
@ExcelColumn(header = "실무자 명", order = 24, width = 10)
|
||||
@Schema(description = "실무자 명")
|
||||
private String contactStaffName;
|
||||
|
||||
@ExcelColumn(header = "실무자 연락처1", order = 25, width = 14)
|
||||
@Schema(description = "실무자 연락처1")
|
||||
private String contactStaffTel1;
|
||||
|
||||
@ExcelColumn(header = "실무자 연락처2", order = 26, width = 14)
|
||||
@Schema(description = "실무자 연락처2")
|
||||
private String contactStaffTel2;
|
||||
|
||||
@ExcelColumn(header = "실무자 이메일", order = 27, width = 14)
|
||||
@Schema(description = "실무자 이메일")
|
||||
private String contactStaffEmail;
|
||||
|
||||
@ExcelColumn(header = "예경 담당자 명", order = 28, width = 14)
|
||||
@Schema(description = "예경 담당자 명")
|
||||
private String clientManagerName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.kri.kmusical.manage.back.dto.excel.user;
|
||||
|
||||
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 userCmpn;
|
||||
|
||||
@ExcelColumn(header = "직급", order = 4, width = 11)
|
||||
@Schema(description = "직급")
|
||||
private String userGrade;
|
||||
|
||||
@ExcelColumn(header = "사용자 연락처", order = 5, width = 14)
|
||||
@Schema(description = "사용자 연락처")
|
||||
private String userTel;
|
||||
|
||||
@ExcelColumn(header = "사용자 이메일", order = 6, width = 14)
|
||||
@Schema(description = "사용자 이메일")
|
||||
private String userEmail;
|
||||
|
||||
@ExcelColumn(header = "메모", order = 7, width = 20)
|
||||
@Schema(description = "메모")
|
||||
private String memo;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.kri.kmusical.manage.back.dto.excel.user;
|
||||
|
||||
public interface UserUploadBaseDto {
|
||||
|
||||
String getUserId();
|
||||
|
||||
String getUserPw();
|
||||
|
||||
String getUserName();
|
||||
|
||||
String getMemo();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.kmusical.manage.back.dto.kon;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "KON 공연 신청 수")
|
||||
public class PerformanceApplyCountDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "신청 수")
|
||||
private Long applyCnt;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.kri.kmusical.manage.back.dto.kon;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "KON 공연 신청 자")
|
||||
public class PerformanceApplyUserDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "신청자 ID")
|
||||
private String userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceAssignEntity;
|
||||
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 PerformanceAssignDto {
|
||||
|
||||
@Schema(description = "사업고유id")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "평가 슬롯")
|
||||
private Integer reviewSlot;
|
||||
|
||||
@Schema(description = "사용자 id")
|
||||
private String assignUser;
|
||||
|
||||
@Schema(description = "사용자 컨펌 여부")
|
||||
private Short assignStatus;
|
||||
|
||||
public static PerformanceAssignDto from(TPerformanceAssignEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PerformanceAssignDto.builder()
|
||||
.performanceId(entity.getId().getPerformanceId())
|
||||
.reviewSlot(entity.getId().getReviewSlot())
|
||||
.assignUser(entity.getAssignUser())
|
||||
.assignStatus(entity.getAssignStatus())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceBaseDto {
|
||||
|
||||
@Schema(description = "사업고유id")
|
||||
private String performanceId;
|
||||
|
||||
@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()
|
||||
.performanceId(entity.getPerformanceId())
|
||||
.businessType(entity.getBusinessType())
|
||||
.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
import com.kri.kmusical.manage.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()
|
||||
.performanceId(performance.getPerformanceId())
|
||||
.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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
import com.kri.kmusical.manage.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 = "평가 슬롯별 평가 정보")
|
||||
private Map<Integer, PerformanceReviewDto> performanceReviewMap;
|
||||
|
||||
public static PerformanceFullDto from(
|
||||
TPerformanceEntity performance,
|
||||
Map<String, String> performanceDetail,
|
||||
List<PerformanceStaffDto> performanceStaff,
|
||||
PerformanceMonitoringScheduleDto performanceMonitoringSchedule,
|
||||
List<PerformanceAssignDto> performanceAssignList,
|
||||
Map<Integer, PerformanceReviewDto> performanceReviewMap
|
||||
) {
|
||||
return of(
|
||||
PerformanceBaseDto.from(performance),
|
||||
performanceDetail,
|
||||
performanceStaff,
|
||||
performanceMonitoringSchedule,
|
||||
performanceAssignList,
|
||||
performanceReviewMap
|
||||
);
|
||||
}
|
||||
|
||||
public static PerformanceFullDto of(
|
||||
PerformanceBaseDto performance,
|
||||
Map<String, String> performanceDetail,
|
||||
List<PerformanceStaffDto> performanceStaff,
|
||||
PerformanceMonitoringScheduleDto performanceMonitoringSchedule,
|
||||
List<PerformanceAssignDto> performanceAssignList,
|
||||
Map<Integer, PerformanceReviewDto> performanceReviewMap
|
||||
) {
|
||||
if (performance == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PerformanceFullDto.builder()
|
||||
.performanceId(performance.getPerformanceId())
|
||||
.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)
|
||||
.performanceReviewMap(performanceReviewMap)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDate;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceMonitoringScheduleDto {
|
||||
|
||||
@Schema(description = "사업 방문 스케쥴 인덱스")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "사업고유id")
|
||||
private String 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceReviewDto {
|
||||
|
||||
@Schema(description = "사업고유id")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "평가 슬롯")
|
||||
private Integer reviewSlot;
|
||||
|
||||
@Schema(description = "등록 사용자")
|
||||
private String regUser;
|
||||
|
||||
@Schema(description = "평가 일시")
|
||||
private LocalDateTime reviewDt;
|
||||
|
||||
@Schema(description = "평가 상태")
|
||||
private Integer reviewStatus;
|
||||
|
||||
@Schema(description = "업로드 파일명")
|
||||
private String uploadFileName;
|
||||
|
||||
@Schema(description = "pdf로 변환성공 여부")
|
||||
private Short pdfConvert;
|
||||
|
||||
@Schema(description = "pdf로 변환된 파일명")
|
||||
private String pdfFileName;
|
||||
|
||||
public static PerformanceReviewDto from(TPerformanceReviewEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalDateTime reviewDt = entity.getModDt() != null ? entity.getModDt() : entity.getRegDt();
|
||||
|
||||
return PerformanceReviewDto.builder()
|
||||
.performanceId(entity.getPerformanceId())
|
||||
.reviewSlot(entity.getReviewSlot())
|
||||
.regUser(entity.getRegUser())
|
||||
.reviewDt(reviewDt)
|
||||
.reviewStatus(entity.getReviewStatus())
|
||||
.uploadFileName(entity.getUploadFileName())
|
||||
.pdfConvert(entity.getPdfConvert())
|
||||
.pdfFileName(entity.getPdfFileName())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewSlotEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceReviewSlotDto {
|
||||
|
||||
@Schema(description = "평가 슬롯")
|
||||
private Integer reviewSlot;
|
||||
|
||||
@Schema(description = "평가 타입")
|
||||
private Integer reviewType;
|
||||
|
||||
public static PerformanceReviewSlotDto from(TPerformanceReviewSlotEntity entity) {
|
||||
return PerformanceReviewSlotDto.builder()
|
||||
.reviewSlot(entity.getReviewSlot())
|
||||
.reviewType(entity.getReviewType())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.kri.kmusical.manage.back.dto.performance;
|
||||
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceStaffEntity;
|
||||
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 PerformanceStaffDto {
|
||||
|
||||
@Schema(description = "사업 관계자 인덱스")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "사업고유id")
|
||||
private String 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.kri.kmusical.manage.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;
|
||||
String uploadUserId;
|
||||
|
||||
public static UploadContentDto from(MultipartFile file, String uploadUserId){
|
||||
return UploadContentDto.builder()
|
||||
.fileName(file.getOriginalFilename())
|
||||
.fileType(file.getContentType())
|
||||
.fileSize(file.getSize())
|
||||
.uploadUserId(uploadUserId)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.kri.kmusical.manage.back.dto.user;
|
||||
|
||||
import com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.kri.kmusical.manage.back.dto.user;
|
||||
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.util.MakeExtraFieldMap.toExtraFieldMap;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.excel.user.UserUploadBaseDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TUserEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Collection;
|
||||
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 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.common.CodeDto;
|
||||
import com.kri.kmusical.manage.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceAssignDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceAssignEntityId;
|
||||
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.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "t_performance_assign")
|
||||
public class TPerformanceAssignEntity {
|
||||
|
||||
@EmbeddedId
|
||||
private TPerformanceAssignEntityId id;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "assign_user", nullable = false, length = 32)
|
||||
private String assignUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "assign_status", nullable = false)
|
||||
private Short assignStatus;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "reg_user", nullable = false, length = 32)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
public String getPerformanceId() {
|
||||
return id.getPerformanceId();
|
||||
}
|
||||
|
||||
public Integer getReviewSlot() {
|
||||
return id.getReviewSlot();
|
||||
}
|
||||
|
||||
public static TPerformanceAssignEntity from(PerformanceAssignDto dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
|
||||
entity.setId(new TPerformanceAssignEntityId(dto.getPerformanceId(), dto.getReviewSlot()));
|
||||
entity.setAssignUser(dto.getAssignUser());
|
||||
entity.setAssignStatus(dto.getAssignStatus());
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
private LocalDateTime modDt;
|
||||
|
||||
public String getPerformanceId() {
|
||||
return id.getPerformanceId();
|
||||
}
|
||||
|
||||
public String getPerformanceDetailKey() {
|
||||
return id.getPerformanceDetailKey();
|
||||
}
|
||||
|
||||
public static TPerformanceDetailEntity update(
|
||||
String 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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
|
||||
@Size(max = 32)
|
||||
@Column(name = "performance_id", nullable = false, length = 32)
|
||||
private String performanceId;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "performance_no", nullable = false)
|
||||
private Integer performanceNo;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "business_type", nullable = false)
|
||||
private Integer businessType;
|
||||
|
||||
@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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
private LocalDateTime modDt;
|
||||
|
||||
public static TPerformanceEntity from(PerformanceBaseDto dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TPerformanceEntity entity = new TPerformanceEntity();
|
||||
entity.setPerformanceId(dto.getPerformanceId());
|
||||
entity.setBusinessType(dto.getBusinessType());
|
||||
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.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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)
|
||||
private Long id;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "performance_id", nullable = false, length = 32)
|
||||
private String performanceId;
|
||||
|
||||
@Column(name = "monitoring_date")
|
||||
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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.kmusical.manage.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 Short pdfConvert;
|
||||
|
||||
@Size(max = 512)
|
||||
@NotNull
|
||||
@Column(name = "pdf_file_name", nullable = false, length = 512)
|
||||
private String pdfFileName;
|
||||
|
||||
@Column(name = "pdf_convert_dt")
|
||||
private LocalDateTime pdfConvertDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "reg_user", nullable = false, length = 32)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
private LocalDateTime modDt;
|
||||
|
||||
public String getPerformanceId() {
|
||||
return id.getPerformanceId();
|
||||
}
|
||||
|
||||
public Integer getReviewSlot() {
|
||||
return id.getReviewSlot();
|
||||
}
|
||||
|
||||
public static TPerformanceReviewEntity from(PerformanceReviewDto dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TPerformanceReviewEntity entity = new TPerformanceReviewEntity();
|
||||
entity.setId(TPerformanceReviewEntityId.builder()
|
||||
.performanceId(dto.getPerformanceId())
|
||||
.reviewSlot(dto.getReviewSlot())
|
||||
.build());
|
||||
entity.setReviewStatus(dto.getReviewStatus());
|
||||
entity.setUploadFileName(dto.getUploadFileName());
|
||||
entity.setPdfConvert(dto.getPdfConvert());
|
||||
entity.setPdfFileName(dto.getPdfFileName());
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceReviewSlotDto;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter @Setter @Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "t_performance_review_slot")
|
||||
public class TPerformanceReviewSlotEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "review_slot", nullable = false)
|
||||
private Integer reviewSlot;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "review_type", nullable = false)
|
||||
private Integer reviewType;
|
||||
|
||||
|
||||
public static TPerformanceReviewSlotEntity from(PerformanceReviewSlotDto dto) {
|
||||
return TPerformanceReviewSlotEntity.builder()
|
||||
.reviewSlot(dto.getReviewSlot())
|
||||
.reviewType(dto.getReviewType())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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)
|
||||
private Long id;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "performance_id", nullable = false, length = 32)
|
||||
private String 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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
private LocalDateTime modDt;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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.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)
|
||||
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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
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)
|
||||
.regUser(modUser)
|
||||
.regDt(modDt)
|
||||
.modUser(modUser)
|
||||
.modDt(modDt)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.kri.kmusical.manage.back.persistence.entity;
|
||||
|
||||
import com.kri.kmusical.manage.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)
|
||||
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)
|
||||
private String userCmpn;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "user_team", nullable = false, length = 32)
|
||||
private String userTeam;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "user_role", nullable = 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)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "mod_user", length = 32)
|
||||
private String modUser;
|
||||
|
||||
@Column(name = "mod_dt")
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.kri.kmusical.manage.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.Serial;
|
||||
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 {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 7929829948288158244L;
|
||||
@Size(max = 64)
|
||||
@NotNull
|
||||
@Column(name = "code_group", nullable = false, length = 64)
|
||||
private String codeGroup;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "code_value", nullable = false)
|
||||
private Integer codeValue;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.kri.kmusical.manage.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.Serial;
|
||||
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 TPerformanceAssignEntityId implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -1096367455446307015L;
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "performance_id", nullable = false, length = 32)
|
||||
private String performanceId;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "review_slot", nullable = false)
|
||||
private Integer reviewSlot;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.kri.kmusical.manage.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.Serial;
|
||||
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 {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -759856812074393127L;
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "performance_id", nullable = false, length = 32)
|
||||
private String performanceId;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotNull
|
||||
@Column(name = "performance_detail_key", nullable = false, length = 64)
|
||||
private String performanceDetailKey;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.kri.kmusical.manage.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.Serial;
|
||||
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 {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6558083063451609271L;
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "performance_id", nullable = false, length = 32)
|
||||
private String performanceId;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "review_slot", nullable = false)
|
||||
private Integer reviewSlot;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.kri.kmusical.manage.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.Serial;
|
||||
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 {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 6587704077866002687L;
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "user_id", nullable = false, length = 32)
|
||||
private String userId;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotNull
|
||||
@Column(name = "user_detail_key", nullable = false, length = 64)
|
||||
private String userDetailKey;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.kri.kmusical.manage.back.persistence.mapper.kon;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.kon.PerformanceApplyCountDto;
|
||||
import com.kri.kmusical.manage.back.dto.kon.PerformanceApplyUserDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface KonMapper {
|
||||
|
||||
List<PerformanceApplyCountDto> findPerformanceApplyCount(
|
||||
@Param("surveyType") String surveyType
|
||||
);
|
||||
|
||||
List<PerformanceApplyUserDto> findPerformanceApplyUser(
|
||||
@Param("surveyType") String surveyType,
|
||||
@Param("performanceId") String performanceId
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TCodeEntity;
|
||||
import com.kri.kmusical.manage.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);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.assign.AssignUserCountDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceAssignEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceAssignEntityId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface PerformanceAssignRepository extends JpaRepository<TPerformanceAssignEntity, TPerformanceAssignEntityId> {
|
||||
|
||||
boolean existsByAssignUser(String assignUser);
|
||||
|
||||
boolean existsByIdPerformanceId(String performanceId);
|
||||
|
||||
List<TPerformanceAssignEntity> findByIdPerformanceId(String performanceId);
|
||||
|
||||
boolean existsByIdPerformanceIdAndAssignUser(String performanceId, String assignUser);
|
||||
|
||||
boolean existsByAssignUserAndIdPerformanceIdNot(String assignUser, String performanceId);
|
||||
|
||||
Optional<TPerformanceAssignEntity> findByIdPerformanceIdAndIdReviewSlot(
|
||||
String performanceId,
|
||||
Integer reviewSlot
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select new com.kri.kmusical.manage.back.dto.assign.AssignUserCountDto(
|
||||
assign.assignUser,
|
||||
count(assign)
|
||||
)
|
||||
from TPerformanceAssignEntity assign
|
||||
group by assign.assignUser
|
||||
""")
|
||||
List<AssignUserCountDto> countGroupByAssignUser();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceDetailEntity;
|
||||
import com.kri.kmusical.manage.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(String performanceId);
|
||||
|
||||
Integer deleteByIdPerformanceId(String performanceId);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.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(String performanceId);
|
||||
|
||||
Integer deleteByPerformanceId(String performanceId);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PerformanceRepository extends JpaRepository<TPerformanceEntity, String> {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceReviewEntityId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PerformanceReviewRepository extends JpaRepository<TPerformanceReviewEntity, TPerformanceReviewEntityId> {
|
||||
|
||||
boolean existsByRegUserOrModUser(String regUser, String modUser);
|
||||
|
||||
boolean existsByIdPerformanceId(String performanceId);
|
||||
|
||||
List<TPerformanceReviewEntity> findByIdPerformanceId(String performanceId);
|
||||
|
||||
Optional<TPerformanceReviewEntity> findByIdPerformanceIdAndIdReviewSlot(
|
||||
String performanceId,
|
||||
Integer reviewSlot
|
||||
);
|
||||
|
||||
boolean existsByIdPerformanceIdAndIdReviewSlot(String performanceId, Integer reviewSlot);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewSlotEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PerformanceReviewSlotRepository extends JpaRepository<TPerformanceReviewSlotEntity, Integer> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.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(String performanceId);
|
||||
|
||||
Integer deleteByPerformanceId(String performanceId);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TSysEventLogEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SysEventLogRepository extends JpaRepository<TSysEventLogEntity, Long> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TUserDetailEntity;
|
||||
import com.kri.kmusical.manage.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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.kri.kmusical.manage.back.persistence.repository;
|
||||
|
||||
import com.kri.kmusical.manage.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);
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kmusical.manage.back.dto.assign.AssignUserCountDto;
|
||||
import com.kri.kmusical.manage.back.dto.assign.MonitoringApplyUserDto;
|
||||
import com.kri.kmusical.manage.back.dto.kon.PerformanceApplyCountDto;
|
||||
import com.kri.kmusical.manage.back.dto.kon.PerformanceApplyUserDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceAssignDto;
|
||||
import com.kri.kmusical.manage.back.dto.user.UserCompactDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceAssignEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TUserDetailEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TUserEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceAssignEntityId;
|
||||
import com.kri.kmusical.manage.back.persistence.mapper.kon.KonMapper;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceAssignRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewSlotRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.UserDetailRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.UserRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AssignService {
|
||||
|
||||
private static final short ASSIGN_STATUS_CONFIRMED = 1;
|
||||
|
||||
private final PerformanceAssignRepository performanceAssignRepository;
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
private final PerformanceReviewSlotRepository performanceReviewSlotRepository;
|
||||
private final KonMapper konMapper;
|
||||
private final PerformanceRepository performanceRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final UserDetailRepository userDetailRepository;
|
||||
|
||||
@Value("${kon.survey-type:LIST}")
|
||||
private String surveyType;
|
||||
|
||||
public boolean hasAssignWithUser(String userId) {
|
||||
return performanceAssignRepository.existsByAssignUser(userId);
|
||||
}
|
||||
|
||||
public boolean hasAssignWithPerformance(String performanceId) {
|
||||
return performanceAssignRepository.existsByIdPerformanceId(performanceId);
|
||||
}
|
||||
|
||||
public List<PerformanceAssignDto> findByPerformanceId(String performanceId) {
|
||||
return performanceAssignRepository.findByIdPerformanceId(performanceId).stream()
|
||||
.map(PerformanceAssignDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<AssignUserCountDto> findAssignUserCounts() {
|
||||
return performanceAssignRepository.countGroupByAssignUser();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
||||
public List<PerformanceApplyUserDto> findKonPerformanceApplyUser(String performanceId) {
|
||||
return konMapper.findPerformanceApplyUser(surveyType, performanceId);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
||||
public List<PerformanceApplyCountDto> findMonitoringApplyUsersCount() {
|
||||
return konMapper.findPerformanceApplyCount(surveyType);
|
||||
}
|
||||
|
||||
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(String performanceId) {
|
||||
List<PerformanceApplyUserDto> applyUsers = findKonPerformanceApplyUser(performanceId);
|
||||
if (applyUsers.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> userIds = applyUsers.stream()
|
||||
.map(PerformanceApplyUserDto::getUserId)
|
||||
.distinct()
|
||||
.toList();
|
||||
Set<String> userIdSet = Set.copyOf(userIds);
|
||||
Map<String, TUserEntity> userMap = userRepository.findAllById(userIds).stream()
|
||||
.collect(Collectors.toMap(TUserEntity::getUserId, Function.identity()));
|
||||
Map<String, Map<String, String>> userDetailMap = userDetailRepository.findAll().stream()
|
||||
.filter(detail -> userIdSet.contains(detail.getUserId()))
|
||||
.collect(Collectors.groupingBy(
|
||||
TUserDetailEntity::getUserId,
|
||||
Collectors.toMap(
|
||||
TUserDetailEntity::getUserDetailKey,
|
||||
TUserDetailEntity::getUserDetailValue,
|
||||
(left, right) -> right
|
||||
)
|
||||
));
|
||||
|
||||
return applyUsers.stream()
|
||||
.map(applyUser -> {
|
||||
TUserEntity user = userMap.get(applyUser.getUserId());
|
||||
return MonitoringApplyUserDto.builder()
|
||||
.performanceId(performanceId)
|
||||
.userId(applyUser.getUserId())
|
||||
.user(user == null
|
||||
? null
|
||||
: UserCompactDto.from(
|
||||
user,
|
||||
userDetailMap.getOrDefault(applyUser.getUserId(), Collections.emptyMap())
|
||||
))
|
||||
.build();
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceAssignDto confirmAssign(
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String assignUser,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
validateAssignment(performanceId, reviewSlot, assignUser);
|
||||
|
||||
TPerformanceAssignEntity entity = performanceAssignRepository
|
||||
.findByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)
|
||||
.orElse(null);
|
||||
if (entity != null && assignUser.equals(entity.getAssignUser())) {
|
||||
return PerformanceAssignDto.from(entity);
|
||||
}
|
||||
if (entity != null) {
|
||||
validateNoReviewBeforeAssignChange(performanceId, reviewSlot);
|
||||
}
|
||||
if (performanceAssignRepository.existsByIdPerformanceIdAndAssignUser(performanceId, assignUser)) {
|
||||
throw BusinessException.conflict("ASSIGN_USER_DUPLICATED", "동일 공연의 다른 평가 슬롯에 이미 확정된 사용자입니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("assignUser", assignUser);
|
||||
}
|
||||
if (performanceAssignRepository.existsByAssignUserAndIdPerformanceIdNot(assignUser, performanceId)) {
|
||||
throw BusinessException.conflict("ASSIGN_USER_ALREADY_CONFIRMED", "다른 공연에 이미 확정된 사용자입니다.")
|
||||
.with("assignUser", assignUser);
|
||||
}
|
||||
|
||||
if (entity == null) {
|
||||
entity = new TPerformanceAssignEntity();
|
||||
entity.setId(new TPerformanceAssignEntityId(performanceId, reviewSlot));
|
||||
}
|
||||
entity.setAssignUser(assignUser);
|
||||
entity.setAssignStatus(ASSIGN_STATUS_CONFIRMED);
|
||||
entity.setRegUser(regUser);
|
||||
entity.setRegDt(regDt);
|
||||
return PerformanceAssignDto.from(performanceAssignRepository.save(entity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void cancelAssign(String performanceId, Integer reviewSlot) {
|
||||
TPerformanceAssignEntity entity = performanceAssignRepository
|
||||
.findByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)
|
||||
.orElseThrow(() -> BusinessException.notFound("ASSIGN_NOT_FOUND", "배정 정보를 찾을 수 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewSlot", reviewSlot));
|
||||
validateNoReviewBeforeAssignChange(performanceId, reviewSlot);
|
||||
performanceAssignRepository.delete(entity);
|
||||
}
|
||||
|
||||
private void validateAssignment(String performanceId, Integer reviewSlot, String assignUser) {
|
||||
if (StringUtil.isNullOrBlank(performanceId)) {
|
||||
throw BusinessException.badRequest("EMPTY_PERFORMANCE_ID", "공연 ID가 없습니다.");
|
||||
}
|
||||
if (!performanceRepository.existsById(performanceId)) {
|
||||
throw BusinessException.notFound("PERFORMANCE_NOT_FOUND", "존재하지 않는 공연입니다.")
|
||||
.with("performanceId", performanceId);
|
||||
}
|
||||
if (reviewSlot == null) {
|
||||
throw BusinessException.badRequest("EMPTY_REVIEW_SLOT", "평가 슬롯이 없습니다.");
|
||||
}
|
||||
if (!performanceReviewSlotRepository.existsById(reviewSlot)) {
|
||||
throw BusinessException.notFound("REVIEW_SLOT_NOT_FOUND", "존재하지 않는 평가 슬롯입니다.")
|
||||
.with("reviewSlot", reviewSlot);
|
||||
}
|
||||
if (StringUtil.isNullOrBlank(assignUser)) {
|
||||
throw BusinessException.badRequest("EMPTY_USER_ID", "사용자 ID가 없습니다.");
|
||||
}
|
||||
if (!userRepository.existsByUserId(assignUser)) {
|
||||
throw BusinessException.notFound("USER_NOT_FOUND", "존재하지 않는 사용자 ID입니다.")
|
||||
.with("userId", assignUser);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateNoReviewBeforeAssignChange(String performanceId, Integer reviewSlot) {
|
||||
if (performanceReviewRepository.existsByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)) {
|
||||
throw BusinessException.conflict("ASSIGN_HAS_REVIEW", "평가가 시작된 슬롯의 배정은 교체하거나 취소할 수 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewSlot", reviewSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import com.kri.common.feature.auth.jwt.JwtService;
|
||||
import com.kri.kmusical.manage.back.dto.auth.LoginRequestDto;
|
||||
import com.kri.kmusical.manage.back.dto.auth.LoginResponseDto;
|
||||
import com.kri.kmusical.manage.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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import com.kri.kmusical.manage.back.dto.common.CodeDto;
|
||||
import com.kri.kmusical.manage.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,903 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import static com.kri.kmusical.manage.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.kmusical.manage.back.common.util.ExcelUploadResultUtil;
|
||||
import com.kri.kmusical.manage.back.common.util.TelUtil;
|
||||
import com.kri.kmusical.manage.back.dto.common.CodeDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.ExcelErrorDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.performance.PerformanceDownloadDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.performance.PerformanceUploadDto;
|
||||
import com.kri.kmusical.manage.back.dto.kon.PerformanceApplyCountDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceAssignDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceCompactDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceFullDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceMonitoringScheduleDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceStaffDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceAssignEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceDetailEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceStaffEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.mapper.kon.KonMapper;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceAssignRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceDetailRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceMonitoringScheduleRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceStaffRepository;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PerformanceService {
|
||||
|
||||
private static final DateTimeFormatter REVIEW_DT_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private final KonMapper konMapper;
|
||||
private final PerformanceRepository performanceRepository;
|
||||
private final PerformanceDetailRepository performanceDetailRepository;
|
||||
private final PerformanceStaffRepository performanceStaffRepository;
|
||||
private final PerformanceMonitoringScheduleRepository performanceMonitoringScheduleRepository;
|
||||
private final PerformanceAssignRepository performanceAssignRepository;
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
private final CodeService codeService;
|
||||
private final AssignService assignService;
|
||||
private final ReviewService reviewService;
|
||||
|
||||
@Value("${kon.survey-type:LIST}")
|
||||
private String surveyType;
|
||||
|
||||
public PerformanceFullDto getPerformance(String performanceId) {
|
||||
TPerformanceEntity performance = getPerformanceEntity(performanceId);
|
||||
return toFullDto(performance);
|
||||
}
|
||||
|
||||
public List<PerformanceFullDto> getPerformanceList() {
|
||||
List<TPerformanceEntity> performances = performanceRepository.findAll();
|
||||
PerformanceFullLookup lookup = buildPerformanceFullLookup();
|
||||
|
||||
return performances.stream()
|
||||
.map(performance -> toFullDto(performance, lookup))
|
||||
.sorted(Comparator.comparing(
|
||||
this::getPerformanceNoForSort,
|
||||
Comparator.nullsLast(Integer::compareTo)
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<PerformanceCompactDto> getPerformanceCompactList() {
|
||||
List<TPerformanceEntity> performances = performanceRepository.findAll();
|
||||
PerformanceCompactLookup lookup = buildPerformanceCompactLookup();
|
||||
|
||||
return performances.stream()
|
||||
.map(performance -> toCompactDto(performance, lookup))
|
||||
.sorted(Comparator.comparing(
|
||||
this::getPerformanceNoForSort,
|
||||
Comparator.nullsLast(Integer::compareTo)
|
||||
))
|
||||
.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<>();
|
||||
Set<String> existingPerformanceIds = performanceRepository.findAll().stream()
|
||||
.map(TPerformanceEntity::getPerformanceId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
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,
|
||||
existingPerformanceIds
|
||||
);
|
||||
if (!rowErrors.isEmpty()) {
|
||||
errorList.addAll(rowErrors);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
createPerformanceInternal(row, regUser, regDt);
|
||||
existingPerformanceIds.add(row.getPerformanceId().trim());
|
||||
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.getPerformanceId());
|
||||
|
||||
entity.updateFromDto(dto, modUser, modDt);
|
||||
updatePerformanceDetail(dto.getPerformanceId(), dto.getPerformanceDetail(), modUser, modDt);
|
||||
updatePerformanceStaff(dto.getPerformanceId(), dto.getPerformanceStaff(), modUser, modDt);
|
||||
upsertPerformanceMonitoringSchedule(
|
||||
dto.getPerformanceId(),
|
||||
dto.getPerformanceMonitoringSchedule(),
|
||||
modUser,
|
||||
modDt
|
||||
);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deletePerformance(String 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("공연 업로드 템플릿 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] exportPerformance(String[] performanceIds) {
|
||||
Set<String> selectedPerformanceIds = performanceIds == null
|
||||
? Collections.emptySet()
|
||||
: Arrays.stream(performanceIds).collect(Collectors.toSet());
|
||||
List<PerformanceDownloadDto> performanceList = getPerformanceList().stream()
|
||||
.filter(performance -> selectedPerformanceIds.contains(performance.getPerformanceId()))
|
||||
.map(this::toPerformanceDownloadRow)
|
||||
.toList();
|
||||
|
||||
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");
|
||||
List<CodeDto> reviewStatusList = codeService.findByCodeGroup("review_status");
|
||||
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(performanceList, PerformanceDownloadDto.class);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
|
||||
appendCodeSheet(workbook, businessTypeList, "사업유형");
|
||||
appendCodeSheet(workbook, genreList, "장르");
|
||||
appendCodeSheet(workbook, areaList, "지역");
|
||||
appendCodeSheet(workbook, ticketReservationStatusList, "티켓 예약");
|
||||
appendCodeSheet(workbook, reviewStatusList, "평가 상태");
|
||||
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("공연 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
private PerformanceDownloadDto toPerformanceDownloadRow(PerformanceFullDto performance) {
|
||||
Map<String, String> detail = performance.getPerformanceDetail() == null
|
||||
? Collections.emptyMap()
|
||||
: performance.getPerformanceDetail();
|
||||
PerformanceMonitoringScheduleDto schedule = performance.getPerformanceMonitoringSchedule();
|
||||
PerformanceStaffDto ownStaff = findStaff(performance, 1);
|
||||
PerformanceStaffDto contactStaff = findStaff(performance, 2);
|
||||
PerformanceAssignDto monitoringAssign1 = findAssign(performance, 1);
|
||||
PerformanceAssignDto monitoringAssign2 = findAssign(performance, 2);
|
||||
PerformanceAssignDto monitoringAssign3 = findAssign(performance, 3);
|
||||
PerformanceAssignDto consultingAssign1 = findAssign(performance, 4);
|
||||
PerformanceAssignDto consultingAssign2 = findAssign(performance, 5);
|
||||
PerformanceReviewDto monitoringReview1 = findReview(performance, 1);
|
||||
PerformanceReviewDto monitoringReview2 = findReview(performance, 2);
|
||||
PerformanceReviewDto monitoringReview3 = findReview(performance, 3);
|
||||
PerformanceReviewDto consultingReview1 = findReview(performance, 4);
|
||||
PerformanceReviewDto consultingReview2 = findReview(performance, 5);
|
||||
|
||||
return PerformanceDownloadDto.builder()
|
||||
.performanceId(performance.getPerformanceId())
|
||||
.businessType(toStringValue(performance.getBusinessType()))
|
||||
.performanceArea(toStringValue(performance.getPerformanceArea()))
|
||||
.artistName(performance.getArtistName())
|
||||
.performanceName(performance.getPerformanceName())
|
||||
.performanceStartMonth(toStringValue(performance.getPerformanceStartMonth()))
|
||||
.performanceDtInfo(performance.getPerformanceDtInfo())
|
||||
.performanceTimeInfo(performance.getPerformanceTimeInfo())
|
||||
.ticketReservationStatus(toStringValue(performance.getTicketReservationStatus()))
|
||||
.ticketReservationMemo(performance.getTicketReservationMemo())
|
||||
.monitoringDate(schedule == null ? null : toStringValue(schedule.getMonitoringDate()))
|
||||
.monitoringTimeInfo(schedule == null ? null : schedule.getMonitoringTimeInfo())
|
||||
.monitoringAddress(schedule == null ? null : schedule.getMonitoringAddress())
|
||||
.ownStaffName(ownStaff == null ? null : ownStaff.getStaffName())
|
||||
.ownStaffTel1(ownStaff == null ? null : ownStaff.getStaffTel1())
|
||||
.ownStaffTel2(ownStaff == null ? null : ownStaff.getStaffTel2())
|
||||
.ownStaffEmail(ownStaff == null ? null : ownStaff.getStaffEmail())
|
||||
.contactStaffName(contactStaff == null ? null : contactStaff.getStaffName())
|
||||
.contactStaffTel1(contactStaff == null ? null : contactStaff.getStaffTel1())
|
||||
.contactStaffTel2(contactStaff == null ? null : contactStaff.getStaffTel2())
|
||||
.contactStaffEmail(contactStaff == null ? null : contactStaff.getStaffEmail())
|
||||
.performanceMemo(performance.getPerformanceMemo())
|
||||
.monitoringPaymentDate(detail.get("monitoringPaymentDate"))
|
||||
.monitoringReviewUser1(monitoringAssign1 == null ? null : monitoringAssign1.getAssignUser())
|
||||
.monitoringReviewStatus1(monitoringReview1 == null ? null : toStringValue(monitoringReview1.getReviewStatus()))
|
||||
.monitoringReviewDt1(formatReviewDt(monitoringReview1))
|
||||
.monitoringReviewUser2(monitoringAssign2 == null ? null : monitoringAssign2.getAssignUser())
|
||||
.monitoringReviewStatus2(monitoringReview2 == null ? null : toStringValue(monitoringReview2.getReviewStatus()))
|
||||
.monitoringReviewDt2(formatReviewDt(monitoringReview2))
|
||||
.monitoringReviewUser3(monitoringAssign3 == null ? null : monitoringAssign3.getAssignUser())
|
||||
.monitoringReviewStatus3(monitoringReview3 == null ? null : toStringValue(monitoringReview3.getReviewStatus()))
|
||||
.monitoringReviewDt3(formatReviewDt(monitoringReview3))
|
||||
.consultingReviewUser1(consultingAssign1 == null ? null : consultingAssign1.getAssignUser())
|
||||
.consultingReviewStatus1(consultingReview1 == null ? null : toStringValue(consultingReview1.getReviewStatus()))
|
||||
.consultingReviewDt1(formatReviewDt(consultingReview1))
|
||||
.consultingReviewUser2(consultingAssign2 == null ? null : consultingAssign2.getAssignUser())
|
||||
.consultingReviewStatus2(consultingReview2 == null ? null : toStringValue(consultingReview2.getReviewStatus()))
|
||||
.consultingReviewDt2(formatReviewDt(consultingReview2))
|
||||
.build();
|
||||
}
|
||||
|
||||
private PerformanceStaffDto findStaff(PerformanceFullDto performance, Integer staffType) {
|
||||
if (performance.getPerformanceStaff() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceStaff().stream()
|
||||
.filter(staff -> Objects.equals(staff.getStaffType(), staffType))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private PerformanceAssignDto findAssign(
|
||||
PerformanceFullDto performance,
|
||||
Integer reviewSlot
|
||||
) {
|
||||
if (performance.getPerformanceAssignList() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceAssignList().stream()
|
||||
.filter(assign -> Objects.equals(assign.getReviewSlot(), reviewSlot))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private PerformanceReviewDto findReview(PerformanceFullDto performance, Integer reviewSlot) {
|
||||
if (performance.getPerformanceReviewMap() == null) {
|
||||
return null;
|
||||
}
|
||||
return performance.getPerformanceReviewMap().get(reviewSlot);
|
||||
}
|
||||
|
||||
private String formatReviewDt(PerformanceReviewDto review) {
|
||||
return review == null || review.getReviewDt() == null
|
||||
? null
|
||||
: review.getReviewDt().format(REVIEW_DT_FORMATTER);
|
||||
}
|
||||
|
||||
private String toStringValue(Object value) {
|
||||
return value == null ? null : String.valueOf(value);
|
||||
}
|
||||
|
||||
private Integer getPerformanceNoForSort(PerformanceFullDto performance) {
|
||||
if (performance == null || performance.getPerformanceDetail() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return NumericUtil.parseOnlyInteger(performance.getPerformanceDetail().get("performanceNo"));
|
||||
}
|
||||
|
||||
private Integer getPerformanceNoForSort(PerformanceCompactDto performance) {
|
||||
if (performance == null || performance.getPerformanceDetail() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return NumericUtil.parseOnlyInteger(performance.getPerformanceDetail().get("performanceNo"));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
||||
public List<PerformanceApplyCountDto> findPerformanceApplyCount() {
|
||||
return konMapper.findPerformanceApplyCount(surveyType);
|
||||
}
|
||||
|
||||
private PerformanceFullDto toFullDto(TPerformanceEntity performance) {
|
||||
String performanceId = performance.getPerformanceId();
|
||||
|
||||
return PerformanceFullDto.from(
|
||||
performance,
|
||||
getPerformanceDetailMap(performanceId),
|
||||
getPerformanceStaffList(performanceId),
|
||||
getPerformanceMonitoringSchedule(performanceId),
|
||||
assignService.findByPerformanceId(performanceId),
|
||||
reviewService.findMapByPerformanceId(performanceId)
|
||||
);
|
||||
}
|
||||
|
||||
private PerformanceFullDto toFullDto(TPerformanceEntity performance, PerformanceFullLookup lookup) {
|
||||
String performanceId = performance.getPerformanceId();
|
||||
|
||||
return PerformanceFullDto.from(
|
||||
performance,
|
||||
lookup.performanceDetailMap().getOrDefault(performanceId, Collections.emptyMap()),
|
||||
lookup.performanceStaffMap().getOrDefault(performanceId, Collections.emptyList()),
|
||||
lookup.performanceMonitoringScheduleMap().get(performanceId),
|
||||
lookup.performanceAssignMap().getOrDefault(performanceId, Collections.emptyList()),
|
||||
lookup.performanceReviewMap().getOrDefault(performanceId, Collections.emptyMap())
|
||||
);
|
||||
}
|
||||
|
||||
private PerformanceCompactDto toCompactDto(TPerformanceEntity performance) {
|
||||
String performanceId = performance.getPerformanceId();
|
||||
|
||||
return PerformanceCompactDto.from(
|
||||
performance,
|
||||
getPerformanceDetailMap(performanceId),
|
||||
getPerformanceStaffList(performanceId),
|
||||
getPerformanceMonitoringSchedule(performanceId)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private PerformanceCompactDto toCompactDto(
|
||||
TPerformanceEntity performance,
|
||||
PerformanceCompactLookup lookup
|
||||
) {
|
||||
String performanceId = performance.getPerformanceId();
|
||||
|
||||
return PerformanceCompactDto.from(
|
||||
performance,
|
||||
lookup.performanceDetailMap().getOrDefault(performanceId, Collections.emptyMap()),
|
||||
lookup.performanceStaffMap().getOrDefault(performanceId, Collections.emptyList()),
|
||||
lookup.performanceMonitoringScheduleMap().get(performanceId)
|
||||
);
|
||||
}
|
||||
|
||||
private PerformanceFullLookup buildPerformanceFullLookup() {
|
||||
PerformanceCompactLookup compactLookup = buildPerformanceCompactLookup();
|
||||
Map<String, List<PerformanceAssignDto>> assignMap = performanceAssignRepository.findAll()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TPerformanceAssignEntity::getPerformanceId,
|
||||
Collectors.mapping(PerformanceAssignDto::from, Collectors.toList())
|
||||
));
|
||||
Map<String, Map<Integer, PerformanceReviewDto>> reviewMap =
|
||||
performanceReviewRepository.findAll()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TPerformanceReviewEntity::getPerformanceId,
|
||||
Collectors.toMap(
|
||||
TPerformanceReviewEntity::getReviewSlot,
|
||||
PerformanceReviewDto::from
|
||||
)
|
||||
));
|
||||
|
||||
return new PerformanceFullLookup(
|
||||
compactLookup.performanceDetailMap(),
|
||||
compactLookup.performanceStaffMap(),
|
||||
compactLookup.performanceMonitoringScheduleMap(),
|
||||
assignMap,
|
||||
reviewMap
|
||||
);
|
||||
}
|
||||
|
||||
private PerformanceCompactLookup buildPerformanceCompactLookup() {
|
||||
Map<String, Map<String, String>> detailMap = performanceDetailRepository.findAll()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TPerformanceDetailEntity::getPerformanceId,
|
||||
toMap(
|
||||
TPerformanceDetailEntity::getPerformanceDetailKey,
|
||||
TPerformanceDetailEntity::getPerformanceDetailValue,
|
||||
(left, right) -> right,
|
||||
LinkedHashMap::new
|
||||
)
|
||||
));
|
||||
Map<String, List<PerformanceStaffDto>> staffMap = performanceStaffRepository.findAll()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TPerformanceStaffEntity::getPerformanceId,
|
||||
Collectors.mapping(PerformanceStaffDto::from, Collectors.toList())
|
||||
));
|
||||
Map<String, PerformanceMonitoringScheduleDto> scheduleMap =
|
||||
performanceMonitoringScheduleRepository.findAll()
|
||||
.stream()
|
||||
.collect(toMap(
|
||||
TPerformanceMonitoringScheduleEntity::getPerformanceId,
|
||||
PerformanceMonitoringScheduleDto::from,
|
||||
(first, ignored) -> first
|
||||
));
|
||||
|
||||
return new PerformanceCompactLookup(detailMap, staffMap, scheduleMap);
|
||||
}
|
||||
|
||||
private record PerformanceCompactLookup(
|
||||
Map<String, Map<String, String>> performanceDetailMap,
|
||||
Map<String, List<PerformanceStaffDto>> performanceStaffMap,
|
||||
Map<String, PerformanceMonitoringScheduleDto> performanceMonitoringScheduleMap
|
||||
) {
|
||||
}
|
||||
|
||||
private record PerformanceFullLookup(
|
||||
Map<String, Map<String, String>> performanceDetailMap,
|
||||
Map<String, List<PerformanceStaffDto>> performanceStaffMap,
|
||||
Map<String, PerformanceMonitoringScheduleDto> performanceMonitoringScheduleMap,
|
||||
Map<String, List<PerformanceAssignDto>> performanceAssignMap,
|
||||
Map<String, Map<Integer, PerformanceReviewDto>> performanceReviewMap
|
||||
) {
|
||||
}
|
||||
|
||||
private List<ExcelErrorDto> validatePerformanceUploadRow(
|
||||
PerformanceUploadDto row,
|
||||
int rowNumber,
|
||||
List<CodeDto> businessTypeList,
|
||||
List<CodeDto> genreList,
|
||||
List<CodeDto> areaList,
|
||||
List<CodeDto> ticketReservationStatusList,
|
||||
Set<String> existingPerformanceIds
|
||||
) {
|
||||
List<ExcelErrorDto> errors = new ArrayList<>();
|
||||
|
||||
Integer performanceNo = NumericUtil.parseOnlyInteger(row.getPerformanceNo());
|
||||
if (performanceNo == null) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "No", "No는 숫자여야 합니다."));
|
||||
}
|
||||
|
||||
String performanceId = StringUtil.normalizeBlank(row.getPerformanceId());
|
||||
if (performanceId == null) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "연번", "연번을 입력해야 합니다."));
|
||||
} else if (existingPerformanceIds.contains(performanceId)) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "연번", "이미 등록된 공연 ID입니다."));
|
||||
}
|
||||
|
||||
validateCode(errors, rowNumber, "사업유형", row.getBusinessType(), businessTypeList);
|
||||
validateCode(errors, rowNumber, "지역", row.getPerformanceArea(), areaList);
|
||||
validateCode(
|
||||
errors,
|
||||
rowNumber,
|
||||
"티켓 예약",
|
||||
row.getTicketReservationStatus(),
|
||||
ticketReservationStatusList
|
||||
);
|
||||
|
||||
Integer performanceStartMonth = NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth());
|
||||
if(performanceStartMonth == null){
|
||||
performanceStartMonth = 0;
|
||||
}
|
||||
else if (performanceStartMonth < 1 || performanceStartMonth > 12) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "사업 수행 월", "사업 수행 월은 1~12 사이 숫자여야 합니다."));
|
||||
}
|
||||
|
||||
String monitoringDate = row.getMonitoringDate();
|
||||
if (!StringUtil.isNullOrBlank(monitoringDate) && DateTimeUtil.parseLocalDate(monitoringDate) == null) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "모니터링 일정", "모니터링 일정은 yyyy-MM-dd 형식이어야 합니다."));
|
||||
}
|
||||
|
||||
validateRequired(errors, rowNumber, "단체(인) 명", row.getArtistName());
|
||||
validateRequired(errors, rowNumber, "사업 명", row.getPerformanceName());
|
||||
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
|
||||
) {
|
||||
String performanceId = row.getPerformanceId().trim();
|
||||
|
||||
Integer performanceStartMonth = NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth());
|
||||
if(performanceStartMonth == null){
|
||||
performanceStartMonth = 0;
|
||||
}
|
||||
|
||||
TPerformanceEntity performance = TPerformanceEntity.builder()
|
||||
.performanceId(performanceId)
|
||||
.performanceNo(NumericUtil.parseOnlyInteger(row.getPerformanceNo()))
|
||||
.businessType(NumericUtil.parseOnlyInteger(row.getBusinessType()))
|
||||
.performanceArea(NumericUtil.parseOnlyInteger(row.getPerformanceArea()))
|
||||
.artistName(Objects.toString(StringUtil.normalizeBlank(row.getArtistName()), ""))
|
||||
.performanceName(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceName()), ""))
|
||||
.performanceStartMonth(performanceStartMonth)
|
||||
.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(
|
||||
String performanceId,
|
||||
PerformanceUploadDto row,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
Map<String, String> detail = new LinkedHashMap<>();
|
||||
detail.put("monitoringPaymentDate", Objects.toString(StringUtil.normalizeBlank(row.getMonitoringPaymentDate()), ""));
|
||||
|
||||
detail.put("performanceNo", Objects.toString(StringUtil.normalizeBlank(row.getPerformanceNo()), ""));
|
||||
detail.put("performanceAreaDetail", Objects.toString(StringUtil.normalizeBlank(row.getPerformanceAreaDetail()), ""));
|
||||
detail.put("consultingStatus", Objects.toString(StringUtil.normalizeBlank(row.getConsultingStatus()), ""));
|
||||
detail.put("checkDeliver", Objects.toString(StringUtil.normalizeBlank(row.getCheckDeliver()), ""));
|
||||
detail.put("checkReport", Objects.toString(StringUtil.normalizeBlank(row.getCheckReport()), ""));
|
||||
detail.put("clientManagerName", Objects.toString(StringUtil.normalizeBlank(row.getClientManagerName()), ""));
|
||||
|
||||
|
||||
List<TPerformanceDetailEntity> detailEntities = detail.entrySet().stream()
|
||||
.map(entry -> TPerformanceDetailEntity.update(
|
||||
performanceId,
|
||||
entry.getKey(),
|
||||
entry.getValue(),
|
||||
regUser,
|
||||
regDt
|
||||
))
|
||||
.toList();
|
||||
|
||||
performanceDetailRepository.saveAll(detailEntities);
|
||||
}
|
||||
|
||||
private void savePerformanceUploadStaff(
|
||||
String 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(
|
||||
String 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(
|
||||
String 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(String performanceId) {
|
||||
return performanceDetailRepository.findByIdPerformanceId(performanceId).stream()
|
||||
.collect(toMap(
|
||||
TPerformanceDetailEntity::getPerformanceDetailKey,
|
||||
TPerformanceDetailEntity::getPerformanceDetailValue
|
||||
));
|
||||
}
|
||||
|
||||
private List<PerformanceStaffDto> getPerformanceStaffList(String performanceId) {
|
||||
return performanceStaffRepository.findByPerformanceId(performanceId).stream()
|
||||
.map(PerformanceStaffDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private PerformanceMonitoringScheduleDto getPerformanceMonitoringSchedule(String performanceId) {
|
||||
return performanceMonitoringScheduleRepository.findFirstByPerformanceId(performanceId)
|
||||
.map(PerformanceMonitoringScheduleDto::from)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private void updatePerformanceDetail(
|
||||
String 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(
|
||||
String 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(
|
||||
String 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(String performanceId) {
|
||||
if (assignService.hasAssignWithPerformance(performanceId)) {
|
||||
throw BusinessException.conflict("PERFORMANCE_HAS_ASSIGN", "배정 정보가 있는 공연은 삭제할 수 없습니다.")
|
||||
.with("performanceId", performanceId);
|
||||
}
|
||||
|
||||
if (reviewService.hasReviewWithPerformance(performanceId)) {
|
||||
throw BusinessException.conflict("PERFORMANCE_HAS_REVIEW", "평가 결과가 있는 공연은 삭제할 수 없습니다.")
|
||||
.with("performanceId", performanceId);
|
||||
}
|
||||
}
|
||||
|
||||
private TPerformanceEntity getPerformanceEntity(String performanceId) {
|
||||
return performanceRepository.findById(performanceId)
|
||||
.orElseThrow(() ->
|
||||
BusinessException.notFound("PERFORMANCE_NOT_FOUND", "공연을 찾을 수 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewRepository;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReviewPdfConvertService {
|
||||
|
||||
private static final short PDF_CONVERT_COMPLETE = 1;
|
||||
private static final short PDF_CONVERT_FAILED = 9;
|
||||
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
|
||||
@Value("${kri.file.pdf-converter-command:soffice}")
|
||||
private String pdfConverterCommand;
|
||||
|
||||
public void convertReviewFileToPdf(
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String uploadFileName,
|
||||
Path source,
|
||||
Path dir
|
||||
) {
|
||||
String pdfFileName = convertToPdfIfPossible(source, dir);
|
||||
if (StringUtil.isNullOrBlank(pdfFileName)) {
|
||||
updatePdfConvertFailure(performanceId, reviewSlot, uploadFileName);
|
||||
log.warn(
|
||||
"Review PDF conversion failed. performanceId={}, reviewSlot={}, uploadFileName={}",
|
||||
performanceId,
|
||||
reviewSlot,
|
||||
uploadFileName
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)
|
||||
.filter(entity -> uploadFileName.equals(entity.getUploadFileName()))
|
||||
.ifPresentOrElse(
|
||||
entity -> updatePdfConvertResult(entity, pdfFileName),
|
||||
() -> log.info(
|
||||
"Skipped stale review PDF conversion result. performanceId={}, reviewSlot={}, uploadFileName={}, pdfFileName={}",
|
||||
performanceId,
|
||||
reviewSlot,
|
||||
uploadFileName,
|
||||
pdfFileName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private void updatePdfConvertResult(TPerformanceReviewEntity entity, String pdfFileName) {
|
||||
entity.setPdfConvert(PDF_CONVERT_COMPLETE);
|
||||
entity.setPdfFileName(pdfFileName);
|
||||
entity.setPdfConvertDt(LocalDateTime.now());
|
||||
performanceReviewRepository.save(entity);
|
||||
}
|
||||
|
||||
private void updatePdfConvertFailure(
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String uploadFileName
|
||||
) {
|
||||
performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)
|
||||
.filter(entity -> uploadFileName.equals(entity.getUploadFileName()))
|
||||
.ifPresent(entity -> {
|
||||
entity.setPdfConvert(PDF_CONVERT_FAILED);
|
||||
entity.setPdfFileName("");
|
||||
entity.setPdfConvertDt(LocalDateTime.now());
|
||||
performanceReviewRepository.save(entity);
|
||||
});
|
||||
}
|
||||
|
||||
private String convertToPdfIfPossible(Path source, Path dir) {
|
||||
String extension = extractExtension(source.getFileName().toString()).toLowerCase();
|
||||
Set<String> targets = new HashSet<>(Set.of(".docx", ".hwpx", ".hwp", ".pptx", ".xlsx"));
|
||||
if (!targets.contains(extension)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
Process process = new ProcessBuilder(
|
||||
pdfConverterCommand,
|
||||
"--headless",
|
||||
"--convert-to",
|
||||
"pdf",
|
||||
"--outdir",
|
||||
dir.toString(),
|
||||
source.toString()
|
||||
).redirectErrorStream(true).start();
|
||||
|
||||
boolean finished = process.waitFor(300, TimeUnit.SECONDS);
|
||||
if (!finished || process.exitValue() != 0) {
|
||||
process.destroyForcibly();
|
||||
return "";
|
||||
}
|
||||
|
||||
String baseName = stripExtension(source.getFileName().toString());
|
||||
Path pdf = dir.resolve(baseName + ".pdf").normalize();
|
||||
return Files.exists(pdf) ? pdf.getFileName().toString() : "";
|
||||
} catch (Exception e) {
|
||||
log.warn("Review PDF conversion error. source={}", source, e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String stripExtension(String fileName) {
|
||||
int dot = fileName.lastIndexOf('.');
|
||||
return dot > 0 ? fileName.substring(0, dot) : fileName;
|
||||
}
|
||||
|
||||
private String extractExtension(String fileName) {
|
||||
int dot = fileName.lastIndexOf('.');
|
||||
return dot >= 0 ? fileName.substring(dot) : "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.COMPLETE_STATUS;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kmusical.manage.back.config.FileStorageProperties;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceReviewEntityId;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceAssignRepository;
|
||||
import com.kri.kmusical.manage.back.service.file.AbstractFileService;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.io.PathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
public class ReviewService extends AbstractFileService {
|
||||
|
||||
private static final short PDF_CONVERT_PENDING = 0;
|
||||
private static final short PDF_CONVERT_COMPLETE = 1;
|
||||
private static final short PDF_CONVERT_NOT_TARGET = 8;
|
||||
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
private final PerformanceAssignRepository performanceAssignRepository;
|
||||
private final FileStorageProperties fileStorageProperties;
|
||||
private final ReviewPdfConvertService reviewPdfConvertService;
|
||||
private final Executor pdfConvertTaskExecutor;
|
||||
|
||||
public ReviewService(
|
||||
PerformanceReviewRepository performanceReviewRepository,
|
||||
PerformanceAssignRepository performanceAssignRepository,
|
||||
FileStorageProperties fileStorageProperties,
|
||||
ReviewPdfConvertService reviewPdfConvertService,
|
||||
@Qualifier("pdfConvertTaskExecutor") Executor pdfConvertTaskExecutor
|
||||
) {
|
||||
this.performanceReviewRepository = performanceReviewRepository;
|
||||
this.performanceAssignRepository = performanceAssignRepository;
|
||||
this.fileStorageProperties = fileStorageProperties;
|
||||
this.reviewPdfConvertService = reviewPdfConvertService;
|
||||
this.pdfConvertTaskExecutor = pdfConvertTaskExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Path getBaseDir() {
|
||||
return Path.of(fileStorageProperties.getReviewBaseDir())
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
public boolean hasReviewWithUser(String userId) {
|
||||
return performanceReviewRepository.existsByRegUserOrModUser(userId, userId);
|
||||
}
|
||||
|
||||
public boolean hasReviewWithPerformance(String performanceId) {
|
||||
return performanceReviewRepository.existsByIdPerformanceId(performanceId);
|
||||
}
|
||||
|
||||
public Map<Integer, PerformanceReviewDto> findMapByPerformanceId(String performanceId) {
|
||||
return performanceReviewRepository.findByIdPerformanceId(performanceId).stream()
|
||||
.collect(Collectors.toMap(
|
||||
TPerformanceReviewEntity::getReviewSlot,
|
||||
PerformanceReviewDto::from
|
||||
));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceReviewDto uploadReviewFile(
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
MultipartFile file,
|
||||
String userId,
|
||||
LocalDateTime now
|
||||
) {
|
||||
validateAssignedUser(performanceId, reviewSlot, userId);
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
||||
}
|
||||
|
||||
try {
|
||||
Path dir = reviewDir(performanceId, reviewSlot);
|
||||
String uploadFileName = buildFileNameWithTime(file, now);
|
||||
saveFile(dir, file, uploadFileName);
|
||||
Path uploadPath = dir.resolve(uploadFileName).normalize();
|
||||
|
||||
boolean pdfFile = isPdf(uploadFileName);
|
||||
boolean pdfConvertTarget = isPdfConvertTarget(uploadFileName);
|
||||
String pdfFileName = pdfFile ? uploadFileName : "";
|
||||
Short pdfConvert = resolveInitialPdfConvertStatus(pdfFile, pdfConvertTarget);
|
||||
|
||||
TPerformanceReviewEntity entity = performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)
|
||||
.orElseGet(() -> TPerformanceReviewEntity.builder()
|
||||
.id(TPerformanceReviewEntityId.builder()
|
||||
.performanceId(performanceId)
|
||||
.reviewSlot(reviewSlot)
|
||||
.build())
|
||||
.regDt(now)
|
||||
.regUser(userId)
|
||||
.build());
|
||||
|
||||
entity.setReviewStatus(COMPLETE_STATUS);
|
||||
entity.setUploadFileName(uploadFileName);
|
||||
entity.setPdfConvert(pdfConvert);
|
||||
entity.setPdfFileName(pdfFileName);
|
||||
entity.setPdfConvertDt(null);
|
||||
if (entity.getRegUser() == null) {
|
||||
entity.setRegUser(userId);
|
||||
entity.setRegDt(now);
|
||||
} else {
|
||||
entity.setModUser(userId);
|
||||
entity.setModDt(now);
|
||||
}
|
||||
|
||||
TPerformanceReviewEntity saved = performanceReviewRepository.save(entity);
|
||||
if (pdfConvert == PDF_CONVERT_PENDING) {
|
||||
convertPdfAfterCommit(performanceId, reviewSlot, uploadFileName, uploadPath, dir);
|
||||
}
|
||||
|
||||
return PerformanceReviewDto.from(saved);
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_FILE_SAVE_FAILED", "평가/모니터링 파일 저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public PerformanceReviewDto getReviewFile(String performanceId, Integer reviewSlot) {
|
||||
return PerformanceReviewDto.from(getReviewEntity(performanceId, reviewSlot));
|
||||
}
|
||||
|
||||
private void convertPdfAfterCommit(
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String uploadFileName,
|
||||
Path uploadPath,
|
||||
Path dir
|
||||
) {
|
||||
Runnable task = () -> reviewPdfConvertService.convertReviewFileToPdf(
|
||||
performanceId,
|
||||
reviewSlot,
|
||||
uploadFileName,
|
||||
uploadPath,
|
||||
dir
|
||||
);
|
||||
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
pdfConvertTaskExecutor.execute(task);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
pdfConvertTaskExecutor.execute(task);
|
||||
}
|
||||
|
||||
public PathResource getOriginalFileResource(String performanceId, Integer reviewSlot) {
|
||||
TPerformanceReviewEntity entity = getReviewEntity(performanceId, reviewSlot);
|
||||
return toResource(reviewDir(performanceId, reviewSlot).resolve(entity.getUploadFileName()));
|
||||
}
|
||||
|
||||
public PathResource getOriginalFileZipResource(String performanceId, Integer reviewSlot) {
|
||||
List<TPerformanceReviewEntity> reviews = performanceReviewRepository.findAll()
|
||||
.stream()
|
||||
.filter(review -> Integer.valueOf(reviewSlot).equals(review.getReviewSlot()))
|
||||
.filter(review -> StringUtil.hasText(review.getUploadFileName()))
|
||||
.toList();
|
||||
if (reviews.isEmpty()) {
|
||||
throw BusinessException.notFound("REVIEW_FILE_NOT_FOUND", "평가/모니터링 파일이 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewSlot", reviewSlot);
|
||||
}
|
||||
|
||||
try {
|
||||
Path zip = Files.createTempFile(getOriginalFileZipBaseName(performanceId, reviewSlot), ".zip");
|
||||
int entryCount = 0;
|
||||
try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(zip))) {
|
||||
Set<String> entryNames = new HashSet<>();
|
||||
for (TPerformanceReviewEntity review : reviews) {
|
||||
Path sourceDir = reviewDir(review.getPerformanceId(), reviewSlot);
|
||||
Path source = sourceDir.resolve(review.getUploadFileName()).normalize();
|
||||
if (!source.startsWith(sourceDir) || !Files.exists(source) || !Files.isRegularFile(source)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = buildZipEntryName(review, entryNames);
|
||||
out.putNextEntry(new ZipEntry(entryName));
|
||||
Files.copy(source, out);
|
||||
out.closeEntry();
|
||||
entryCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (entryCount == 0) {
|
||||
Files.deleteIfExists(zip);
|
||||
throw BusinessException.notFound("REVIEW_FILE_NOT_FOUND", "평가/모니터링 파일이 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewSlot", reviewSlot);
|
||||
}
|
||||
|
||||
return new PathResource(zip);
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_FILE_ZIP_FAILED", "평가/모니터링 파일 압축 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private String buildZipEntryName(TPerformanceReviewEntity review, Set<String> entryNames) {
|
||||
String userId = StringUtil.isNullOrBlank(review.getRegUser()) ? "user" : review.getRegUser();
|
||||
String fileName = removeTimestampPrefix(review.getUploadFileName());
|
||||
String entryName = sanitizeZipEntryName(review.getPerformanceId() + "_" + userId + "_" + fileName);
|
||||
if (entryNames.add(entryName)) {
|
||||
return entryName;
|
||||
}
|
||||
|
||||
String baseName = stripExtension(entryName);
|
||||
String extension = extractExtension(entryName);
|
||||
int index = 2;
|
||||
while (true) {
|
||||
String candidate = baseName + "_" + index + extension;
|
||||
if (entryNames.add(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
private String sanitizeZipEntryName(String fileName) {
|
||||
String sanitized = Path.of(fileName).getFileName().toString()
|
||||
.replace('\\', '_')
|
||||
.replace('/', '_');
|
||||
return StringUtil.isNullOrBlank(sanitized) ? "review-file" : sanitized;
|
||||
}
|
||||
|
||||
private String getOriginalFileZipBaseName(String performanceId, Integer reviewSlot) {
|
||||
return "review_" + performanceId + "_" + reviewSlot;
|
||||
}
|
||||
|
||||
public PathResource getPdfOrOriginalFileResource(String performanceId, Integer reviewSlot) {
|
||||
TPerformanceReviewEntity entity = getReviewEntity(performanceId, reviewSlot);
|
||||
String fileName = StringUtil.isNullOrBlank(entity.getPdfFileName())
|
||||
? entity.getUploadFileName()
|
||||
: entity.getPdfFileName();
|
||||
return toResource(reviewDir(performanceId, reviewSlot).resolve(fileName));
|
||||
}
|
||||
|
||||
private TPerformanceReviewEntity getReviewEntity(String performanceId, Integer reviewSlot) {
|
||||
return performanceReviewRepository.findByIdPerformanceIdAndIdReviewSlot(
|
||||
performanceId,
|
||||
reviewSlot
|
||||
)
|
||||
.orElseThrow(() -> BusinessException.notFound("REVIEW_FILE_NOT_FOUND", "평가/모니터링 파일이 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewSlot", reviewSlot));
|
||||
}
|
||||
|
||||
private void validateAssignedUser(String performanceId, Integer reviewSlot, String userId) {
|
||||
performanceAssignRepository.findByIdPerformanceIdAndIdReviewSlot(performanceId, reviewSlot)
|
||||
.filter(assign -> assign.getAssignUser().equals(userId))
|
||||
.orElseThrow(() -> BusinessException.forbidden(
|
||||
"REVIEW_ASSIGNMENT_REQUIRED",
|
||||
"해당 평가 슬롯에 확정된 사용자만 평가할 수 있습니다."
|
||||
)
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewSlot", reviewSlot));
|
||||
}
|
||||
|
||||
private PathResource toResource(Path path) {
|
||||
Path normalized = path.toAbsolutePath().normalize();
|
||||
if (!Files.exists(normalized)) {
|
||||
throw BusinessException.notFound("FILE_NOT_FOUND", "파일이 없습니다.");
|
||||
}
|
||||
return new PathResource(normalized);
|
||||
}
|
||||
|
||||
private Path reviewDir(String performanceId, Integer reviewSlot) {
|
||||
return getBaseDir()
|
||||
.resolve(String.valueOf(performanceId))
|
||||
.resolve(String.valueOf(reviewSlot))
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
private String stripExtension(String fileName) {
|
||||
int dot = fileName.lastIndexOf('.');
|
||||
return dot > 0 ? fileName.substring(0, dot) : fileName;
|
||||
}
|
||||
|
||||
private boolean isPdf(String fileName) {
|
||||
return ".pdf".equalsIgnoreCase(extractExtension(fileName));
|
||||
}
|
||||
|
||||
private Short resolveInitialPdfConvertStatus(boolean pdfFile, boolean pdfConvertTarget) {
|
||||
if (pdfFile) {
|
||||
return PDF_CONVERT_COMPLETE;
|
||||
}
|
||||
return pdfConvertTarget ? PDF_CONVERT_PENDING : PDF_CONVERT_NOT_TARGET;
|
||||
}
|
||||
|
||||
private boolean isPdfConvertTarget(String fileName) {
|
||||
String extension = extractExtension(fileName).toLowerCase();
|
||||
return Set.of(".docx", ".hwpx", ".hwp", ".pptx", ".xlsx").contains(extension);
|
||||
}
|
||||
|
||||
private String removeTimestampPrefix(String fileName) {
|
||||
if (StringUtil.isNullOrBlank(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
return fileName.replaceFirst("^\\d{4}-\\d{2}-\\d{2}_\\d{6}_", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.REVIEW_TYPE;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kmusical.manage.back.config.FileStorageProperties;
|
||||
import com.kri.kmusical.manage.back.service.file.AbstractFileService;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.PathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReviewTemplateService extends AbstractFileService {
|
||||
|
||||
private final FileStorageProperties fileStorageProperties;
|
||||
|
||||
@Value("${kri.file.pdf-converter-command:soffice}")
|
||||
private String pdfConverterCommand;
|
||||
|
||||
@Override
|
||||
protected Path getBaseDir() {
|
||||
return Path.of(fileStorageProperties.getReviewTemplateBaseDir())
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
public String uploadReviewTemplate(Integer reviewType, MultipartFile file) {
|
||||
validateReviewTemplateType(reviewType);
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
|
||||
}
|
||||
|
||||
String fileName = sanitizeFileName(file.getOriginalFilename());
|
||||
Path dir = templateDir(reviewType);
|
||||
|
||||
try {
|
||||
deleteExistingFiles(dir);
|
||||
saveFile(dir, file, fileName);
|
||||
Path uploadPath = dir.resolve(fileName).normalize();
|
||||
convertToPdfIfPossible(uploadPath, dir);
|
||||
return fileName;
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_TEMPLATE_SAVE_FAILED", "평가양식 파일 저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public PathResource getReviewTemplateResource(Integer reviewType) {
|
||||
Path file = findReviewTemplateFile(reviewType, false);
|
||||
return new PathResource(file);
|
||||
}
|
||||
|
||||
public PathResource getReviewTemplatePdfResource(Integer reviewType) {
|
||||
Path file = findReviewTemplateFile(reviewType, true);
|
||||
return new PathResource(file);
|
||||
}
|
||||
|
||||
private Path findReviewTemplateFile(Integer reviewType, boolean pdf) {
|
||||
validateReviewTemplateType(reviewType);
|
||||
|
||||
Path dir = templateDir(reviewType);
|
||||
if (!Files.isDirectory(dir)) {
|
||||
throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
||||
.with("reviewType", reviewType);
|
||||
}
|
||||
|
||||
try (var files = Files.list(dir)) {
|
||||
return files
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(path -> pdf == isPdf(path.getFileName().toString()))
|
||||
.sorted(Comparator.comparing(path -> path.getFileName().toString()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
||||
.with("reviewType", reviewType));
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_TEMPLATE_READ_FAILED", "평가양식 파일 조회 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteExistingFiles(Path dir) throws IOException {
|
||||
if (!Files.isDirectory(dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try (var files = Files.list(dir)) {
|
||||
for (Path file : files.filter(Files::isRegularFile).toList()) {
|
||||
Files.deleteIfExists(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String convertToPdfIfPossible(Path source, Path dir) {
|
||||
String extension = extractExtension(source.getFileName().toString()).toLowerCase();
|
||||
Set<String> targets = new HashSet<>(Set.of(".docx", ".hwpx", ".hwp", ".pptx", ".xlsx"));
|
||||
if (isPdf(source.getFileName().toString()) || !targets.contains(extension)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
Process process = new ProcessBuilder(
|
||||
pdfConverterCommand,
|
||||
"--headless",
|
||||
"--convert-to",
|
||||
"pdf",
|
||||
"--outdir",
|
||||
dir.toString(),
|
||||
source.toString()
|
||||
).redirectErrorStream(true).start();
|
||||
|
||||
boolean finished = process.waitFor(60, TimeUnit.SECONDS);
|
||||
if (!finished || process.exitValue() != 0) {
|
||||
process.destroyForcibly();
|
||||
return "";
|
||||
}
|
||||
|
||||
String baseName = stripExtension(source.getFileName().toString());
|
||||
Path pdf = dir.resolve(baseName + ".pdf").normalize();
|
||||
return Files.exists(pdf) ? pdf.getFileName().toString() : "";
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String stripExtension(String fileName) {
|
||||
int dot = fileName.lastIndexOf('.');
|
||||
return dot > 0 ? fileName.substring(0, dot) : fileName;
|
||||
}
|
||||
|
||||
private boolean isPdf(String fileName) {
|
||||
return ".pdf".equalsIgnoreCase(extractExtension(fileName));
|
||||
}
|
||||
|
||||
private Path templateDir(Integer reviewType) {
|
||||
return getBaseDir()
|
||||
.resolve(String.valueOf(reviewType))
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
private void validateReviewTemplateType(Integer reviewType) {
|
||||
if (!REVIEW_TYPE.contains(reviewType)) {
|
||||
throw BusinessException.badRequest("INVALID_REVIEW_TEMPLATE_TYPE", "유효하지 않은 평가양식 타입입니다.")
|
||||
.with("reviewType", reviewType);
|
||||
}
|
||||
}
|
||||
|
||||
private String sanitizeFileName(String originalFileName) {
|
||||
if (StringUtil.isNullOrBlank(originalFileName)) {
|
||||
return "review-template";
|
||||
}
|
||||
|
||||
return Path.of(originalFileName).getFileName().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,525 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.MONITORING_USER_ROLE;
|
||||
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.SYSTEM_USER_NAME;
|
||||
import static com.kri.kmusical.manage.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.kmusical.manage.back.common.util.ExcelUploadResultUtil;
|
||||
import com.kri.kmusical.manage.back.common.util.TelUtil;
|
||||
import com.kri.kmusical.manage.back.dto.auth.LoginRequestDto;
|
||||
import com.kri.kmusical.manage.back.dto.common.CodeDto;
|
||||
import com.kri.kmusical.manage.back.dto.common.DataVerificationDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.ExcelErrorDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.user.MonitoringUserUploadDto;
|
||||
import com.kri.kmusical.manage.back.dto.excel.user.UserUploadBaseDto;
|
||||
import com.kri.kmusical.manage.back.dto.user.UserCompactDto;
|
||||
import com.kri.kmusical.manage.back.dto.user.UserFullDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TUserDetailEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TUserEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.UserDetailRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.UserRepository;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final UserDetailRepository userDetailRepository;
|
||||
private final CodeService codeService;
|
||||
private final AssignService assignService;
|
||||
private final ReviewService reviewService;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
public byte[] exportUser(Integer userRole, String[] userIds) {
|
||||
validateUserRole(userRole);
|
||||
return exportUser(userRole, getUserUploadClass(userRole), userIds);
|
||||
}
|
||||
|
||||
private Class<? extends UserUploadBaseDto> getUserUploadClass(Integer userRole) {
|
||||
return MonitoringUserUploadDto.class;
|
||||
}
|
||||
|
||||
private <T> byte[] exportUserTemplate(Integer userRole, Class<T> clazz) {
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(Collections.emptyList(), clazz);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("사용자 업로드 템플릿 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends UserUploadBaseDto> byte[] exportUser(Integer userRole, Class<T> clazz, String[] userIds) {
|
||||
Set<String> selectedUserIds = userIds == null
|
||||
? Collections.emptySet()
|
||||
: Arrays.stream(userIds).collect(Collectors.toSet());
|
||||
|
||||
List<UserFullDto> userList = getUserList(userRole).stream()
|
||||
.filter(user -> selectedUserIds.contains(user.getUserId()))
|
||||
.toList();
|
||||
List<T> exportRows = userList.stream()
|
||||
.map(user -> toUserUploadRow(clazz, user))
|
||||
.toList();
|
||||
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(exportRows, clazz);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("사용자 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends UserUploadBaseDto> T toUserUploadRow(Class<T> clazz, UserFullDto user) {
|
||||
if (clazz == MonitoringUserUploadDto.class) {
|
||||
return clazz.cast(MonitoringUserUploadDto.builder()
|
||||
.userId(user.getUserId())
|
||||
.userPw(user.getUserPw())
|
||||
.userName(user.getUserName())
|
||||
.userCmpn(getUserDetailValue(user, "userCmpn"))
|
||||
.userGrade(getUserDetailValue(user, "userGrade"))
|
||||
.userTel(getUserDetailValue(user, "userTel"))
|
||||
.userEmail(getUserDetailValue(user, "userEmail"))
|
||||
.memo(user.getMemo())
|
||||
.build());
|
||||
}
|
||||
|
||||
throw BusinessException.internalError("지원하지 않는 사용자 엑셀 형식입니다.");
|
||||
}
|
||||
|
||||
private String getUserDetailValue(UserFullDto user, String key) {
|
||||
return getUserDetail(user).get(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package com.kri.kmusical.manage.back.service.common;
|
||||
|
||||
import static com.kri.common.feature.json.JsonUtil.toMap;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.kmusical.manage.back.common.enums.SystemEventType;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceCompactDto;
|
||||
import com.kri.kmusical.manage.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.kmusical.manage.back.dto.user.UserFullDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TSysEventLogEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.SysEventLogRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
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 writeUploadReviewFileLog(String regId, LocalDateTime regDt, String clientIp,
|
||||
String performanceId, Integer reviewSlot, UploadContentDto content){
|
||||
writeSystemLog(
|
||||
SystemEventType.UPLOAD_REVIEW,
|
||||
"Upload Review",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"reviewSlot", reviewSlot,
|
||||
"UploadContent", content
|
||||
)
|
||||
);
|
||||
}
|
||||
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, String performanceId) {
|
||||
writeSystemLog(
|
||||
SystemEventType.DELETE_USER,
|
||||
"Delete User",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"performanceId",
|
||||
performanceId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignConfirmByAdminLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String assignUser
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.ASSIGN_PERFORMANCE_CONFIRM,
|
||||
"Assign Confirm",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"reviewSlot", reviewSlot,
|
||||
"assignUser", assignUser
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignCancelLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String assignUser
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.ASSIGN_PERFORMANCE_CANCEL,
|
||||
"Assign Cancel",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"reviewSlot", reviewSlot,
|
||||
"assignUser", assignUser
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.kri.kmusical.manage.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.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
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(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
||||
|
||||
return prefix + "_" + timestamp + "_" + baseName + ext;
|
||||
}
|
||||
|
||||
protected String buildFileNameWithTime(MultipartFile file, LocalDateTime now) {
|
||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
||||
String baseName = extractBaseName(original);
|
||||
String ext = extractExtension(original);
|
||||
String timestamp = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd_hhmmss"));
|
||||
|
||||
return 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","잘못된 파일 경로입니다.");
|
||||
}
|
||||
|
||||
Files.deleteIfExists(target);
|
||||
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);
|
||||
}
|
||||
}
|
||||
14
src/main/resources/application-dev.yml
Normal file
14
src/main/resources/application-dev.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
spring:
|
||||
datasource:
|
||||
#private 도메인
|
||||
url: jdbc:mysql://db-md87m.vpc-cdb.ntruss.com:3306/test_kmusical_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
|
||||
username: prjct_gokams
|
||||
password: gokams#260907
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
kon:
|
||||
survey-type: TEST
|
||||
|
||||
kri:
|
||||
file:
|
||||
pdf-converter-command: /usr/bin/soffice
|
||||
32
src/main/resources/application-local.yml
Normal file
32
src/main/resources/application-local.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
spring:
|
||||
datasource:
|
||||
#public 도메인
|
||||
url: jdbc:mysql://db-md87m-kr.vpc-pub-cdb.ntruss.com:3306/test_kmusical_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
|
||||
username: prjct_gokams
|
||||
password: gokams#260907
|
||||
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
|
||||
|
||||
kon:
|
||||
survey-type: TEST
|
||||
|
||||
kri:
|
||||
file:
|
||||
pdf-converter-command: "C:/Program Files/LibreOffice/program/soffice.exe"
|
||||
14
src/main/resources/application-prod.yml
Normal file
14
src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
spring:
|
||||
datasource:
|
||||
#private 도메인
|
||||
url: jdbc:mysql://db-md87m.vpc-cdb.ntruss.com:3306/prjct_kmusical_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
|
||||
username: prjct_gokams
|
||||
password: gokams#260907
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
kon:
|
||||
survey-type: BANNER
|
||||
|
||||
kri:
|
||||
file:
|
||||
pdf-converter-command: /usr/bin/soffice
|
||||
84
src/main/resources/application.yml
Normal file
84
src/main/resources/application.yml
Normal file
@@ -0,0 +1,84 @@
|
||||
server:
|
||||
port: 6113
|
||||
forward-headers-strategy: framework
|
||||
tomcat:
|
||||
max-http-form-post-size: 500MB
|
||||
max-swallow-size: -1
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: k-musical-manage-back
|
||||
profiles:
|
||||
default: local
|
||||
jpa:
|
||||
open-in-view: false
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
properties:
|
||||
hibernate:
|
||||
jdbc:
|
||||
batch_size: 1000
|
||||
order_inserts: true
|
||||
order_updates: true
|
||||
format_sql: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
|
||||
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.kmusical.manage.back.dto.kon
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
springdoc:
|
||||
writer-with-order-by-keys: true
|
||||
swagger-ui:
|
||||
tags-sorter: alpha
|
||||
operations-sorter: method
|
||||
|
||||
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/performance/list
|
||||
- /api/v1/code/*
|
||||
|
||||
swagger:
|
||||
enabled: true
|
||||
title: "k-musical-manage-back API"
|
||||
description: "k-musical-manage-back Spring Boot application"
|
||||
version: "v1.0.0"
|
||||
base-package: "com.kri.kmusical.manage.back"
|
||||
allowed-ips:
|
||||
- 211.254.145.130
|
||||
file:
|
||||
review-base-dir: ./upload-file/review
|
||||
review-template-base-dir: ./upload-file/review-template
|
||||
resource-pattern: /files/**
|
||||
pdf-converter-command: soffice
|
||||
|
||||
web:
|
||||
enabled: true # 공통 Web 구성 사용 여부 (기본 true)
|
||||
redis:
|
||||
enabled: false # RedisQueueHelper 사용 시 true
|
||||
scheduling:
|
||||
enabled: false # @Scheduled 사용 시 true
|
||||
40
src/main/resources/mybatis/mapper/kon/KonMapper.xml
Normal file
40
src/main/resources/mybatis/mapper/kon/KonMapper.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.kri.kmusical.manage.back.persistence.mapper.kon.KonMapper">
|
||||
<sql id="BaseDataSelect">
|
||||
SELECT DISTINCT
|
||||
JSON_VALUE(DJ.[VALUE], '$.SC') AS IDKEY,
|
||||
DV.[value] AS performance_id
|
||||
FROM [DATA] DA WITH(NOLOCK)
|
||||
CROSS APPLY OPENJSON([DATJSON]) DJ
|
||||
CROSS APPLY OPENJSON(DJ.[value]) DV
|
||||
WHERE PKEY = '2605013_B'
|
||||
AND [Status] = 10
|
||||
AND JSON_VALUE(DJ.[VALUE], '$.SC') IS NOT NULL
|
||||
AND JSON_VALUE(DJ.[VALUE], '$.SC') != ''
|
||||
AND DV.[KEY] LIKE 'Q1%'
|
||||
AND [SURVEY_TYPE] = #{surveyType}
|
||||
</sql>
|
||||
|
||||
<select id="findPerformanceApplyCount" resultType="PerformanceApplyCountDto">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
)
|
||||
SELECT performance_id, COUNT(1) AS apply_cnt
|
||||
FROM Base
|
||||
GROUP BY performance_id
|
||||
</select>
|
||||
|
||||
<select id="findPerformanceApplyUser" resultType="PerformanceApplyUserDto">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
)
|
||||
SELECT performance_id, IDKEY AS user_id
|
||||
FROM Base
|
||||
WHERE performance_id = #{performanceId}
|
||||
GROUP BY performance_id, IDKEY
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kmusical.manage.back;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class PackageStructureTest {
|
||||
|
||||
@Test
|
||||
void templateIsGenerated() {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.kri.kmusical.manage.back.service;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kmusical.manage.back.dto.performance.PerformanceAssignDto;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceAssignEntity;
|
||||
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceAssignEntityId;
|
||||
import com.kri.kmusical.manage.back.persistence.mapper.kon.KonMapper;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceAssignRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewSlotRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.UserDetailRepository;
|
||||
import com.kri.kmusical.manage.back.persistence.repository.UserRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AssignServiceTest {
|
||||
|
||||
@Mock private PerformanceAssignRepository assignRepository;
|
||||
@Mock private PerformanceReviewRepository reviewRepository;
|
||||
@Mock private PerformanceReviewSlotRepository reviewSlotRepository;
|
||||
@Mock private KonMapper konMapper;
|
||||
@Mock private PerformanceRepository performanceRepository;
|
||||
@Mock private UserRepository userRepository;
|
||||
@Mock private UserDetailRepository userDetailRepository;
|
||||
|
||||
private AssignService assignService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
assignService = new AssignService(
|
||||
assignRepository,
|
||||
reviewRepository,
|
||||
reviewSlotRepository,
|
||||
konMapper,
|
||||
performanceRepository,
|
||||
userRepository,
|
||||
userDetailRepository
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void confirmsUserForReviewSlot() {
|
||||
LocalDateTime now = LocalDateTime.of(2026, 9, 8, 12, 0);
|
||||
when(performanceRepository.existsById("PF-001")).thenReturn(true);
|
||||
when(reviewSlotRepository.existsById(2)).thenReturn(true);
|
||||
when(userRepository.existsByUserId("reviewer")).thenReturn(true);
|
||||
when(assignRepository.findByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
|
||||
.thenReturn(Optional.empty());
|
||||
when(assignRepository.save(any(TPerformanceAssignEntity.class)))
|
||||
.thenAnswer(invocation -> invocation.getArgument(0));
|
||||
|
||||
PerformanceAssignDto result = assignService.confirmAssign(
|
||||
"PF-001", 2, "reviewer", "admin", now
|
||||
);
|
||||
|
||||
assertThat(result.getPerformanceId()).isEqualTo("PF-001");
|
||||
assertThat(result.getReviewSlot()).isEqualTo(2);
|
||||
assertThat(result.getAssignUser()).isEqualTo("reviewer");
|
||||
assertThat(result.getAssignStatus()).isEqualTo((short) 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsReplacementAfterReviewStarted() {
|
||||
TPerformanceAssignEntity current = assignment("PF-001", 2, "old-reviewer");
|
||||
when(performanceRepository.existsById("PF-001")).thenReturn(true);
|
||||
when(reviewSlotRepository.existsById(2)).thenReturn(true);
|
||||
when(userRepository.existsByUserId("new-reviewer")).thenReturn(true);
|
||||
when(assignRepository.findByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
|
||||
.thenReturn(Optional.of(current));
|
||||
when(reviewRepository.existsByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
|
||||
.thenReturn(true);
|
||||
|
||||
assertThatThrownBy(() -> assignService.confirmAssign(
|
||||
"PF-001", 2, "new-reviewer", "admin", LocalDateTime.now()
|
||||
)).isInstanceOf(BusinessException.class);
|
||||
|
||||
verify(assignRepository, never()).save(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cancelsSlotAssignmentBeforeReviewStarts() {
|
||||
TPerformanceAssignEntity current = assignment("PF-001", 2, "reviewer");
|
||||
when(assignRepository.findByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
|
||||
.thenReturn(Optional.of(current));
|
||||
|
||||
assignService.cancelAssign("PF-001", 2);
|
||||
|
||||
verify(assignRepository).delete(current);
|
||||
}
|
||||
|
||||
private TPerformanceAssignEntity assignment(
|
||||
String performanceId,
|
||||
Integer reviewSlot,
|
||||
String assignUser
|
||||
) {
|
||||
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
|
||||
entity.setId(new TPerformanceAssignEntityId(performanceId, reviewSlot));
|
||||
entity.setAssignUser(assignUser);
|
||||
entity.setAssignStatus((short) 1);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user