Merge branch 'dev' into 'deploy-dev-front'
Dev See merge request korea-research/korea-research!95
This commit is contained in:
14
README.md
14
README.md
@@ -97,7 +97,7 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
|
||||
|
||||
|
||||
### VM Options 예시
|
||||
#### `admin`, `front`, `api` 모두 사용가능합니다.
|
||||
#### `admin`, `front` 모두 사용가능합니다.
|
||||
```
|
||||
-Dspring.profiles.active=local
|
||||
-Dapp.initData.core=false
|
||||
@@ -108,14 +108,9 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
|
||||
-Dserver.port=8080
|
||||
-Dserver.forward-headers-strategy=native
|
||||
-Dlogging.level.org.springframework.security=DEBUG
|
||||
-Dspring.datasource.driver-class-name=org.postgresql.Driver
|
||||
-Dspring.datasource.url=jdbc:postgresql://15.165.180.203:5432/korea_research
|
||||
-Dspring.datasource.username=ko_research
|
||||
-Dspring.datasource.password=koresearch1@#4
|
||||
-Daes.secret-key=092HW829O0A0AVR0
|
||||
-Dpath.upload.storage=LOCAL
|
||||
-Dpath.upload.sftp.public=/home/etribe/data/upload
|
||||
-Dpath.upload.sftp.tmpdir=${user.home}/upload/tmpdir
|
||||
-Dfile.upload.sftp.ip=115.68.193.117
|
||||
-Dfile.upload.sftp.id=etribe
|
||||
-Dfile.upload.sftp.password=Etribe@3415
|
||||
@@ -127,8 +122,11 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
|
||||
-Dspring.datasource.hikari.connection-timeout=5000
|
||||
-Dspring.datasource.hikari.leak-detection-threshold=30000
|
||||
```
|
||||
** 주의 : 운영서버일 경우 -Dpath.upload.storage=SFTP로 설정
|
||||
|
||||
** 주의 : 운영서버일 경우 vm옵션 추가
|
||||
-Dspring.profiles.active=prod
|
||||
-Dpath.upload.storage=SFTP
|
||||
-Djasypt.encryptor.password=ko-research
|
||||
-Djasypt.encryptor.algorithm=PBEWITHHMACSHA512ANDAES_256
|
||||
|
||||
|
||||
## JDBC 및 데이터 핸들링 구성 옵션
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
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 java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@@ -30,4 +32,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,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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -5,6 +5,7 @@ import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePo
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -13,10 +14,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.adapters.persistence;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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 app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortOut;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetSuggestionDao implements GetSuggestionPortOut {
|
||||
private final GetSuggestionMapper mapper;
|
||||
|
||||
@Override
|
||||
public Optional<GetSuggestion> operate(GetSuggestionCmd cmd) {
|
||||
return mapper.getSuggestionById(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
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 java.util.Optional;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface GetSuggestionMapper {
|
||||
Optional<GetSuggestion> getSuggestionById(GetSuggestionCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports;
|
||||
|
||||
import java.util.Optional;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
|
||||
public interface GetSuggestionPortIn {
|
||||
Optional<GetSuggestion> operate(GetSuggestionCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports;
|
||||
|
||||
import java.util.Optional;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestion;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain.GetSuggestionCmd;
|
||||
|
||||
public interface GetSuggestionPortOut {
|
||||
Optional<GetSuggestion> operate(GetSuggestionCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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 app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortIn;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestion.ports.GetSuggestionPortOut;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@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;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.ports.application.domain;
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestion.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,6 +9,6 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleCommentCmd {
|
||||
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 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;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestionUI.model.GetSuggestionUIReqVO;
|
||||
|
||||
@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,25 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.persistence;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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 app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortOut;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@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,14 @@
|
||||
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 java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@Mapper
|
||||
public interface GetSuggestionsMapper {
|
||||
List<GetSuggestions> getSuggestions(@Param("pageable") Pageable pageable,
|
||||
@Param("cmd")GetSuggestionsCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web;
|
||||
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web.model.GetSuggestionsReqVO;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.adapters.web.model.GetSuggestionsResVO;
|
||||
|
||||
@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 lombok.RequiredArgsConstructor;
|
||||
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 app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortIn;
|
||||
import app.module.admin.usecase.communication.suggestion.getSuggestions.ports.GetSuggestionsPortOut;
|
||||
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,5 +1,7 @@
|
||||
package app.module.admin.usecase.communication.suggestion.getSuggestionsUI;
|
||||
|
||||
import app.module.admin.config.application.util.DateUiUtil;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -11,11 +13,12 @@ import app.module.admin.usecase.communication.suggestion.getSuggestionsUI.model.
|
||||
@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,89 @@
|
||||
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.LocalRegionPercentDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.LocalRegionResearcherPercentDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.RegionDetailExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.RegionMainExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.TotalPercentDto;
|
||||
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 app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ChartDao implements ChartPortOut {
|
||||
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),
|
||||
chartMapper.selectLocalRegionPercentage(reqVO),
|
||||
chartMapper.selectLocalRegionResearcherPercentage(reqVO),
|
||||
uiCodeListMapper.findByParentId("code.region.main"));
|
||||
|
||||
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
|
||||
// 지방 실사 일경우 실사 지역으로만
|
||||
reqVO.setRegionMainCode(AdminUtil.getLoginUserRegionMainCode());
|
||||
|
||||
return new ChartDto(
|
||||
recordMonthText,
|
||||
chartMapper.selectTotalPercentage(reqVO),
|
||||
null,
|
||||
chartMapper.selectLocalRegionResearcherPercentage(reqVO),
|
||||
null);
|
||||
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
|
||||
// 조사원 일경우
|
||||
reqVO.setAdminSeq(AdminUtil.getLoginUserSeq());
|
||||
return new ChartDto(recordMonthText, chartMapper.selectTotalPercentageResearcher(reqVO), 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));
|
||||
}else{
|
||||
throw new NoMatchingURIException("잘못된 접근");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashboardExcelDto selectDashboard(String recordMonth) {
|
||||
return new DashboardExcelDto(
|
||||
chartMapper.selectRegionMainExcel(recordMonth),
|
||||
chartMapper.selectRegionDetailExcel(recordMonth));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.LocalRegionPercentDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.LocalRegionResearcherPercentDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.RegionDetailExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.RegionMainExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.TotalPercentDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.web.model.TotalPercentageReqVO;
|
||||
import app.module.admin.usecase.researcher.adpaters.web.model.ResearchersListReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ChartMapper {
|
||||
|
||||
TotalPercentDto selectTotalPercentage(TotalPercentageReqVO reqVO);
|
||||
TotalPercentDto selectTotalPercentageResearcher(TotalPercentageReqVO reqVO);
|
||||
List<LocalRegionPercentDto> selectLocalRegionPercentage(TotalPercentageReqVO reqVO);
|
||||
List<LocalRegionResearcherPercentDto> selectLocalRegionResearcherPercentage(TotalPercentageReqVO reqVO);
|
||||
List<RegionMainExcelDto> selectRegionMainExcel(String recordMonth);
|
||||
List<RegionDetailExcelDto> selectRegionDetailExcel(String recordMonth);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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,14 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class DashboardExcelDto {
|
||||
List<RegionMainExcelDto> regionMain;
|
||||
List<RegionDetailExcelDto> regionDetail;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LocalRegionPercentDto {
|
||||
private String regionName;
|
||||
private Double totalHouseholdCount;
|
||||
private Double dailyPercent;
|
||||
private Double visitPercent;
|
||||
private Double totalVisitCount;
|
||||
private Double giftSentPercent;
|
||||
private Double totalGiftSentCount;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LocalRegionResearcherPercentDto {
|
||||
private String researcherName;
|
||||
private String regionMainCodeName;
|
||||
private Double totalHouseholdCount;
|
||||
private Double dailyPercent;
|
||||
private Double visitPercent;
|
||||
private Double totalVisitCount;
|
||||
private Double giftSentPercent;
|
||||
private Double totalGiftSentCount;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RegionDetailExcelDto {
|
||||
private String regionDetailName;
|
||||
private String regionName;
|
||||
private String householdCount;
|
||||
private String avgCompletionRate;
|
||||
private String visitCount;
|
||||
private String giftSentCount;
|
||||
private String regionOrder;
|
||||
private String regionDetailOrder;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RegionMainExcelDto {
|
||||
private String regionName;
|
||||
private String researcherCount;
|
||||
private String householdCount;
|
||||
private String avgCompletionRate;
|
||||
private String visitCount;
|
||||
private String giftSentCount;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.persistence.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TotalPercentDto {
|
||||
private Double dailyPercent;
|
||||
private Double totalHouseholdCount;
|
||||
private Double visitPercent;
|
||||
private Double totalVisitCount;
|
||||
private Double giftSentPercent;
|
||||
private Double totalGiftSentCount;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.DateUiUtil;
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.DashboardExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.RegionDetailExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.RegionMainExcelDto;
|
||||
import app.module.admin.usecase.dashboard.chart.adapters.web.model.TotalPercentageReqVO;
|
||||
import app.module.admin.usecase.dashboard.chart.ports.ChartPortIn;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/api/dashboard/chart")
|
||||
class ChartApiController {
|
||||
|
||||
private final ChartPortIn chartPortIn;
|
||||
|
||||
@GetMapping(path = "/total")
|
||||
ResponseEntity<?> selectTotalPercentage(@RequestParam("usageType") String usageType) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(chartPortIn.selectTotalPercentage(usageType));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/researcher")
|
||||
ResponseEntity<?> selectRegionMainCodePercentage(@RequestParam("usageType") String usageType,@RequestParam("regionMainCode") String regionMainCode) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(chartPortIn.selectRegionMainCodePercentage(usageType,regionMainCode));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/excel")
|
||||
ResponseEntity<byte[]> exportDashboardExcel() {
|
||||
|
||||
DashboardExcelDto dashboardExcel = chartPortIn.selectDashboard(
|
||||
DateUiUtil.getCurrentMonthValue());
|
||||
|
||||
List<List<String>> rows1 = new ArrayList<>();
|
||||
for (RegionMainExcelDto item : dashboardExcel.getRegionMain()) {
|
||||
rows1.add(List.of(
|
||||
StringUtils.defaultString(item.getRegionName()),
|
||||
StringUtils.defaultString(item.getResearcherCount()),
|
||||
StringUtils.defaultString(item.getHouseholdCount()),
|
||||
StringUtils.defaultString(item.getAvgCompletionRate()) + "%",
|
||||
StringUtils.defaultString(item.getVisitCount()),
|
||||
StringUtils.defaultString(item.getGiftSentCount())
|
||||
));
|
||||
}
|
||||
|
||||
// 시트 1: 실사
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto(
|
||||
"실사",
|
||||
List.of("실사", "할당 조사원 수", "할당 임가 수", "일계부 진행률", "현장 방문 수", "답례품 전달 임가 수"),
|
||||
rows1,
|
||||
null,
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW)
|
||||
);
|
||||
|
||||
List<List<String>> rows2 = new ArrayList<>();
|
||||
for (RegionDetailExcelDto item : dashboardExcel.getRegionDetail()) {
|
||||
rows2.add(List.of(
|
||||
StringUtils.defaultString(item.getRegionDetailName()),
|
||||
StringUtils.defaultString(item.getHouseholdCount()),
|
||||
StringUtils.defaultString(item.getAvgCompletionRate()) + "%",
|
||||
StringUtils.defaultString(item.getVisitCount()),
|
||||
StringUtils.defaultString(item.getGiftSentCount())
|
||||
));
|
||||
}
|
||||
|
||||
// 시트 2: 세부지역
|
||||
ExcelSheetDto sheet2 = new ExcelSheetDto(
|
||||
"세부지역",
|
||||
List.of("세부지역", "할당 임가 수", "일계부 진행률", "현장 방문 수", "답례품 전달 임가 수"),
|
||||
rows2,
|
||||
null,
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW)
|
||||
);
|
||||
|
||||
// 시트 모음
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1, sheet2);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "대시보드_" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
||||
String encodedFileName = URLEncoder.encode(rawFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
|
||||
.body(excel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.dashboard.chart.adapters.web.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class TotalPercentageReqVO {
|
||||
private String usageType;
|
||||
private String regionMainCode;
|
||||
private Long adminSeq;
|
||||
private String recordMonth;
|
||||
|
||||
public TotalPercentageReqVO(String usageType, String regionMainCode,String recordMonth) {
|
||||
this.usageType = usageType;
|
||||
this.regionMainCode = regionMainCode;
|
||||
this.recordMonth = recordMonth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.dashboard.chart.ports;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
public interface ChartPortIn {
|
||||
|
||||
ChartDto selectTotalPercentage(String usageType);
|
||||
List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode);
|
||||
DashboardExcelDto selectDashboard(String recordMonth);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.dashboard.chart.ports;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
public interface ChartPortOut {
|
||||
|
||||
ChartDto selectTotalPercentage(String usageType);
|
||||
List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode);
|
||||
DashboardExcelDto selectDashboard(String recordMonth);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.admin.usecase.dashboard.chart.ports.applilcation;
|
||||
|
||||
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.ChartPortIn;
|
||||
import app.module.admin.usecase.dashboard.chart.ports.ChartPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class ChartService implements ChartPortIn {
|
||||
private final ChartPortOut portOut;
|
||||
|
||||
@Override
|
||||
public ChartDto selectTotalPercentage(String usageType){
|
||||
return portOut.selectTotalPercentage(usageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode) {
|
||||
return portOut.selectRegionMainCodePercentage(usageType,regionMainCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashboardExcelDto selectDashboard(String recordMonth) {
|
||||
return portOut.selectDashboard(recordMonth);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.admin.usecase.dashboard.getDashboardUI;
|
||||
|
||||
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.dashboard.getDashboardUI.model.GetDashboardUIReqVO;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetDashboardUIController {
|
||||
|
||||
@GetMapping(path = "/dashboard")
|
||||
String operate(
|
||||
Model model,
|
||||
@ModelAttribute("reqVO") GetDashboardUIReqVO reqVO) {
|
||||
|
||||
return "dashboard";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.adapters.persistence;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus;
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatusCmd;
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.GetSmsAutoStatusPortOut;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetSmsAutoStatusDao implements GetSmsAutoStatusPortOut {
|
||||
private final GetSmsAutoStatusMapper mapper;
|
||||
|
||||
@Override
|
||||
public Optional<GetSmsAutoStatus> operate() {
|
||||
return mapper.operate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus;
|
||||
import java.util.Optional;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface GetSmsAutoStatusMapper {
|
||||
Optional<GetSmsAutoStatus> operate();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.ports;
|
||||
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetSmsAutoStatusPortIn {
|
||||
Optional<GetSmsAutoStatus> operate();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.ports;
|
||||
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetSmsAutoStatusPortOut {
|
||||
Optional<GetSmsAutoStatus> operate();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application;
|
||||
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.GetSmsAutoStatusPortIn;
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.GetSmsAutoStatusPortOut;
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetSmsAutoStatusService implements GetSmsAutoStatusPortIn {
|
||||
|
||||
private final GetSmsAutoStatusPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<GetSmsAutoStatus> operate() {
|
||||
return portOut.operate();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.ports.application.domain;
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -10,9 +10,10 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleComment {
|
||||
private Long id;
|
||||
private String content;
|
||||
private String createdBy;
|
||||
public class GetSmsAutoStatus {
|
||||
private Boolean active;
|
||||
private String message;
|
||||
private String sendPhone;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.article.getArticleUpdateUI.adapters.web.model;
|
||||
package app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,6 +9,5 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleUpdateUIReqVO {
|
||||
|
||||
public class GetSmsAutoStatusCmd {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.annotation.UpdateCommand;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain.UpdateSmsAutoStatusCmd;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.UpdateSmsAutoStatusPortOut;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class UpdateSmsAutoStatusDao implements UpdateSmsAutoStatusPortOut {
|
||||
private final UpdateSmsAutoStatusMapper mapper;
|
||||
|
||||
@Override
|
||||
@UpdateCommand
|
||||
public void operate(UpdateSmsAutoStatusCmd cmd) {
|
||||
mapper.operate(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain.UpdateSmsAutoStatusCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UpdateSmsAutoStatusMapper {
|
||||
void operate(UpdateSmsAutoStatusCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.UpdateSmsAutoStatusPortIn;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain.UpdateSmsAutoStatusCmd;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
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.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.web.model.UpdateSmsAutoStatusReqVO;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.web.model.UpdateSmsAutoStatusResVO;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class UpdateSmsAutoStatusController {
|
||||
private final UpdateSmsAutoStatusPortIn portIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PatchMapping(path = "/api/smsAutoStatus/update")
|
||||
ResponseEntity<?> operate(@Valid @RequestBody UpdateSmsAutoStatusReqVO reqVO,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
try {
|
||||
portIn.operate(new UpdateSmsAutoStatusCmd(reqVO.getActive()));
|
||||
} catch (Exception e) {
|
||||
// update 실패
|
||||
log.info(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new UpdateSmsAutoStatusResVO(
|
||||
messageUtil.getMessage("operation.common.update.done")));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.userRole.removeUserRole.adapters.web.model;
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,9 +9,7 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveUserRoleReqVO {
|
||||
|
||||
private String id;
|
||||
public class UpdateSmsAutoStatusReqVO {
|
||||
private Boolean active;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateSmsAutoStatusResVO {
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports;
|
||||
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain.UpdateSmsAutoStatusCmd;
|
||||
|
||||
public interface UpdateSmsAutoStatusPortIn {
|
||||
void operate(UpdateSmsAutoStatusCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports;
|
||||
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain.UpdateSmsAutoStatusCmd;
|
||||
|
||||
public interface UpdateSmsAutoStatusPortOut {
|
||||
void operate(UpdateSmsAutoStatusCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain.UpdateSmsAutoStatusCmd;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.UpdateSmsAutoStatusPortIn;
|
||||
import app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.UpdateSmsAutoStatusPortOut;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class UpdateSmsAutoStatusService implements UpdateSmsAutoStatusPortIn {
|
||||
private final UpdateSmsAutoStatusPortOut portOut;
|
||||
|
||||
@Override
|
||||
public void operate(UpdateSmsAutoStatusCmd cmd) {
|
||||
portOut.operate(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.dashboard.updateSmsAutoStatus.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class UpdateSmsAutoStatusCmd extends AuditCommand {
|
||||
private Boolean active;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.email.send.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.email.send.adapters.web.model.EmailVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class EmailController {
|
||||
|
||||
@GetMapping(path = "/addons/email/form")
|
||||
public String emailForm(@ModelAttribute("formDto") EmailVO emailVO) {
|
||||
return "email/emailForm";
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package app.module.admin.usecase.email.send.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.email.send.adapters.web.model.EmailVO;
|
||||
import app.module.admin.usecase.email.send.ports.EmailSendPortIn;
|
||||
import app.module.admin.usecase.email.send.ports.application.domain.Email;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class EmailSendController {
|
||||
|
||||
private final EmailSendPortIn emailSendPortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PostMapping(path = "/addons/email/form")
|
||||
public String sendEmail(
|
||||
RedirectAttributes redirectAttributes,
|
||||
@Valid @ModelAttribute("formDto") EmailVO emailVO,
|
||||
BindingResult bindingResult)
|
||||
throws IOException, MessagingException {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "email/emailForm";
|
||||
}
|
||||
|
||||
emailSendPortIn.connect(
|
||||
new Email(
|
||||
emailVO.getTo(),
|
||||
null,
|
||||
emailVO.getSubject(),
|
||||
emailVO.getMsgType(),
|
||||
emailVO.getMessage(),
|
||||
emailVO.getMultipartFiles()));
|
||||
|
||||
redirectAttributes.addFlashAttribute(
|
||||
"operationMessage",
|
||||
messageUtil.getMessage("operation.common.email.to", emailVO.getTo()));
|
||||
|
||||
return "redirect:/addons/email/form";
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package app.module.admin.usecase.email.send.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class EmailVO {
|
||||
|
||||
@NotEmpty(message = "{valid.common.required}")
|
||||
private String to;
|
||||
|
||||
@NotEmpty(message = "{valid.common.required}")
|
||||
private String subject;
|
||||
|
||||
private String msgType;
|
||||
|
||||
@NotEmpty(message = "{valid.common.required}")
|
||||
private String message;
|
||||
|
||||
private List<MultipartFile> multipartFiles;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.admin.usecase.email.send.ports;
|
||||
|
||||
import app.module.admin.usecase.email.send.ports.application.domain.Email;
|
||||
import jakarta.mail.MessagingException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public interface EmailSendPortIn {
|
||||
|
||||
void connect(Email email) throws MessagingException, UnsupportedEncodingException;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package app.module.admin.usecase.email.send.ports.application;
|
||||
|
||||
import app.module.admin.usecase.email.send.ports.EmailSendPortIn;
|
||||
import app.module.admin.usecase.email.send.ports.application.domain.Email;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeUtility;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class EmailSendService implements EmailSendPortIn {
|
||||
|
||||
private final JavaMailSender mailSender;
|
||||
|
||||
@Value("${spring.mail.username}")
|
||||
private String mailUsername;
|
||||
|
||||
@Override
|
||||
public void connect(Email email) throws MessagingException, UnsupportedEncodingException {
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
|
||||
mimeMessageHelper.setTo(email.getTo());
|
||||
mimeMessageHelper.setFrom(email.getFrom() != null ? email.getFrom() : mailUsername);
|
||||
mimeMessageHelper.setSubject(MimeUtility.encodeText(email.getSubject(), "UTF-8", "B"));
|
||||
mimeMessageHelper.setText(email.getMessage(), "HTML".equals(email.getMsgType()));
|
||||
|
||||
if (email.getMultipartFiles() != null) {
|
||||
for (MultipartFile multipartFile : email.getMultipartFiles()) {
|
||||
if (!multipartFile.isEmpty()) {
|
||||
mimeMessageHelper.addAttachment(
|
||||
Objects.requireNonNull(multipartFile.getOriginalFilename()), multipartFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mailSender.send(mimeMessage);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package app.module.admin.usecase.email.send.ports.application.domain;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Email {
|
||||
|
||||
private String to;
|
||||
private String from;
|
||||
private String subject;
|
||||
private String msgType;
|
||||
private String message;
|
||||
private List<MultipartFile> multipartFiles;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package app.module.admin.usecase.home.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.AdminUtil;
|
||||
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.GetSmsAutoStatusPortIn;
|
||||
import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import java.security.Principal;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
public class HomeController {
|
||||
|
||||
private final AdminViewPortIn adminViewPortIn;
|
||||
private final GetSmsAutoStatusPortIn getSmsAutoStatusPortIn;
|
||||
|
||||
@GetMapping
|
||||
public String home(Principal principal, Model model) {
|
||||
@@ -25,6 +28,9 @@ public class HomeController {
|
||||
model.addAttribute("loginUserRoles", loginUser.getRole());
|
||||
});
|
||||
|
||||
model.addAttribute("smsActive",
|
||||
getSmsAutoStatusPortIn.operate().orElse(null).getActive());
|
||||
|
||||
return "home";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ class CreateHouseholdDao implements CreateHouseholdPortOut {
|
||||
private final CreateHouseholdMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@CreateCommand
|
||||
public void operate(CreateHouseholdOutCmd outCmd) {
|
||||
// 임가 등록
|
||||
|
||||
@@ -52,6 +52,8 @@ class CreateHouseholdController {
|
||||
reqVO.getIndustryDetail(),
|
||||
reqVO.getResearcherSeq(),
|
||||
reqVO.getIsPanel(),
|
||||
reqVO.getUsageType().name(),
|
||||
reqVO.getEmploymentType().name(),
|
||||
reqVO.getMemo()
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package app.module.admin.usecase.household.createHousehold.adapters.web.model;
|
||||
|
||||
import app.module.admin.config.application.enums.EmploymentType;
|
||||
import app.module.admin.config.application.enums.UsageType;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -33,5 +35,7 @@ public class CreateHouseholdReqVO {
|
||||
private String industryDetail;
|
||||
private Long researcherSeq;
|
||||
private Boolean isPanel;
|
||||
private UsageType usageType;
|
||||
private EmploymentType employmentType;
|
||||
private String memo;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdP
|
||||
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortOut;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdInCmd;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdOutCmd;
|
||||
import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortIn;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class CreateHouseholdService implements CreateHouseholdPortIn {
|
||||
@@ -20,8 +24,10 @@ class CreateHouseholdService implements CreateHouseholdPortIn {
|
||||
private final CreateHouseholdPortOut portOut;
|
||||
private final BCryptPasswordEncoder passwordEncoder;
|
||||
private final CheckHouseholdNumPortIn checkHouseholdNumPortIn;
|
||||
private final AutoSchedulesPortIn autoSchedulesPortIn;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void operate(CreateHouseholdInCmd inCmd) {
|
||||
|
||||
// 임가번호 중복체크
|
||||
@@ -34,28 +40,40 @@ class CreateHouseholdService implements CreateHouseholdPortIn {
|
||||
});
|
||||
}
|
||||
|
||||
portOut.operate(new CreateHouseholdOutCmd(
|
||||
null,
|
||||
inCmd.getHouseholdNum(),
|
||||
inCmd.getOwnerName(),
|
||||
inCmd.getOwnerAge(),
|
||||
(!StringUtils.hasText(inCmd.getTel2()) || !StringUtils.hasText(inCmd.getTel3()))
|
||||
? null
|
||||
: inCmd.getTel1() + "-" + inCmd.getTel2() + "-" + inCmd.getTel3(),
|
||||
inCmd.getPhone1() + "-" + inCmd.getPhone2() + "-" + inCmd.getPhone3(),
|
||||
passwordEncoder.encode(inCmd.getPhone3()), // 비밀번호 핸드폰 뒤 네자리
|
||||
inCmd.getRegionMainCode(),
|
||||
inCmd.getRegionSubCode(),
|
||||
inCmd.getRegionDetailCode(),
|
||||
inCmd.getAddress(),
|
||||
inCmd.getIndustryLargeCode(),
|
||||
inCmd.getIndustryMiddleCode(),
|
||||
inCmd.getIndustrySubMiddle(),
|
||||
inCmd.getIndustryDetail(),
|
||||
inCmd.getResearcherSeq(),
|
||||
inCmd.getIsPanel(),
|
||||
inCmd.getMemo(),
|
||||
List.of("ROLE_GENERAL")
|
||||
));
|
||||
// 임가 등록
|
||||
try {
|
||||
portOut.operate(new CreateHouseholdOutCmd(
|
||||
null,
|
||||
inCmd.getHouseholdNum(),
|
||||
inCmd.getOwnerName(),
|
||||
inCmd.getOwnerAge(),
|
||||
(!StringUtils.hasText(inCmd.getTel2()) || !StringUtils.hasText(inCmd.getTel3()))
|
||||
? null
|
||||
: inCmd.getTel1() + "-" + inCmd.getTel2() + "-" + inCmd.getTel3(),
|
||||
inCmd.getPhone1() + "-" + inCmd.getPhone2() + "-" + inCmd.getPhone3(),
|
||||
passwordEncoder.encode(inCmd.getPhone3()),
|
||||
inCmd.getRegionMainCode(),
|
||||
inCmd.getRegionSubCode(),
|
||||
inCmd.getRegionDetailCode(),
|
||||
inCmd.getAddress(),
|
||||
inCmd.getIndustryLargeCode(),
|
||||
inCmd.getIndustryMiddleCode(),
|
||||
inCmd.getIndustrySubMiddle(),
|
||||
inCmd.getIndustryDetail(),
|
||||
inCmd.getResearcherSeq(),
|
||||
inCmd.getIsPanel(),
|
||||
inCmd.getUsageType(),
|
||||
inCmd.getEmploymentType(),
|
||||
inCmd.getMemo(),
|
||||
List.of("ROLE_GENERAL")
|
||||
));
|
||||
|
||||
// 월별 입력 현황 레코드 추가
|
||||
autoSchedulesPortIn.operate();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,7 @@ public class CreateHouseholdInCmd {
|
||||
private String industryDetail;
|
||||
private Long researcherSeq;
|
||||
private Boolean isPanel;
|
||||
private String usageType;
|
||||
private String employmentType;
|
||||
private String memo;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public class CreateHouseholdOutCmd extends AuditCommand {
|
||||
private String industryDetail;
|
||||
private Long researcherSeq;
|
||||
private Boolean isPanel;
|
||||
private String usageType;
|
||||
private String employmentType;
|
||||
private String memo;
|
||||
private List<String> roleIds;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain.GetDailyRecords;
|
||||
import app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain.GetHouseholds;
|
||||
import app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain.GetVisitInfos;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain.GetHouseholdsExcelCmd;
|
||||
import app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.GetHouseholdsExcelPortOut;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetHouseholdsExcelDao implements GetHouseholdsExcelPortOut {
|
||||
private final GetHouseholdsExcelMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<GetHouseholds> households(GetHouseholdsExcelCmd cmd) {
|
||||
return mapper.households(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GetDailyRecords> dailyRecords(GetHouseholdsExcelCmd cmd) {
|
||||
return mapper.dailyRecords(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GetVisitInfos> visitInfos(GetHouseholdsExcelCmd cmd) {
|
||||
return mapper.visitInfos(cmd);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user