Merge branch 'refs/heads/dev' into first_open_fetch
# Conflicts: # core/src/test/java/app/module/core/common/util/AESEncryptUtilTest.java
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package app.module.admin;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
@@ -12,7 +12,6 @@ import app.module.core.usecase.uri.toptier.ports.URITopTierPortIn;
|
||||
import app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -21,6 +20,8 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
|
||||
@@ -3,10 +3,6 @@ package app.module.admin.config.adapters.web.mvc;
|
||||
import app.module.admin.config.adapters.web.interceptor.AdminURIInterceptor;
|
||||
import app.module.core.config.adapters.web.interceptor.URIAuthorizeInterceptor;
|
||||
import app.module.core.config.application.enums.PublicAccess;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -20,6 +16,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class AdminWebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.module.admin.config.application.aop;
|
||||
|
||||
import app.module.core.config.adapters.web.security.domain.CoreRole;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.enums.OperationLogType;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
@@ -9,10 +8,6 @@ import app.module.core.usecase.admin.view.ports.application.domain.AdminView;
|
||||
import app.module.core.usecase.operationlog.save.application.domain.OperationLogSaveCommand;
|
||||
import app.module.core.usecase.operationlog.save.application.port.in.OperationLogSavePortIn;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
@@ -21,6 +16,11 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@@ -63,7 +63,7 @@ public class RoleUpdateAspect {
|
||||
|| currentRoles.stream().anyMatch(item -> !beforeRoles.contains(item))) {
|
||||
createLog = true;
|
||||
}
|
||||
} else if (currentRoles.size() > 0) {
|
||||
} else if (!currentRoles.isEmpty()) {
|
||||
createLog = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package app.module.admin.config.application.batch;
|
||||
|
||||
import app.module.admin.usecase.batchLog.ports.BatchLogPortIn;
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
|
||||
import app.module.core.config.application.logging.SafeLogger;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class BatchLogRunner {
|
||||
SafeLogger safeLogger = new SafeLogger(LoggerFactory.getLogger(BatchLogRunner.class));
|
||||
|
||||
private final BatchLogPortIn batchLogPortIn;
|
||||
|
||||
public void run(BatchLogType batchType, Runnable action) {
|
||||
// 이미 실행 중인지 확인
|
||||
if (batchLogPortIn.exists(batchType)) {
|
||||
safeLogger.warn("[{}] 배치가 이미 실행 중 입니다.", batchType.name());
|
||||
return;
|
||||
}
|
||||
|
||||
// 실행 로그 insert (RUNNING)
|
||||
Long logId = batchLogPortIn.create(batchType);
|
||||
|
||||
try {
|
||||
action.run();
|
||||
// 성공 처리
|
||||
batchLogPortIn.update(logId, "SUCCESS", null);
|
||||
} catch (Exception e) {
|
||||
// 실패 처리
|
||||
batchLogPortIn.update(logId, "FAIL", e.getMessage());
|
||||
safeLogger.error("[{}] 배치 실패: {}", batchType.name(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package app.module.admin.config.application.bean;
|
||||
|
||||
import org.jasypt.encryption.StringEncryptor;
|
||||
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
||||
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class JasyptConfig {
|
||||
@Value("${jasypt.encryptor.password}")
|
||||
private String jasyptPassword;
|
||||
|
||||
@Value("${jasypt.encryptor.algorithm}")
|
||||
private String jasyptAlgorithm;
|
||||
|
||||
@Bean("jasyptStringEncryptor")
|
||||
public StringEncryptor stringEncryptor() {
|
||||
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
|
||||
config.setPassword(jasyptPassword); // 암호화할 때 사용하는 키
|
||||
config.setPoolSize("1"); // 인스턴스 pool
|
||||
config.setAlgorithm(jasyptAlgorithm); // 암호화 알고리즘
|
||||
config.setStringOutputType("base64"); // 인코딩 방식
|
||||
config.setKeyObtentionIterations("1000"); // 반복할 해싱 회수
|
||||
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator"); // salt 생성 클래스
|
||||
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
|
||||
|
||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
||||
encryptor.setConfig(config);
|
||||
return encryptor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package app.module.admin.config.application.bean;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.SpringBootVFS;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@MapperScan(
|
||||
basePackages = { "app.module.admin.**.persistence", "app.module.core.**.persistence" },
|
||||
annotationClass = org.apache.ibatis.annotations.Mapper.class,
|
||||
sqlSessionFactoryRef = "kriSqlSessionFactory")
|
||||
@EnableTransactionManagement
|
||||
public class KRIConfig {
|
||||
|
||||
@Value("${mybatis.mapper-locations.kri}")
|
||||
private String mybatisMapper;
|
||||
|
||||
@Primary
|
||||
@Bean(name = "kriDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.kri")
|
||||
public DataSource kriDataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "kriSqlSessionFactory")
|
||||
public SqlSessionFactory kriSqlSessionFactory(@Qualifier("kriDataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
|
||||
sessionFactoryBean.setVfs(SpringBootVFS.class);
|
||||
configureSqlSessionFactory(sessionFactoryBean, dataSource);
|
||||
return sessionFactoryBean.getObject();
|
||||
}
|
||||
|
||||
protected void configureSqlSessionFactory(SqlSessionFactoryBean sessionFactoryBean, DataSource dataSource) throws IOException {
|
||||
sessionFactoryBean.setDataSource(dataSource);
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
sessionFactoryBean.setMapperLocations(resolver.getResources(mybatisMapper));
|
||||
|
||||
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
|
||||
configuration.setMapUnderscoreToCamelCase(true);
|
||||
sessionFactoryBean.setConfiguration(configuration);
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "kriSqlSessionTemplate")
|
||||
public SqlSessionTemplate kriSqlSessionTemplate(@Qualifier("kriSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||
SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
|
||||
return sqlSessionTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package app.module.admin.config.application.bean;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.SpringBootVFS;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@MapperScan(
|
||||
basePackages = "app.module.mms.**.persistence",
|
||||
annotationClass = org.apache.ibatis.annotations.Mapper.class,
|
||||
sqlSessionFactoryRef = "mmsSqlSessionFactory")
|
||||
@EnableTransactionManagement
|
||||
public class MMSDBConfig {
|
||||
|
||||
@Value("${mybatis.mapper-locations.mms}")
|
||||
private String mybatisMapper;
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.datasource.mms")
|
||||
public DataSource mmsDataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Bean(name = "mmsSqlSessionFactory")
|
||||
public SqlSessionFactory mmsSqlSessionFactory(@Qualifier("mmsDataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
|
||||
sessionFactoryBean.setVfs(SpringBootVFS.class);
|
||||
configureSqlSessionFactory(sessionFactoryBean, dataSource);
|
||||
return sessionFactoryBean.getObject();
|
||||
}
|
||||
|
||||
protected void configureSqlSessionFactory(SqlSessionFactoryBean sessionFactoryBean, DataSource dataSource) throws IOException {
|
||||
sessionFactoryBean.setDataSource(dataSource);
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
sessionFactoryBean.setMapperLocations(resolver.getResources(mybatisMapper));
|
||||
|
||||
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
|
||||
configuration.setMapUnderscoreToCamelCase(true);
|
||||
// configuration.setJdbcTypeForNull(null);
|
||||
sessionFactoryBean.setConfiguration(configuration);
|
||||
}
|
||||
|
||||
@Bean(name = "mmsSqlSessionTemplate")
|
||||
public SqlSessionTemplate mmsSqlSessionTemplate(@Qualifier("mmsSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||
SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
|
||||
return sqlSessionTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.config.application.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum EmploymentType {
|
||||
FULLTIME( "1. 임업전업"),
|
||||
MAIN( "2. 임업주업"),
|
||||
PART( "3. 임업부업");
|
||||
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.config.application.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum ExcelTemplateType {
|
||||
HOUSEHOLD("임가 목록"),
|
||||
DAILY_STATUS("일계부 등록 현황"),
|
||||
VISIT("임가방문정보"),
|
||||
DAILY_RECORD("일계부 등록 데이터");
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.config.application.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum UsageType {
|
||||
MOBILE("모바일웹"),
|
||||
PAPER("지류");
|
||||
private final String desc;
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import app.module.core.usecase.operationlog.save.application.domain.OperationLogSaveCommand;
|
||||
import app.module.core.usecase.operationlog.save.application.port.in.OperationLogSavePortIn;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -21,6 +20,9 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -37,7 +39,7 @@ public class AdminAuthFailEvent {
|
||||
@EventListener
|
||||
public void handleAuthenticationFailureEvent(AbstractAuthenticationFailureEvent event) {
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
|
||||
if (event.getException() instanceof BadCredentialsException) {
|
||||
adminViewPortIn
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package app.module.admin.config.application.security;
|
||||
|
||||
import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserIdSaveCmd;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.logging.SafeLogger;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.status.ports.AdminUpdateLoginFailPortIn;
|
||||
import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserIdSaveCmd;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent;
|
||||
@@ -21,10 +21,13 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AdminAuthSuccessEvent {
|
||||
SafeLogger safeLogger = new SafeLogger(LoggerFactory.getLogger(AdminAuthSuccessEvent.class));
|
||||
|
||||
private final MessageUtil messageUtil;
|
||||
private final AdminViewPortIn adminViewPortIn;
|
||||
@@ -49,7 +52,7 @@ public class AdminAuthSuccessEvent {
|
||||
AdminUser adminUser = (AdminUser) authentication.getPrincipal();
|
||||
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
|
||||
// 로그인 실패 회수 초기화
|
||||
adminViewPortIn
|
||||
@@ -83,6 +86,6 @@ public class AdminAuthSuccessEvent {
|
||||
public void handleAuthenticationFailureEvent(AbstractAuthenticationFailureEvent event) {
|
||||
Exception e = event.getException();
|
||||
Authentication authentication = event.getAuthentication();
|
||||
log.warn("Unsuccessful authentication result: {}", authentication, e);
|
||||
safeLogger.warn("Unsuccessful authentication result: {}", authentication, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,6 @@ import app.module.core.config.adapters.web.security.domain.CorePrivilege;
|
||||
import app.module.core.config.adapters.web.security.domain.CoreRole;
|
||||
import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import app.module.core.usecase.admin.view.ports.application.domain.AdminView;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@@ -19,6 +14,12 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminDetailsService implements UserDetailsService {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package app.module.admin.config.application.security;
|
||||
|
||||
import app.module.core.config.application.enums.PublicAccess;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
||||
@@ -21,11 +17,14 @@ import org.springframework.security.core.session.SessionRegistryImpl;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl;
|
||||
|
||||
import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;
|
||||
import org.springframework.security.web.session.HttpSessionEventPublisher;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@RequiredArgsConstructor
|
||||
@@ -82,7 +81,7 @@ public class AdminSecurityConfig {
|
||||
List<String> permitPaths =
|
||||
Arrays.stream(PublicAccess.values())
|
||||
.map(PublicAccess::getPath)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
http.authorizeHttpRequests(
|
||||
(auth) ->
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package app.module.admin.config.application.security;
|
||||
|
||||
import java.util.Collection;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AdminUser extends User {
|
||||
private Long seq;
|
||||
private String roleId;
|
||||
|
||||
@@ -2,12 +2,12 @@ package app.module.admin.config.application.util;
|
||||
|
||||
import app.module.admin.config.application.security.AdminUser;
|
||||
import app.module.core.config.adapters.web.interceptor.model.URITopTierVO;
|
||||
import java.util.List;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class AdminUtil {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AdminUtil {
|
||||
}
|
||||
|
||||
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||
return user.getRegionMainCode().isEmpty() ? null : user.getRegionMainCode();
|
||||
return user.getRegionMainCode() == null ? null : user.getRegionMainCode();
|
||||
}
|
||||
|
||||
public static String getLoginUserLastIp() {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package app.module.admin.config.application.util;
|
||||
|
||||
import app.module.admin.config.application.util.model.DayRange;
|
||||
import app.module.admin.config.application.util.model.MonthOption;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class DateUiUtil {
|
||||
@@ -30,4 +33,45 @@ public class DateUiUtil {
|
||||
public static String getCurrentMonthValue() {
|
||||
return LocalDate.now().format(VALUE_FORMAT);
|
||||
}
|
||||
|
||||
public static String getMonthValue(LocalDate date) {
|
||||
return date.format(VALUE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자 자동 발송 대상 날짜 범위를 반환합니다.
|
||||
*
|
||||
* 발송일 기준으로 대상자 범위를 계산합니다.
|
||||
* 발송일은 매월 8일, 15일, 22일, 다음 달 1일이며,
|
||||
* 각 발송일마다 고정된 날짜 구간이 대상자 범위로 설정됩니다.
|
||||
*
|
||||
* 예시:
|
||||
* - 8일인 경우 → 1일부터 7일 까지
|
||||
* - 15일인 경우 → 8일부터 14일 까지
|
||||
* - 22일인 경우 → 15일부터 21일 까지
|
||||
* - 다음 달 1일인 경우 → 전달의 22일 부터 28,30,31일 까지
|
||||
*
|
||||
* 발송일이 아닌 경우에는 빈 Optional을 반환합니다.
|
||||
*
|
||||
* @param today 현재 날짜
|
||||
* @return DayRange 객체 또는 발송일이 아니면 Optional.empty()
|
||||
*/
|
||||
public static Optional<DayRange> getDayRange(LocalDate today) {
|
||||
int day = today.getDayOfMonth();
|
||||
|
||||
if (day == 8) {
|
||||
return Optional.of(new DayRange(1, 7));
|
||||
} else if (day == 15) {
|
||||
return Optional.of(new DayRange(8, 14));
|
||||
} else if (day == 22) {
|
||||
return Optional.of(new DayRange(15, 21));
|
||||
} else if (day == 1) {
|
||||
// 다음 달 1일 → 전달 22~말일까지
|
||||
LocalDate prevMonth = today.minusMonths(1);
|
||||
int prevLastDay = prevMonth.lengthOfMonth();
|
||||
return Optional.of(new DayRange(22, prevLastDay));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ public class ExcelWriterUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.setColumnWidth(col, (maxLength + 2) * 256);
|
||||
// sheet.setColumnWidth(col, (maxLength + 2) * 256);
|
||||
sheet.setColumnWidth(col, Math.min((maxLength + 2) * 256, 20000)); // 최대 너비 제한
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.module.admin.config.application.util.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class DayRange {
|
||||
private int fromDay;
|
||||
private int toDay;
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package app.module.admin.config.application.util.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ExcelSheetDto {
|
||||
/**
|
||||
* 시트명
|
||||
@@ -36,10 +40,4 @@ public class ExcelSheetDto {
|
||||
this.commaColumns = commaColumns;
|
||||
this.headerBgColors = headerBgColors;
|
||||
}
|
||||
|
||||
public String getSheetName() { return sheetName; }
|
||||
public List<String> getHeaders() { return headers; }
|
||||
public List<List<String>> getData() { return data; }
|
||||
public Set<Integer> getCommaColumns() { return commaColumns; }
|
||||
public Map<Integer, IndexedColors> getHeaderBgColors() { return headerBgColors; }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.admin.usecase.admin.checkAdminId.adapters.web;
|
||||
|
||||
import app.module.core.config.constants.CommonConstants;
|
||||
import app.module.core.usecase.admin.checkAdminId.ports.CheckAdminIdPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -18,6 +19,12 @@ class AdminIdDuplicateCheckPostController {
|
||||
|
||||
@GetMapping("/api/settings/admin/idCheck")
|
||||
ResponseEntity<?> selectIdCheck(@RequestParam String id ) {
|
||||
if (!id.matches(CommonConstants.ADMIN_ID_REGEX)) {
|
||||
return ResponseEntity
|
||||
.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(CommonConstants.ADMIN_ID_MSG);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(checkAdminIdPortIn.connect(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ import app.module.core.usecase.admin.getAdmins.ports.application.domain.GetAdmin
|
||||
import app.module.core.usecase.admin.getAdmins.ports.application.domain.GetAdminsCmd;
|
||||
import app.module.core.usecase.admin.getAdmins.ports.application.domain.GetAdminsRole;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@@ -23,6 +20,10 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class AdminExcelController {
|
||||
|
||||
@@ -2,7 +2,6 @@ package app.module.admin.usecase.admin.removeAdmins.adapters.web;
|
||||
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.removeAdmin.ports.RemoveAdminPortIn;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -10,6 +9,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class AdminRemoveController {
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
package app.module.admin.usecase.admin.removeAdmins.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.admin.removeAdmins.adapters.web.model.RemoveAdminsReqVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.removeAdmin.ports.RemoveAdminPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package app.module.admin.usecase.admin.removeAdmins.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -8,7 +8,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -2,22 +2,15 @@ package app.module.admin.usecase.admin.saveAdmin.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminCreateBindingVO;
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.validator.AdminCreateValidator;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.saveAdmin.ports.SaveAdminPortIn;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
||||
@@ -2,7 +2,6 @@ package app.module.admin.usecase.admin.saveAdmin.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.admin.getAdmins.adapters.web.model.AdminListFilterVO;
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminUpdateBindingVO;
|
||||
import app.module.core.config.adapters.web.security.domain.CoreRole;
|
||||
import app.module.core.config.application.component.ListPageableInfo;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
@@ -10,8 +9,6 @@ import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import app.module.core.usecase.admin.view.ports.application.domain.AdminView;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -19,6 +16,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class AdminUpdateGetController {
|
||||
|
||||
@@ -2,25 +2,14 @@ package app.module.admin.usecase.admin.saveAdmin.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminUpdateBindingVO;
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.validator.AdminUpdateValidator;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.saveAdmin.ports.SaveAdminPortIn;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -28,4 +27,5 @@ public class AdminCreateBindingVO {
|
||||
private Boolean accountDisabled;
|
||||
/* private Boolean accountLocked;*/
|
||||
private String roleId;
|
||||
private Boolean checkDuplicate;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.validator;
|
||||
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminCreateBindingVO;
|
||||
import java.util.Optional;
|
||||
import app.module.core.config.constants.CommonConstants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class AdminCreateValidator implements Validator {
|
||||
|
||||
// 아이디: 4~15자, 영문/숫자/한글/특수문자(_,-) 허용
|
||||
private final String ID_REGEX = "^[a-zA-Z0-9가-힣_-]{4,15}$";
|
||||
// 비밀번호: 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상
|
||||
private final String PASSWORD_REGEX = "^(?=.*[0-9])(?=.*[!@#$%_\\-]).{5}$";
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return AdminCreateBindingVO.class.equals(clazz);
|
||||
@@ -24,51 +21,68 @@ public class AdminCreateValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
AdminCreateBindingVO vo = (AdminCreateBindingVO) target;
|
||||
|
||||
if (vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
|
||||
errors.rejectValue("roleId", "error.roleId", "권한을 선택해주세요.");
|
||||
// [1] 필수값 누락 체크
|
||||
if(StringUtils.isBlank(vo.getRoleId())) {
|
||||
errors.rejectValue("roleId", "error.roleId", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isBlank(vo.getId())) {
|
||||
errors.rejectValue("id", "error.id", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isBlank(vo.getPassword())) {
|
||||
errors.rejectValue("password", "error.password", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (vo.getAccountDisabled() == null ) {
|
||||
errors.rejectValue("accountDisabled", "error.accountDisabled", "사용여부를 선택해주세요.");
|
||||
}
|
||||
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "valid.common.required","아이디는 필수입력값입니다.");
|
||||
Optional.ofNullable(vo.getId())
|
||||
.filter(id -> !id.matches(ID_REGEX))
|
||||
.ifPresent(id -> errors.rejectValue("id", "valid.common.id.wrong","아이디를 4~15자, 영문/숫자/한글/특수문자(_,-) 입니다."));
|
||||
|
||||
// 비밀번호 유효성 검사
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "valid.common.required","비밀번호는 필수입력값입니다.");
|
||||
|
||||
Optional.ofNullable(vo.getPassword())
|
||||
.filter(password -> !password.matches(PASSWORD_REGEX))
|
||||
.ifPresent(password -> errors.rejectValue("password", "valid.common.password.wrong","비밀번호는 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상입니다."));
|
||||
|
||||
if (vo.getRoleId() != null && "ROLE_RESEARCHER".equals(vo.getRoleId())) {
|
||||
if (vo.getName() == null || vo.getName().isBlank()) {
|
||||
errors.rejectValue("name", "error.name", "이름을 입력해주세요.");
|
||||
// 권한 조사원으로 선택했을 경우
|
||||
if("ROLE_RESEARCHER".equals(vo.getRoleId())) {
|
||||
if(StringUtils.isBlank(vo.getName())) {
|
||||
errors.rejectValue("name", "error.name", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if (vo.getName().length() > 10) {
|
||||
errors.rejectValue("name", "error.name", "이름은 10자까지 입력가능합니다.");
|
||||
if(StringUtils.isBlank(vo.getPhone1())) {
|
||||
errors.rejectValue("phone1", "error.phone1", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if (vo.getPhone1() == null || vo.getPhone1().isBlank()) {
|
||||
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리를 입력해주세요.");
|
||||
} else if (!vo.getPhone1().matches("^\\d{4}$")) {
|
||||
if(StringUtils.isBlank(vo.getPhone2())) {
|
||||
errors.rejectValue("phone2", "error.phone2", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if (!vo.getPhone1().matches("^\\d{4}$")) {
|
||||
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리는 4자리 숫자여야 합니다.");
|
||||
return;
|
||||
}
|
||||
if (vo.getPhone2() == null || vo.getPhone2().isBlank()) {
|
||||
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리를 입력해주세요.");
|
||||
} else if (!vo.getPhone2().matches("^\\d{4}$")) {
|
||||
if (!vo.getPhone2().matches("^\\d{4}$")) {
|
||||
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리는 4자리 숫자여야 합니다.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
||||
|
||||
if(vo.getAccountDisabled() == null) {
|
||||
errors.rejectValue("accountDisabled", "error.accountDisabled", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
// ROLE_ADMIN이 아닌 경우 실사지역 null체크
|
||||
Optional.ofNullable(vo.getRoleId())
|
||||
.filter(id -> !id.equals("ROLE_ADMIN"))
|
||||
.ifPresent(nonAdmins -> {
|
||||
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
||||
errors.rejectValue("regionMainCode", "valid.common.required","실사지역은 필수입력값입니다.");
|
||||
errors.rejectValue("regionMainCode", "valid.common.required","필수입력항목을 확인해주세요.");
|
||||
}
|
||||
});
|
||||
|
||||
// [2] 아이디 중복 확인 여부
|
||||
if (vo.getCheckDuplicate() == null || !vo.getCheckDuplicate()) {
|
||||
errors.rejectValue("checkDuplicate", "error.checkDuplicate", "아이디 중복 확인을 먼저 진행해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
// [3] 비밀번호 형식 검사
|
||||
if (!vo.getPassword().matches(CommonConstants.ADMIN_PASSWORD_REGEX)) {
|
||||
errors.rejectValue("password", "valid.common.password.wrong",
|
||||
CommonConstants.ADMIN_PASSWORD_MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.validator;
|
||||
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminUpdateBindingVO;
|
||||
import java.util.Optional;
|
||||
import app.module.core.config.constants.CommonConstants;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class AdminUpdateValidator implements Validator {
|
||||
|
||||
// 비밀번호: 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상
|
||||
private final String PASSWORD_REGEX = "^(?=.*[0-9])(?=.*[!@#$%_\\-]).{5}$";
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return AdminUpdateBindingVO.class.equals(clazz);
|
||||
@@ -22,39 +20,54 @@ public class AdminUpdateValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
AdminUpdateBindingVO vo = (AdminUpdateBindingVO) target;
|
||||
|
||||
if (vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
|
||||
errors.rejectValue("roleId", "error.roleId", "권한을 선택해주세요.");
|
||||
// [1] 필수값 누락 체크
|
||||
if(vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
|
||||
errors.rejectValue("roleId", "error.roleId", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
Optional.ofNullable(vo.getUpdatePassword())
|
||||
.filter(password -> !password.trim().isEmpty() && !password.matches(PASSWORD_REGEX))
|
||||
.ifPresent(password -> errors.rejectValue("updatePassword", "valid.common.password.wrong","비밀번호는 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상입니다."));
|
||||
|
||||
if (vo.getRoleId() != null && "ROLE_RESEARCHER".equals(vo.getRoleId())) {
|
||||
if (vo.getName() == null || vo.getName().isBlank()) {
|
||||
errors.rejectValue("name", "error.name", "이름을 입력해주세요.");
|
||||
// 권한 조사원으로 선택했을 경우
|
||||
if(vo.getRoleId() != null && "ROLE_RESEARCHER".equals(vo.getRoleId())) {
|
||||
if(vo.getName() == null || vo.getName().isEmpty()) {
|
||||
errors.rejectValue("name", "error.name", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if (vo.getName().length() > 10) {
|
||||
errors.rejectValue("name", "error.name", "이름은 10자까지 입력가능합니다.");
|
||||
if(vo.getPhone1() == null || vo.getPhone1().isBlank()) {
|
||||
errors.rejectValue("phone1", "error.phone1", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if (vo.getPhone1() == null || vo.getPhone1().isBlank()) {
|
||||
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리를 입력해주세요.");
|
||||
} else if (!vo.getPhone1().matches("^\\d{4}$")) {
|
||||
if(vo.getPhone2() == null || vo.getPhone2().isBlank()) {
|
||||
errors.rejectValue("phone2", "error.phone2", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
if (!vo.getPhone1().matches("^\\d{4}$")) {
|
||||
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리는 4자리 숫자여야 합니다.");
|
||||
return;
|
||||
}
|
||||
if (vo.getPhone2() == null || vo.getPhone2().isBlank()) {
|
||||
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리를 입력해주세요.");
|
||||
} else if (!vo.getPhone2().matches("^\\d{4}$")) {
|
||||
if (!vo.getPhone2().matches("^\\d{4}$")) {
|
||||
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리는 4자리 숫자여야 합니다.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
||||
|
||||
// 사용여부
|
||||
if(vo.getAccountDisabled() == null) {
|
||||
errors.rejectValue("accountDisabled", "error.accountDisabled", "필수입력항목을 확인해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
// ROLE_ADMIN이 아닌 경우 실사지역 null체크
|
||||
Optional.ofNullable(vo.getRoleId())
|
||||
.filter(id -> !id.equals("ROLE_ADMIN"))
|
||||
.ifPresent(nonAdmins -> {
|
||||
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
||||
errors.rejectValue("regionMainCode", "valid.common.required","실사지역을 선택해주세요.");
|
||||
errors.rejectValue("regionMainCode", "valid.common.required","필수입력항목을 확인해주세요.");
|
||||
}
|
||||
});
|
||||
|
||||
// [3] 비밀번호 형식 검사
|
||||
if ((vo.getUpdatePassword() != "" && vo.getUpdatePassword() != null )&& !vo.getUpdatePassword().matches(CommonConstants.ADMIN_PASSWORD_REGEX)){
|
||||
errors.rejectValue("updatePassword", "valid.common.password.wrong", CommonConstants.ADMIN_PASSWORD_MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package app.module.admin.usecase.article.createArticle.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.createArticle.adapters.web.model.CreateArticleReqVO;
|
||||
import app.module.admin.usecase.article.createArticle.adapters.web.validator.CreateArticleValidator;
|
||||
import app.module.core.usecase.article.createArticle.ports.CreateArticlePortIn;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticle;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class CreateArticleController {
|
||||
|
||||
private final CreateArticlePortIn createArticlePortIn;
|
||||
private final CreateArticleValidator createArticleValidator;
|
||||
|
||||
@PostMapping(path = "/api/board/articles/create")
|
||||
ResponseEntity<?> operate(@Valid CreateArticleReqVO reqVO, BindingResult bindingResult) {
|
||||
|
||||
createArticleValidator.validate(reqVO, bindingResult);
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
CreateArticle article =
|
||||
createArticlePortIn
|
||||
.operate(
|
||||
new CreateArticleCmd(
|
||||
reqVO.getTitle(),
|
||||
reqVO.getContent(),
|
||||
reqVO.getVisible(),
|
||||
reqVO.getStartDate(),
|
||||
reqVO.getEndDate(),
|
||||
reqVO.getFileMappingId()))
|
||||
.orElseThrow();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(article);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package app.module.admin.usecase.article.createArticle.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleReqVO {
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String title;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String content;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Boolean visible;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private List<String> fileMappingId;
|
||||
|
||||
public String getTitle() {
|
||||
return StringEscapeUtils.escapeHtml4(title);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return StringEscapeUtils.escapeHtml4(content);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package app.module.admin.usecase.article.createArticle.adapters.web.validator;
|
||||
|
||||
import app.module.admin.usecase.article.createArticle.adapters.web.model.CreateArticleReqVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CreateArticleValidator implements Validator {
|
||||
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return CreateArticleReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateArticleReqVO vo = (CreateArticleReqVO) target;
|
||||
|
||||
LocalDateTime startDate = vo.getStartDate();
|
||||
LocalDateTime endDate = vo.getEndDate();
|
||||
|
||||
// 게시일 날짜 체크
|
||||
if (startDate == null) {
|
||||
errors.rejectValue(
|
||||
"startDate", "valid.common.required",
|
||||
messageUtil.getMessage("valid.common.required"));
|
||||
}
|
||||
|
||||
if (endDate == null) {
|
||||
errors.rejectValue(
|
||||
"endDate", "valid.common.required",
|
||||
messageUtil.getMessage("valid.common.required"));
|
||||
}
|
||||
|
||||
if (startDate != null && endDate != null) {
|
||||
if (!startDate.isBefore(endDate)) {
|
||||
errors.rejectValue(
|
||||
"startDate",
|
||||
"valid.common.date.invalid",
|
||||
messageUtil.getMessage("valid.common.date.invalid"));
|
||||
errors.rejectValue(
|
||||
"endDate",
|
||||
"valid.common.date.invalid",
|
||||
messageUtil.getMessage("valid.common.date.invalid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticle.adapters.web;
|
||||
|
||||
import app.module.core.usecase.article.getArticle.ports.GetArticlePortIn;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleController {
|
||||
|
||||
private final GetArticlePortIn getArticlePortIn;
|
||||
|
||||
@GetMapping(path = "/api/board/articles/{id}")
|
||||
ResponseEntity<?> operate(@PathVariable Long id) {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(getArticlePortIn.operate(new GetArticleCmd(id)).orElseThrow());
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticleCreateUI.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.getArticleCreateUI.adapters.web.model.CreateArticleUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class CreateArticleUIController {
|
||||
|
||||
@GetMapping(path = "/board/articles/create")
|
||||
String operate(
|
||||
Model model,
|
||||
@ModelAttribute("reqVO") CreateArticleUIReqVO reqVO) {
|
||||
|
||||
return "board/articles/create";
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticleUpdateUI.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.getArticleUpdateUI.adapters.web.model.GetArticleUpdateUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleUpdateUIController {
|
||||
|
||||
@GetMapping(path = "/board/articles/{id}")
|
||||
String operate(
|
||||
Model model,
|
||||
@PathVariable @ModelAttribute("id") Long id,
|
||||
@ModelAttribute("reqVO") GetArticleUpdateUIReqVO reqVO) {
|
||||
|
||||
return "board/articles/{id}";
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticles.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.getArticles.adapters.web.model.GetArticlesReqVO;
|
||||
import app.module.core.usecase.article.getArticles.ports.GetArticlesPortIn;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticles;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticlesCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetArticlesController {
|
||||
|
||||
private final GetArticlesPortIn getArticlesPortIn;
|
||||
|
||||
@GetMapping(path = "/api/board/articles")
|
||||
ResponseEntity<?> operate(@PageableDefault Pageable pageable, GetArticlesReqVO reqVO) {
|
||||
Page<GetArticles> articles =
|
||||
getArticlesPortIn.operate(
|
||||
pageable,
|
||||
new GetArticlesCmd(
|
||||
reqVO.getSearchField(), reqVO.getSearchValue(), reqVO.getSearchOpen()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(articles);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticles.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticlesReqVO {
|
||||
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String searchOpen;
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticlesExcel.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.getArticlesExcel.adapters.web.model.GetArticlesExcelReqVO;
|
||||
import app.module.core.usecase.article.getArticles.ports.GetArticlesPortIn;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticles;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticlesCmd;
|
||||
import app.module.core.usecase.excel.createCell.ports.CreateCellPortIn;
|
||||
import app.module.core.usecase.excel.createCell.ports.application.model.CellConfig;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetArticlesExcelController {
|
||||
|
||||
private final GetArticlesPortIn getArticlesPortIn;
|
||||
private final CreateCellPortIn createCellPortIn;
|
||||
|
||||
@GetMapping(path = "/api/board/articles/excel")
|
||||
void operate(
|
||||
@PageableDefault(size = Integer.MAX_VALUE) Pageable pageable,
|
||||
GetArticlesExcelReqVO reqVO,
|
||||
HttpServletResponse response)
|
||||
throws IOException {
|
||||
|
||||
String title = "예제 게시판 목록";
|
||||
|
||||
Page<GetArticles> output =
|
||||
getArticlesPortIn.operate(
|
||||
pageable,
|
||||
new GetArticlesCmd(
|
||||
reqVO.getSearchField(), reqVO.getSearchValue(), reqVO.getSearchOpen()));
|
||||
|
||||
if (!output.getContent().isEmpty()) {
|
||||
|
||||
// 1000 개 로우가 넘으면 디스크에 기록한다.
|
||||
try (SXSSFWorkbook wb = new SXSSFWorkbook(1000)) {
|
||||
SXSSFSheet sheet = wb.createSheet(title);
|
||||
sheet.trackAllColumnsForAutoSizing();
|
||||
|
||||
AtomicInteger colNo = new AtomicInteger(0);
|
||||
|
||||
// 상단 Header 생성 및 필터 적용
|
||||
createCellPortIn.operate(
|
||||
// 상단 Header 의 Row 목록 - 2개 이상이면 병합이 가능해진다.
|
||||
List.of(sheet.createRow(sheet.getPhysicalNumberOfRows())),
|
||||
// 상단 Header Row 를 구성하는 col 목록
|
||||
List.of(
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
"제목",
|
||||
createCellPortIn.getDefaultHeaderStyle(wb, HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
"공개여부",
|
||||
createCellPortIn.getDefaultHeaderStyle(wb, HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
"게시일",
|
||||
createCellPortIn.getDefaultHeaderStyle(wb, HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
"종료일",
|
||||
createCellPortIn.getDefaultHeaderStyle(wb, HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
"최근 수정자",
|
||||
createCellPortIn.getDefaultHeaderStyle(wb, HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
"최근 수정일",
|
||||
createCellPortIn.getDefaultHeaderStyle(wb, HorizontalAlignment.CENTER),
|
||||
null)));
|
||||
sheet.setAutoFilter(new CellRangeAddress(0, 0, 0, colNo.get() - 1));
|
||||
|
||||
// 본문 데이터
|
||||
output
|
||||
.getContent()
|
||||
.forEach(
|
||||
item -> {
|
||||
colNo.set(0);
|
||||
createCellPortIn.operate(
|
||||
List.of(sheet.createRow(sheet.getPhysicalNumberOfRows())),
|
||||
List.of(
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
item.getTitle(),
|
||||
createCellPortIn.getDefaultDataStyle(wb,
|
||||
HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
item.getVisible() ? "Y" : "N",
|
||||
createCellPortIn.getDefaultDataStyle(wb,
|
||||
HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
item.getStartDate()
|
||||
.format(
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||
createCellPortIn.getDefaultDataStyle(wb,
|
||||
HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
item.getEndDate()
|
||||
.format(
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||
createCellPortIn.getDefaultDataStyle(wb,
|
||||
HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
item.getUpdatedBy(),
|
||||
createCellPortIn.getDefaultDataStyle(wb,
|
||||
HorizontalAlignment.CENTER),
|
||||
null),
|
||||
new CellConfig(
|
||||
0,
|
||||
colNo.getAndIncrement(),
|
||||
null,
|
||||
CellType.STRING,
|
||||
item.getUpdatedAt()
|
||||
.format(
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||
createCellPortIn.getDefaultDataStyle(wb,
|
||||
HorizontalAlignment.CENTER),
|
||||
null)));
|
||||
});
|
||||
|
||||
// 한글 파일명 처리를 위해 URLEncoder 필요
|
||||
String filename =
|
||||
URLEncoder.encode(
|
||||
String.format(
|
||||
"%s-%s.xlsx",
|
||||
title,
|
||||
new SimpleDateFormat("yyyyMMdd").format(
|
||||
Calendar.getInstance().getTime())),
|
||||
StandardCharsets.UTF_8);
|
||||
|
||||
response.setHeader(
|
||||
HttpHeaders.CONTENT_DISPOSITION,
|
||||
String.format("attachment; filename=\"%s\"", filename));
|
||||
|
||||
wb.write(response.getOutputStream());
|
||||
|
||||
// 디스크에 기록한 임시 파일 제거
|
||||
wb.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticlesExcel.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticlesExcelReqVO {
|
||||
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String searchOpen;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticlesUI.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.getArticlesUI.adapters.web.model.GetArticlesUIReqVO;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetArticlesUIController {
|
||||
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@GetMapping(path = "/board/articles")
|
||||
String operate(@ModelAttribute("reqVO") GetArticlesUIReqVO reqVO, Model model) {
|
||||
|
||||
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
||||
|
||||
return "board/articles";
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticlesUI.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticlesUIReqVO {
|
||||
|
||||
private Integer page;
|
||||
private String sort;
|
||||
private Integer size;
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String searchOpen;
|
||||
|
||||
public Integer getPage() {
|
||||
// 요청 페이지 넘버 - 초기값 `0`
|
||||
return page != null ? page : 0;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
// 정렬 값 - 초기값 `orderNo 내림차순`
|
||||
return StringUtils.isEmpty(sort) ? "orderNo,DESC" : sort;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
// 페이지 당 아이템 수 - 초기값 `10`
|
||||
return size != null ? size : 10;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package app.module.admin.usecase.article.removeArticles.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.removeArticles.adapters.web.model.RemoveArticlesReqVO;
|
||||
import app.module.core.usecase.article.removeArticles.ports.RemoveArticlesPortIn;
|
||||
import app.module.core.usecase.article.removeArticles.ports.application.domain.RemoveArticlesCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RemoveArticlesController {
|
||||
|
||||
private final RemoveArticlesPortIn removeArticlesPortIn;
|
||||
|
||||
@DeleteMapping(path = "/api/board/articles/remove")
|
||||
ResponseEntity<?> operate(@Valid RemoveArticlesReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
removeArticlesPortIn.operate(new RemoveArticlesCmd(reqVO.getSelectIds()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.article.removeArticles.adapters.web.model;
|
||||
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveArticlesReqVO {
|
||||
|
||||
private Set<Long> selectIds;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package app.module.admin.usecase.article.sortArticles.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.sortArticles.adapters.web.model.SortArticlesReqVO;
|
||||
import app.module.core.usecase.article.sortArticles.ports.SortArticlesPortIn;
|
||||
import app.module.core.usecase.article.sortArticles.ports.application.domain.SortArticlesCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class SortArticlesController {
|
||||
|
||||
private final SortArticlesPortIn sortArticlesPortIn;
|
||||
|
||||
@PatchMapping(path = "/api/board/articles/sort")
|
||||
ResponseEntity<?> operate(
|
||||
@Valid @RequestBody List<SortArticlesReqVO> reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(bindingResult);
|
||||
}
|
||||
|
||||
sortArticlesPortIn.operate(
|
||||
reqVO.stream()
|
||||
.map(
|
||||
sortArticlesReqVO ->
|
||||
new SortArticlesCmd(sortArticlesReqVO.getId(),
|
||||
sortArticlesReqVO.getOrderNo()))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package app.module.admin.usecase.article.sortArticles.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortArticlesReqVO {
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package app.module.admin.usecase.article.updateArticle.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.article.updateArticle.adapters.web.model.UpdateArticleReqVO;
|
||||
import app.module.admin.usecase.article.updateArticle.adapters.web.validator.UpdateArticleValidator;
|
||||
import app.module.core.usecase.article.updateArticle.ports.UpdateArticlePortIn;
|
||||
import app.module.core.usecase.article.updateArticle.ports.application.domain.UpdateArticleCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class UpdateArticleController {
|
||||
|
||||
private final UpdateArticlePortIn updateArticlePortIn;
|
||||
private final UpdateArticleValidator updateArticleValidator;
|
||||
|
||||
@PutMapping(path = "/api/board/articles/update")
|
||||
ResponseEntity<?> operate(@Valid UpdateArticleReqVO reqVO, BindingResult bindingResult) {
|
||||
|
||||
updateArticleValidator.validate(reqVO, bindingResult);
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
updateArticlePortIn.operate(
|
||||
new UpdateArticleCmd(
|
||||
reqVO.getId(),
|
||||
reqVO.getTitle(),
|
||||
reqVO.getContent(),
|
||||
reqVO.getVisible(),
|
||||
reqVO.getOrderNo(),
|
||||
reqVO.getStartDate(),
|
||||
reqVO.getEndDate(),
|
||||
reqVO.getFileMappingId()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package app.module.admin.usecase.article.updateArticle.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateArticleReqVO {
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String title;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String content;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Boolean visible;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Integer orderNo;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private List<String> fileMappingId;
|
||||
|
||||
public String getTitle() {
|
||||
return StringEscapeUtils.escapeHtml4(title);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return StringEscapeUtils.escapeHtml4(content);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package app.module.admin.usecase.article.updateArticle.adapters.web.validator;
|
||||
|
||||
import app.module.admin.usecase.article.updateArticle.adapters.web.model.UpdateArticleReqVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class UpdateArticleValidator implements Validator {
|
||||
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return UpdateArticleReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
UpdateArticleReqVO vo = (UpdateArticleReqVO) target;
|
||||
|
||||
LocalDateTime startDate = vo.getStartDate();
|
||||
LocalDateTime endDate = vo.getEndDate();
|
||||
|
||||
// 게시일 날짜 체크
|
||||
if (startDate == null) {
|
||||
errors.rejectValue(
|
||||
"startDate", "valid.common.required",
|
||||
messageUtil.getMessage("valid.common.required"));
|
||||
}
|
||||
|
||||
if (endDate == null) {
|
||||
errors.rejectValue(
|
||||
"endDate", "valid.common.required",
|
||||
messageUtil.getMessage("valid.common.required"));
|
||||
}
|
||||
|
||||
if (startDate != null && endDate != null) {
|
||||
if (!startDate.isBefore(endDate)) {
|
||||
errors.rejectValue(
|
||||
"startDate",
|
||||
"valid.common.date.invalid",
|
||||
messageUtil.getMessage("valid.common.date.invalid"));
|
||||
errors.rejectValue(
|
||||
"endDate",
|
||||
"valid.common.date.invalid",
|
||||
messageUtil.getMessage("valid.common.date.invalid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package app.module.admin.usecase.batchLog.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.batchLog.ports.BatchLogPortOut;
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogCmd;
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class BatchLogDao implements BatchLogPortOut {
|
||||
private final BatchLogMapper mapper;
|
||||
|
||||
@Override
|
||||
public boolean exists(BatchLogType type) {
|
||||
return mapper.exists(type.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long create(BatchLogType type) {
|
||||
BatchLogCmd cmd = new BatchLogCmd(null, type.name(), "RUNNING", LocalDateTime.now());
|
||||
mapper.create(cmd);
|
||||
return cmd.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Long id, String status, String errorMessage) {
|
||||
mapper.update(id, status, errorMessage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.admin.usecase.batchLog.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BatchLogMapper {
|
||||
boolean exists(String type);
|
||||
Long create(BatchLogCmd cmd);
|
||||
void update(Long id, String status, String errorMessage);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.batchLog.ports;
|
||||
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
|
||||
|
||||
public interface BatchLogPortIn {
|
||||
boolean exists(BatchLogType type);
|
||||
Long create(BatchLogType type);
|
||||
void update(Long id, String status, String errorMessage);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.batchLog.ports;
|
||||
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
|
||||
|
||||
public interface BatchLogPortOut {
|
||||
boolean exists(BatchLogType type);
|
||||
Long create(BatchLogType type);
|
||||
void update(Long id, String status, String errorMessage);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.admin.usecase.batchLog.ports.application;
|
||||
|
||||
import app.module.admin.usecase.batchLog.ports.BatchLogPortIn;
|
||||
import app.module.admin.usecase.batchLog.ports.BatchLogPortOut;
|
||||
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class BatchLogService implements BatchLogPortIn {
|
||||
private final BatchLogPortOut portOut;
|
||||
|
||||
@Override
|
||||
public boolean exists(BatchLogType type) {
|
||||
return portOut.exists(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long create(BatchLogType type) {
|
||||
return portOut.create(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Long id, String status, String errorMessage) {
|
||||
portOut.update(id, status, errorMessage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.admin.usecase.batchLog.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class BatchLog {
|
||||
private Long id;
|
||||
private String type;
|
||||
private String status;
|
||||
private LocalDateTime startAt;
|
||||
private LocalDateTime endAt;
|
||||
private String errorMessage;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.batchLog.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class BatchLogCmd {
|
||||
private Long id;
|
||||
private String type;
|
||||
private String status;
|
||||
private LocalDateTime startAt;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.usecase.batchLog.ports.application.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum BatchLogType {
|
||||
AUTO_SMS,
|
||||
MONTHLY_STATUS,
|
||||
CARRYOVER
|
||||
}
|
||||
@@ -11,9 +11,14 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class CreateNoticeController {
|
||||
@@ -23,8 +28,13 @@ class CreateNoticeController {
|
||||
ResponseEntity<?> operate(@RequestBody @Valid CreateNoticeReqVO reqVO, BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
List<String> fieldOrder = Arrays.asList("title", "content", "visible", "startDate", "endDate");
|
||||
|
||||
List<FieldError> sortedErrors = bindingResult.getFieldErrors().stream()
|
||||
.sorted(Comparator.comparingInt(error -> fieldOrder.indexOf(error.getField())))
|
||||
.toList();
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
.body(sortedErrors);
|
||||
}
|
||||
|
||||
CreateNotice article =
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeReqVO;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
@@ -15,19 +14,19 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateNoticeReqVO {
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@NotBlank(message = "제목은 필수입력값입니다.")
|
||||
private String title;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@NotBlank(message = "내용은 {valid.common.required}")
|
||||
private String content;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
@NotNull(message = "노출 여부는 {valid.common.required}")
|
||||
private Boolean visible;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
@NotNull(message = "시작일은 {valid.common.required}")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
@NotNull(message = "종료일은 {valid.common.required}")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private List<String> fileMappingId;
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
@@ -2,7 +2,6 @@ package app.module.admin.usecase.communication.notice.getNotice.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@@ -13,10 +13,10 @@ import java.util.Optional;
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticeService implements GetNoticePortIn {
|
||||
|
||||
private final GetNoticePortOut portOut;
|
||||
private final GetNoticePortOut getNoticePortOut;
|
||||
|
||||
@Override
|
||||
public Optional<GetNotice> operate(GetNoticeCmd command) {
|
||||
return portOut.operate(command);
|
||||
return getNoticePortOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -68,60 +68,6 @@ class GetNoticesDao implements GetNoticesPortOut {
|
||||
@Override
|
||||
@Transactional
|
||||
public List<GetNotices> operateList(GetNoticesCmd command) {
|
||||
/*// 검색조건 초기화
|
||||
Specification<Article> spec = (root, query, criteriaBuilder) -> null;
|
||||
|
||||
// 검색어 - like 검색
|
||||
if (!StringUtils.isEmpty(command.getSearchField())) {
|
||||
spec =
|
||||
spec.and(
|
||||
(root, query, builder) ->
|
||||
builder.like(
|
||||
root.get(command.getSearchField()),
|
||||
"%" + command.getSearchValue() + "%"));
|
||||
}
|
||||
|
||||
// 공개여부 검색
|
||||
if (!StringUtils.isEmpty(command.getSearchOpen())) {
|
||||
spec =
|
||||
spec.and(
|
||||
((root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.equal(
|
||||
root.get("visible"), Boolean.valueOf(command.getSearchOpen()))));
|
||||
}
|
||||
|
||||
List<Article> result = getArticlesRepo.findAll(spec);
|
||||
|
||||
return result.stream()
|
||||
.map(
|
||||
article ->
|
||||
new GetArticles(
|
||||
article.getId(),
|
||||
article.getUpdatedBy(),
|
||||
article.getUpdatedAt(),
|
||||
article.getTitle(),
|
||||
article.getContent(),
|
||||
article.getVisible(),
|
||||
article.getStartDate(),
|
||||
article.getEndDate(),
|
||||
article.getOrderNo(),
|
||||
article.getUploadFiles().stream()
|
||||
// 목록에 보여줄 대표이미지만 담는다
|
||||
.filter(
|
||||
uploadFile -> uploadFile.getType()
|
||||
.equals(FileUploadType.EXAMPLE_REP))
|
||||
.map(
|
||||
uploadFile ->
|
||||
new GetArticleFiles(
|
||||
uploadFile.getId(),
|
||||
uploadFile.getType(),
|
||||
uploadFile.getPath(),
|
||||
uploadFile.getName(),
|
||||
uploadFile.getOriginName(),
|
||||
uploadFile.getFileLength()))
|
||||
.findFirst()
|
||||
.orElse(null)))
|
||||
.collect(Collectors.toList());*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,15 @@ package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
|
||||
@@ -17,7 +17,7 @@ class RemoveNoticesDao implements RemoveNoticesPortOut {
|
||||
|
||||
@Override
|
||||
public void operate(RemoveNoticesCmd command) {
|
||||
String loginUser = CommonUtil.getLoginUsername();;
|
||||
String loginUser = CommonUtil.getLoginUsername();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
mapper.deleteNoticeUploadFiles(
|
||||
|
||||
@@ -11,10 +11,15 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class UpdateNoticeController {
|
||||
@@ -26,15 +31,22 @@ class UpdateNoticeController {
|
||||
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
List<String> fieldOrder = Arrays.asList("title", "content", "visible", "startDate", "endDate");
|
||||
|
||||
List<FieldError> sortedErrors = bindingResult.getFieldErrors().stream()
|
||||
.sorted(Comparator.comparingInt(error -> fieldOrder.indexOf(error.getField())))
|
||||
.toList();
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
.body(sortedErrors);
|
||||
}
|
||||
|
||||
updateFilePortIn.operate(
|
||||
new UpdateFileCmd(
|
||||
reqVO.getId(),
|
||||
reqVO.getFileMappingId().stream().map(Long::parseLong).toList(),
|
||||
FileUploadType.NOTICE)
|
||||
reqVO.getFileMappingId() != null
|
||||
? reqVO.getFileMappingId().stream().map(Long::parseLong).toList()
|
||||
: List.of(),
|
||||
FileUploadType.NOTICE)
|
||||
);
|
||||
|
||||
updateNoticePortIn.operate(
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.AdminUtil;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@@ -17,20 +17,19 @@ public class UpdateNoticeReqVO {
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@NotBlank(message = "제목은 {valid.common.required}")
|
||||
private String title;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@NotBlank(message = "내용은 {valid.common.required}")
|
||||
private String content;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
@NotNull(message = "노출여부는 {valid.common.required}")
|
||||
private Boolean visible;
|
||||
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
@NotNull(message = "시작일은 {valid.common.required}")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
@NotNull(message = "종료일은 {valid.common.required}")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private List<String> fileMappingId;
|
||||
|
||||
@@ -10,10 +10,10 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
class UpdateNoticeService implements UpdateNoticePortIn {
|
||||
|
||||
private final UpdateNoticePortOut portOut;
|
||||
private final UpdateNoticePortOut updateNoticePortOut;
|
||||
|
||||
@Override
|
||||
public void operate(UpdateNoticeCmd command) {
|
||||
portOut.operate(command);
|
||||
updateNoticePortOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package app.module.admin.usecase.communication.sms.getSmsUI;
|
||||
|
||||
import app.module.admin.usecase.communication.sms.getSmsUI.model.GetSmsReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import app.module.admin.usecase.communication.sms.getSmsUI.model.GetSmsReqVO;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortOut;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionDao implements GetSuggestionPortOut {
|
||||
private final GetSuggestionMapper mapper;
|
||||
|
||||
@Override
|
||||
public Optional<GetSuggestion> operate(GetSuggestionCmd cmd) {
|
||||
return mapper.getSuggestionById(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapper
|
||||
public interface GetSuggestionMapper {
|
||||
Optional<GetSuggestion> getSuggestionById(GetSuggestionCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetSuggestionPortIn {
|
||||
Optional<GetSuggestion> operate(GetSuggestionCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetSuggestionPortOut {
|
||||
Optional<GetSuggestion> operate(GetSuggestionCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortIn;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortOut;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionService implements GetSuggestionPortIn {
|
||||
private final GetSuggestionPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<GetSuggestion> operate(GetSuggestionCmd cmd) {
|
||||
return portOut.operate(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetSuggestion {
|
||||
private Long id;
|
||||
private Long householdSeq;
|
||||
private String householdNum;
|
||||
private String ownerName;
|
||||
private String ownerPhone;
|
||||
private String regionMainName;
|
||||
private String researcherName;
|
||||
private String researcherPhone;
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetSuggestionCmd {
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestionUI;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortIn;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestionUI.model.GetSuggestionUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionUIController {
|
||||
|
||||
private final GetSuggestionPortIn portIn;
|
||||
|
||||
@GetMapping(path = "/communication/suggestions/{id}")
|
||||
String operate(@PathVariable Long id, Model model,
|
||||
@ModelAttribute("reqVO") GetSuggestionUIReqVO reqVO) {
|
||||
model.addAttribute("item",
|
||||
portIn.operate(new GetSuggestionCmd(id)).orElse(null));
|
||||
return "communication/suggestions/{id}";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.article.getArticleCreateUI.adapters.web.model;
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestionUI.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,6 +9,5 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleUIReqVO {
|
||||
|
||||
public class GetSuggestionUIReqVO {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortOut;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestions;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestionsCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionsDao implements GetSuggestionsPortOut {
|
||||
private final GetSuggestionsMapper mapper;
|
||||
|
||||
@Override
|
||||
public Page<GetSuggestions> operate(Pageable pageable, GetSuggestionsCmd cmd) {
|
||||
|
||||
List<GetSuggestions> result = mapper.getSuggestions(pageable, cmd);
|
||||
|
||||
return new PageImpl<>(result, pageable, result.isEmpty() ? 0 : result.get(0).getTotal());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestions;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestionsCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface GetSuggestionsMapper {
|
||||
List<GetSuggestions> getSuggestions(@Param("pageable") Pageable pageable,
|
||||
@Param("cmd")GetSuggestionsCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web.model.GetSuggestionsReqVO;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortIn;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestionsCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionsController {
|
||||
private final GetSuggestionsPortIn portIn;
|
||||
|
||||
@GetMapping(path = "/api/communication/suggestions")
|
||||
ResponseEntity<?> operate(@PageableDefault(size = 10) Pageable pageable,
|
||||
GetSuggestionsReqVO reqVO) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(portIn.operate(pageable,
|
||||
new GetSuggestionsCmd(
|
||||
reqVO.getRecordMonth(),
|
||||
reqVO.getOwnerField(),
|
||||
reqVO.getOwnerValue())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetSuggestionsReqVO {
|
||||
private String recordMonth;
|
||||
private String ownerField;
|
||||
private String ownerValue;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.dashboard.getDashboardUI.model;
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,5 +9,5 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetDashboardUIReqVO {
|
||||
public class GetSuggestionsResVO {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.ports;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestions;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestionsCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetSuggestionsPortIn {
|
||||
Page<GetSuggestions> operate(Pageable pageable, GetSuggestionsCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.ports;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestions;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestionsCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetSuggestionsPortOut {
|
||||
Page<GetSuggestions> operate(Pageable pageable, GetSuggestionsCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortIn;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortOut;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestions;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain.GetSuggestionsCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionsService implements GetSuggestionsPortIn {
|
||||
private final GetSuggestionsPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Page<GetSuggestions> operate(Pageable pageable, GetSuggestionsCmd cmd) {
|
||||
return portOut.operate(pageable, cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetSuggestions {
|
||||
private Long id;
|
||||
private Long householdSeq;
|
||||
private String content;
|
||||
private String ownerName;
|
||||
private String phone;
|
||||
private String updatedBy;
|
||||
private String updatedAt;
|
||||
private Integer total;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetSuggestionsCmd {
|
||||
private String recordMonth;
|
||||
private String ownerField;
|
||||
private String ownerValue;
|
||||
}
|
||||
@@ -1,21 +1,23 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestionsUI;
|
||||
|
||||
import app.module.admin.config.application.util.DateUiUtil;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestionsUI.model.GetSuggestionsUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestionsUI.model.GetSuggestionsUIReqVO;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionsUIController {
|
||||
|
||||
@GetMapping(path = "/communication/suggestions")
|
||||
String operate(
|
||||
Model model,
|
||||
@ModelAttribute("reqVO") GetSuggestionsUIReqVO reqVO) {
|
||||
@GetMapping(path = "/communication/suggestions")
|
||||
String operate(Model model, @ModelAttribute("reqVO") GetSuggestionsUIReqVO reqVO) {
|
||||
|
||||
return "communication/suggestions";
|
||||
}
|
||||
model.addAttribute("monthList", DateUiUtil.getRecentMonths(13));
|
||||
model.addAttribute("currentMonth", DateUiUtil.getCurrentMonthValue());
|
||||
|
||||
return "communication/suggestions";
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,20 @@ import lombok.Setter;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetSuggestionsUIReqVO {
|
||||
private Integer page;
|
||||
private String sort;
|
||||
private Integer size;
|
||||
private String recordMonth;
|
||||
private String ownerField;
|
||||
private String ownerValue;
|
||||
|
||||
public Integer getPage() {
|
||||
// 요청 페이지 넘버 - 초기값 `0`
|
||||
return page != null ? page : 0;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
// 페이지 당 아이템 수 - 초기값 `10`
|
||||
return size != null ? size : 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence;
|
||||
|
||||
import app.module.admin.config.application.util.AdminUtil;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.ChartDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.DashboardExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.LocalRegionResearcherPercentDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.web.model.TotalPercentageReqVO;
|
||||
import app.module.admin.usecase.dashboard.chart.ports.ChartPortOut;
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
import app.module.core.usecase.uicode.list.adapters.persistence.UICodeListMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ChartDao implements ChartPortOut {
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfiles;
|
||||
private final ChartMapper chartMapper;
|
||||
private final UICodeListMapper uiCodeListMapper;
|
||||
|
||||
@Override
|
||||
public ChartDto selectTotalPercentage(String usageType) {
|
||||
TotalPercentageReqVO reqVO = new TotalPercentageReqVO();
|
||||
reqVO.setUsageType(usageType);
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
|
||||
String formattedDate = today.format(formatter);
|
||||
reqVO.setRecordMonth(formattedDate);
|
||||
DateTimeFormatter formatterText = DateTimeFormatter.ofPattern("yyyy년 MM월 현황");
|
||||
String recordMonthText = today.format(formatterText);
|
||||
|
||||
if("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) {
|
||||
// 관리자 일경우
|
||||
return new ChartDto(
|
||||
recordMonthText,
|
||||
chartMapper.selectTotalPercentage(reqVO,activeProfiles),
|
||||
chartMapper.selectLocalRegionPercentage(reqVO,activeProfiles),
|
||||
chartMapper.selectLocalRegionResearcherPercentage(reqVO,activeProfiles),
|
||||
uiCodeListMapper.findByParentId("code.region.main",AdminUtil.getLoginUserRole(),activeProfiles));
|
||||
|
||||
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
|
||||
// 지방 실사 일경우 실사 지역으로만
|
||||
reqVO.setRegionMainCode(AdminUtil.getLoginUserRegionMainCode());
|
||||
|
||||
return new ChartDto(
|
||||
recordMonthText,
|
||||
chartMapper.selectTotalPercentage(reqVO,activeProfiles),
|
||||
chartMapper.selectLocalRegionPercentage(reqVO,activeProfiles),
|
||||
chartMapper.selectLocalRegionResearcherPercentage(reqVO,activeProfiles),
|
||||
null);
|
||||
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
|
||||
// 조사원 일경우
|
||||
reqVO.setAdminSeq(AdminUtil.getLoginUserSeq());
|
||||
return new ChartDto(recordMonthText, chartMapper.selectTotalPercentageResearcher(reqVO,activeProfiles), null,null,null);
|
||||
}
|
||||
|
||||
return new ChartDto(null,null,null,null,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType, String regionMainCode) {
|
||||
LocalDate today = LocalDate.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
|
||||
String formattedDate = today.format(formatter);
|
||||
if("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) {
|
||||
return chartMapper.selectLocalRegionResearcherPercentage(new TotalPercentageReqVO(usageType,regionMainCode,formattedDate),activeProfiles);
|
||||
}else{
|
||||
throw new NoMatchingURIException("잘못된 접근");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashboardExcelDto selectDashboard(String recordMonth) {
|
||||
return new DashboardExcelDto(
|
||||
chartMapper.selectRegionMainExcel(recordMonth,activeProfiles),
|
||||
chartMapper.selectRegionDetailExcel(recordMonth,activeProfiles));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.*;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.web.model.TotalPercentageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ChartMapper {
|
||||
|
||||
TotalPercentDto selectTotalPercentage(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
|
||||
TotalPercentDto selectTotalPercentageResearcher(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
|
||||
List<LocalRegionPercentDto> selectLocalRegionPercentage(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
|
||||
List<LocalRegionResearcherPercentDto> selectLocalRegionResearcherPercentage(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
|
||||
List<RegionMainExcelDto> selectRegionMainExcel(@Param("recordMonth") String recordMonth,@Param("activeProfiles") String activeProfiles);
|
||||
List<RegionDetailExcelDto> selectRegionDetailExcel(@Param("recordMonth") String recordMonth,@Param("activeProfiles") String activeProfiles);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ChartDto {
|
||||
private String recordMonthText;
|
||||
private TotalPercentDto totalPercentDto;
|
||||
private List<LocalRegionPercentDto> localRegionPercentDtoList;
|
||||
private List<LocalRegionResearcherPercentDto> localRegionResearcherPercentDtoList;
|
||||
private List<UICodeElement> regionMainCodeList;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class DashboardExcelDto {
|
||||
List<RegionMainExcelDto> regionMain;
|
||||
List<RegionDetailExcelDto> regionDetail;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user