[삭제] 미사용 파일 삭제 - Article, Email
This commit is contained in:
@@ -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,14 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticleCreateUI.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleUIReqVO {
|
||||
|
||||
}
|
||||
@@ -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,14 +0,0 @@
|
||||
package app.module.admin.usecase.article.getArticleUpdateUI.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleUpdateUIReqVO {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,11 +1,4 @@
|
||||
uri=Home
|
||||
uri.admin.board=\uAC8C\uC2DC\uD310
|
||||
uri.admin.board.exampleBoard=(deprecated) \uC608\uC81C \uAC8C\uC2DC\uD310
|
||||
uri.admin.board.exampleBoard.create=(deprecated) \uC608\uC81C \uAC8C\uC2DC\uD310 \uB4F1\uB85D
|
||||
uri.admin.board.exampleBoard.update.{{pathVar}}=(deprecated) \uC608\uC81C \uAC8C\uC2DC\uD310 \uC218\uC815
|
||||
uri.admin.board.article=\uC608\uC81C \uAC8C\uC2DC\uD310
|
||||
uri.admin.board.article.create=\uC608\uC81C \uAC8C\uC2DC\uD310 \uB4F1\uB85D
|
||||
uri.admin.board.article.update.{{pathVar}}=\uC608\uC81C \uAC8C\uC2DC\uD310 \uC218\uC815
|
||||
uri.admin.settings=Settings
|
||||
uri.admin.settings.admins.group=\uAD00\uB9AC\uC790 & \uC5ED\uD560
|
||||
uri.admin.settings.admins=\uAD00\uB9AC\uC790
|
||||
@@ -24,9 +17,6 @@ uri.admin.settings.user.privilege=\uC0AC\uC6A9\uC790 \uAD8C\uD55C (Privilege)
|
||||
uri.admin.analysis=\uBD84\uC11D
|
||||
uri.admin.analysis.operationLog=Operation Log (\uC218\uD589\uB85C\uADF8)
|
||||
uri.admin.analysis.operationLog.{{pathVar}}=\uC218\uD589\uB85C\uADF8 \uC0C1\uC138
|
||||
uri.admin.addons=Add-ons (\uBD80\uAC00\uAE30\uB2A5)
|
||||
uri.admin.addons.email=Email
|
||||
uri.admin.addons.email.create=Email \uBC1C\uC1A1\uD3FC
|
||||
|
||||
uri.admin.household=\uC784\uAC00 \uD604\uD669
|
||||
uri.admin.household.households=\uC784\uAC00 \uD604\uD669
|
||||
|
||||
@@ -1,333 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<form autocomplete="off" method="get" name="reqForm" th:action="@{/board/articles}"
|
||||
th:object="${reqVO}">
|
||||
|
||||
<!-- hidden parameters -->
|
||||
<input name="sort" th:field="*{sort}" type="hidden"/>
|
||||
<input name="page" th:field="*{page}" type="hidden"/>
|
||||
|
||||
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
|
||||
<div class="col-5">
|
||||
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
|
||||
<select class="form-select d-inline w-25" id="searchField"
|
||||
th:field="*{searchField}">
|
||||
<option selected value="">선택</option>
|
||||
<option value="title">제목</option>
|
||||
<option value="updatedBy">작성자</option>
|
||||
</select> <label>
|
||||
<input class="form-control d-inline" placeholder="검색어를 입력하세요."
|
||||
style="width: 250px;" th:field="*{searchValue}"
|
||||
type="text">
|
||||
</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="col-sm-3 col-form-label" for="searchOpen">공개여부</label>
|
||||
<select class="form-select d-inline w-25" id="searchOpen"
|
||||
th:field="*{searchOpen}">
|
||||
<option selected value="">전체</option>
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-outline-secondary" onclick="goSearch();"
|
||||
type="button">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="goInit();" type="button">
|
||||
초기화
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<div class="fw-bolder text-muted">
|
||||
TOTAL. <span id="totalElements"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<i class="bi bi-list-ol"></i> <label>
|
||||
<select
|
||||
class="form-select form-select-sm" id="pageSize" name="size"
|
||||
onchange="goSearch()"
|
||||
th:field="*{size}">
|
||||
<option
|
||||
th:each="item : ${pageRows}"
|
||||
th:text="${item.codeText}" th:value="${item.codeValue}"></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col" style="width:40px;"><label>
|
||||
<input class="form-check-input"
|
||||
onchange="toggleCheckbox(this);" type="checkbox"/></label>
|
||||
</th>
|
||||
<th scope="col" style="width:60px;"></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="title"
|
||||
href="#">제목</a>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<a class="order-able text-center d-inline-block w-100" data-sort-field="visible"
|
||||
href="#">공개여부</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="startDate"
|
||||
href="#">게시일</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="endDate"
|
||||
href="#">종료일</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="updatedBy"
|
||||
href="#">최근 수정자</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="updatedAt"
|
||||
href="#">최근 수정일</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="orderNo"
|
||||
href="#">정렬번호</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="sortable" id="listTBody">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="row paging"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<button class="btn btn-outline-secondary" onclick="goExcel();" type="button">
|
||||
<i class="bi bi-file-earmark-spreadsheet"></i> 엑셀 다운로드
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-outline-secondary" onclick="goSave();"
|
||||
type="button">
|
||||
<i class="bi bi-save2"></i> 등록
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="goRemove();" type="button">
|
||||
<i class="bi bi-ui-checks-grid"></i> 삭제
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="uiUtil.sortable.update();" type="button">
|
||||
<i class="bi bi-distribute-vertical"></i> 정렬 변경
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const INIT_SORT = 'orderNo,DESC';
|
||||
|
||||
const getArticles = (pageNo) => {
|
||||
const f = document.reqForm;
|
||||
f.page.value = pageNo;
|
||||
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/api/board/articles',
|
||||
data: dataOj,
|
||||
success(response) {
|
||||
console.log(response);
|
||||
|
||||
$('#totalElements').text(response.totalElements);
|
||||
|
||||
// List 구성하기
|
||||
const tbody = $('#listTBody');
|
||||
tbody.empty();
|
||||
|
||||
$(response.content).each((idx, ct) => {
|
||||
tbody.append(
|
||||
`
|
||||
<tr data-order-no="${ct.orderNo}"
|
||||
data-id="${ct.id}">
|
||||
<th
|
||||
scope="row">${idx + (pageNo * f.size.value) + 1}</th>
|
||||
<td><label>
|
||||
<input class="form-check-input"
|
||||
name="selectIds" type="checkbox" value="${ct.id}"/></label></td>
|
||||
<td><img
|
||||
src="${ct.uploadFile ? uiUtil.getFileReferURL('inline', ct.uploadFile)
|
||||
: '/static/ui/img/default-img.jpg'}"
|
||||
style="width: 25px;"
|
||||
class="img-thumbnail"/></td>
|
||||
<td><a href="javascript:goUpdate(${ct.id})">${ct.title}</a></td>
|
||||
<td class="text-secondary text-center">${ct.visible ? 'Y' : 'N'}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.startDate)}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.endDate)}</td>
|
||||
<td>${ct.updatedBy}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.updatedAt)}</td>
|
||||
<td class="text-center">${ct.orderNo} <i
|
||||
class="bi bi-distribute-vertical handle float-end fw-bold"
|
||||
style="cursor: move"></i></td>
|
||||
</tr>
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
if (!$(response.content).length) {
|
||||
tbody.append(`
|
||||
<tr>
|
||||
<td colspan="10" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
|
||||
</tr>
|
||||
`);
|
||||
}
|
||||
|
||||
// Pagination 구성하기
|
||||
const paging = $('.paging');
|
||||
paging.empty();
|
||||
paging.append(
|
||||
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
|
||||
(movePageNo) => {
|
||||
f.page.value = movePageNo;
|
||||
goSearch();
|
||||
}));
|
||||
|
||||
// 리스트 상단 정렬 notation 및 갱신 기능 적용
|
||||
uiUtil.addSortNotation(f.sort.value, (targetPage, targetSort) => {
|
||||
f.page.value = targetPage;
|
||||
f.sort.value = targetSort;
|
||||
goSearch();
|
||||
});
|
||||
|
||||
// sort 기능 적용
|
||||
uiUtil.sortable.init(
|
||||
// 드래그 가능 범위 지정 셀렉터
|
||||
'.sortable',
|
||||
// 드래그 핸들바 지정 셀렉터
|
||||
'.handle',
|
||||
// 현재 정렬이 orderNo,DESC 여부 검사 로직
|
||||
() => {
|
||||
return $('input[name=sort]').val() === INIT_SORT
|
||||
},
|
||||
// orderNo,DESC 로 정렬 변경 로직
|
||||
() => {
|
||||
f.sort.value = INIT_SORT;
|
||||
getArticles(0);
|
||||
},
|
||||
// 정렬변경 수행 로직
|
||||
(updateData) => {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
url: '/api/board/articles/sort',
|
||||
data: JSON.stringify(updateData),
|
||||
contentType: "application/json; charset=utf-8;",
|
||||
dataType: "json",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function () {
|
||||
alert('[[#{operation.orderNo.updated}]]');
|
||||
getArticles(f.page.value);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 최초 리스트 로드
|
||||
getArticles(document.reqForm.page.value);
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
const goSearch = () => {
|
||||
const f = document.reqForm;
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 초기화
|
||||
function goInit() {
|
||||
const f = document.reqForm;
|
||||
f.searchField.value = '';
|
||||
f.searchValue.value = '';
|
||||
f.searchOpen.value = '';
|
||||
}
|
||||
|
||||
// 저장페이지 이동
|
||||
function goSave() {
|
||||
location.href = '/board/articles/create';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
function goUpdate(itemId) {
|
||||
location.href = '/board/articles/' + itemId;
|
||||
}
|
||||
|
||||
function goExcel() {
|
||||
const f = document.reqForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
// size 를 제거하면 전체 목록을 가져온다.
|
||||
delete data.size;
|
||||
|
||||
location.href = '/api/board/articles/excel?' + new URLSearchParams(data).toString();
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
function toggleCheckbox(oj) {
|
||||
$('input[name=selectIds]').prop("checked", oj.checked);
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
if (!$('input[name=selectIds]').is(':checked')) {
|
||||
alert(/*[[#{operation.common.remove.choose}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
||||
const f = document.reqForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'DELETE',
|
||||
'url': '/api/board/articles/remove',
|
||||
'data': {
|
||||
'selectIds': data.selectIds
|
||||
},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
alert('선택한 아이템이 삭제되었습니다.');
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,193 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<form
|
||||
class="fw-bold"
|
||||
method="post" name="reqForm" th:action="@{/board/articles/create}">
|
||||
|
||||
<div class="container">
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="title">제목 *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control unescapeText" id="title" name="title"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="boardStartDate">게시일 *</label>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
|
||||
placeholder="게시일을 선택하세요" type="text"/>
|
||||
<a class="input-button" data-toggle title="toggle">
|
||||
<i class="icon-calendar"></i>
|
||||
</a>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
|
||||
placeholder="종료일을 선택하세요" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="open">공개여부</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" id="open" name="visible">
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="content">내용 *</label>
|
||||
<div class="input-group w-100">
|
||||
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4">
|
||||
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
|
||||
<div class="input-group w-50" style="float: left">
|
||||
<input accept="image/*" class="form-control" id="representImgFile"
|
||||
name="representImgFile"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);" type="file">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
|
||||
<!-- <input type="text" class="form-control" name="repImgAlt"-->
|
||||
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
|
||||
<!-- </div>-->
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4 publicFileInputs">
|
||||
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
|
||||
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
|
||||
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
|
||||
<i class="bi bi-arrow-left"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
|
||||
<i class="bi bi-justify"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
|
||||
<i class="bi bi-save2"></i> 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<!-- web editor - tinymce -->
|
||||
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
|
||||
<script src="/static/ui/editorImageUpload.js"></script>
|
||||
|
||||
<script>
|
||||
const goSave = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
|
||||
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
|
||||
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
|
||||
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'POST',
|
||||
'url': '/api/board/articles/create',
|
||||
'data': obj,
|
||||
success: (res) => {
|
||||
alert(`'${f.title.value}' 게시물이 생성되었습니다.\n이전 화면으로 이동합니다.`);
|
||||
history.back();
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (res) {
|
||||
const resJson = res.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (res) {
|
||||
$(res.responseJSON).each((idx, oj) => {
|
||||
let target = $(f).find('[name=' + oj.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function addFileInput() {
|
||||
$('.publicFileInputs').append(`
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script th:inline="javascript">
|
||||
// init tinymce editor
|
||||
initEditor('#content');
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// date time picker
|
||||
$(".flatpickr").flatpickr({
|
||||
dateFormat: "Y-m-d\\TH:i",
|
||||
// altInput: true,
|
||||
// altFormat: "Y-m-d H:i",
|
||||
monthSelectorType: 'static',
|
||||
enableTime: true,
|
||||
time_24hr: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const goPrev = () => {
|
||||
history.back();
|
||||
}
|
||||
|
||||
const gotoList = () => {
|
||||
location.href = '/board/articles';
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,249 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<form
|
||||
class="fw-bold"
|
||||
method="post" name="reqForm" th:action="@{/board/articles/update}">
|
||||
<input name="id" th:value="${id}" type="hidden">
|
||||
<input name="orderNo" type="hidden">
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="title">제목 *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control unescapeText" id="title" name="title"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="boardStartDate">게시일 *</label>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
|
||||
placeholder="게시일을 선택하세요" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
|
||||
placeholder="종료일을 선택하세요" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="open">공개여부</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" id="open" name="visible">
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="content">내용 *</label>
|
||||
<div class="input-group w-100">
|
||||
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4">
|
||||
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
|
||||
<div class="input-group w-50" style="float: left">
|
||||
<input accept="image/*" class="form-control"
|
||||
id="representImgFile"
|
||||
name="representImgFile"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);"
|
||||
type="file">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
|
||||
<!-- <input type="text" class="form-control" name="repImgAlt"-->
|
||||
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
|
||||
<!-- </div>-->
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4 publicFileInputs">
|
||||
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
|
||||
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
|
||||
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
|
||||
<i class="bi bi-arrow-left"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
|
||||
<i class="bi bi-justify"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
|
||||
<i class="bi bi-save2"></i> 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<!-- web editor - tinymce -->
|
||||
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
|
||||
<script src="/static/ui/editorImageUpload.js"></script>
|
||||
|
||||
<script>
|
||||
const goPrev = () => {
|
||||
history.back();
|
||||
}
|
||||
|
||||
const gotoList = () => {
|
||||
location.href = '/board/articles';
|
||||
}
|
||||
|
||||
function addFileInput() {
|
||||
const inputGroup = $(`
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
$('.publicFileInputs').append(inputGroup);
|
||||
|
||||
return inputGroup;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// date time picker
|
||||
$(".flatpickr").flatpickr({
|
||||
enableTime: true,
|
||||
dateFormat: "Y-m-d\\TH:i",
|
||||
monthSelectorType: 'static',
|
||||
time_24hr: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const getArticle = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/api/board/articles/' + f.id.value,
|
||||
success(res) {
|
||||
console.log(res);
|
||||
|
||||
showAudit(res.title, res.createdBy, uiUtil.isoStrToReadable(res.createdAt)
|
||||
, res.updatedBy, uiUtil.isoStrToReadable(res.updatedAt));
|
||||
|
||||
initEditor('#content', (editor) => {
|
||||
editor.on('init', function () {
|
||||
setTimeout(() => {
|
||||
tinymce.get('content').setContent(uiUtil.unescapeHtml(res.content));
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
f.title.value = uiUtil.unescapeHtml(res.title);
|
||||
f.startDate.value = res.startDate.substring(0, 16);
|
||||
f.endDate.value = res.endDate.substring(0, 16);
|
||||
f.visible.value = res.visible;
|
||||
f.orderNo.value = res.orderNo;
|
||||
|
||||
res.uploadFiles.forEach((uploadFile) => {
|
||||
switch (uploadFile.type.name) {
|
||||
// 대표 이미지
|
||||
case 'EXAMPLE_REP':
|
||||
const input = $(f.representImgFile);
|
||||
input.parent().append(
|
||||
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
|
||||
uiUtil.showFileInfo(input, uploadFile, true);
|
||||
break;
|
||||
// 다건 첨부 파일
|
||||
case 'EXAMPLE_PUBLIC':
|
||||
let inputGroup = addFileInput();
|
||||
inputGroup.append(
|
||||
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
|
||||
uiUtil.showFileInfo(inputGroup.find('input[type=file]'), uploadFile, false);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 상세정보 얻기
|
||||
getArticle();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const goSave = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
|
||||
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
|
||||
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
|
||||
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
// 기존 에러 메세지 초기화
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
'method': 'PUT',
|
||||
'url': '/api/board/articles/update',
|
||||
'data': obj,
|
||||
success: (res) => {
|
||||
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
|
||||
history.back();
|
||||
}
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (res) {
|
||||
const resJson = res.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (res) {
|
||||
$(res.responseJSON).each((idx, oj) => {
|
||||
let target = $(f).find('[name=' + oj.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,333 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<form autocomplete="off" method="get" name="reqForm" th:action="@{/board/secArticles}"
|
||||
th:object="${reqVO}">
|
||||
|
||||
<!-- hidden parameters -->
|
||||
<input name="sort" th:field="*{sort}" type="hidden"/>
|
||||
<input name="page" th:field="*{page}" type="hidden"/>
|
||||
|
||||
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
|
||||
<div class="col-5">
|
||||
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
|
||||
<select class="form-select d-inline w-25" id="searchField"
|
||||
th:field="*{searchField}">
|
||||
<option selected value="">선택</option>
|
||||
<option value="title">제목</option>
|
||||
<option value="updatedBy">작성자</option>
|
||||
</select> <label>
|
||||
<input class="form-control d-inline" placeholder="검색어를 입력하세요."
|
||||
style="width: 250px;" th:field="*{searchValue}"
|
||||
type="text">
|
||||
</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="col-sm-3 col-form-label" for="searchOpen">공개여부</label>
|
||||
<select class="form-select d-inline w-25" id="searchOpen"
|
||||
th:field="*{searchOpen}">
|
||||
<option selected value="">전체</option>
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-outline-secondary" onclick="goSearch();"
|
||||
type="button">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="goInit();" type="button">
|
||||
초기화
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<div class="fw-bolder text-muted">
|
||||
TOTAL. <span id="totalElements"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<i class="bi bi-list-ol"></i> <label>
|
||||
<select
|
||||
class="form-select form-select-sm" id="pageSize" name="size"
|
||||
onchange="goSearch()"
|
||||
th:field="*{size}">
|
||||
<option
|
||||
th:each="item : ${pageRows}"
|
||||
th:text="${item.codeText}" th:value="${item.codeValue}"></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col" style="width:40px;"><label>
|
||||
<input class="form-check-input"
|
||||
onchange="toggleCheckbox(this);" type="checkbox"/></label>
|
||||
</th>
|
||||
<th scope="col" style="width:60px;"></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="title"
|
||||
href="#">제목</a>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<a class="order-able text-center d-inline-block w-100" data-sort-field="visible"
|
||||
href="#">공개여부</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="startDate"
|
||||
href="#">게시일</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="endDate"
|
||||
href="#">종료일</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="updatedBy"
|
||||
href="#">최근 수정자</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="updatedAt"
|
||||
href="#">최근 수정일</a></th>
|
||||
<th scope="col">
|
||||
<a class="order-able" data-sort-field="orderNo"
|
||||
href="#">정렬번호</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="sortable" id="listTBody">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="row paging"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<button class="btn btn-outline-secondary" onclick="goExcel();" type="button">
|
||||
<i class="bi bi-file-earmark-spreadsheet"></i> 엑셀 다운로드
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-outline-secondary" onclick="goSave();"
|
||||
type="button">
|
||||
<i class="bi bi-save2"></i> 등록
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="goRemove();" type="button">
|
||||
<i class="bi bi-ui-checks-grid"></i> 삭제
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="uiUtil.sortable.update();" type="button">
|
||||
<i class="bi bi-distribute-vertical"></i> 정렬 변경
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const INIT_SORT = 'orderNo,DESC';
|
||||
|
||||
const getArticles = (pageNo) => {
|
||||
const f = document.reqForm;
|
||||
f.page.value = pageNo;
|
||||
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/api/board/secArticles',
|
||||
data: dataOj,
|
||||
success(response) {
|
||||
console.log(response);
|
||||
|
||||
$('#totalElements').text(response.totalElements);
|
||||
|
||||
// List 구성하기
|
||||
const tbody = $('#listTBody');
|
||||
tbody.empty();
|
||||
|
||||
$(response.content).each((idx, ct) => {
|
||||
tbody.append(
|
||||
`
|
||||
<tr data-order-no="${ct.orderNo}"
|
||||
data-id="${ct.id}">
|
||||
<th
|
||||
scope="row">${idx + (pageNo * f.size.value) + 1}</th>
|
||||
<td><label>
|
||||
<input class="form-check-input"
|
||||
name="selectIds" type="checkbox" value="${ct.id}"/></label></td>
|
||||
<td><img
|
||||
src="${ct.uploadFile ? uiUtil.getFileReferURL('inline', ct.uploadFile)
|
||||
: '/static/ui/img/default-img.jpg'}"
|
||||
style="width: 25px;"
|
||||
class="img-thumbnail"/></td>
|
||||
<td><a href="javascript:goUpdate(${ct.id})">${ct.title}</a></td>
|
||||
<td class="text-secondary text-center">${ct.visible ? 'Y' : 'N'}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.startDate)}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.endDate)}</td>
|
||||
<td>${ct.updatedBy}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.updatedAt)}</td>
|
||||
<td class="text-center">${ct.orderNo} <i
|
||||
class="bi bi-distribute-vertical handle float-end fw-bold"
|
||||
style="cursor: move"></i></td>
|
||||
</tr>
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
if (!$(response.content).length) {
|
||||
tbody.append(`
|
||||
<tr>
|
||||
<td colspan="10" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
|
||||
</tr>
|
||||
`);
|
||||
}
|
||||
|
||||
// Pagination 구성하기
|
||||
const paging = $('.paging');
|
||||
paging.empty();
|
||||
paging.append(
|
||||
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
|
||||
(movePageNo) => {
|
||||
f.page.value = movePageNo;
|
||||
goSearch();
|
||||
}));
|
||||
|
||||
// 리스트 상단 정렬 notation 및 갱신 기능 적용
|
||||
uiUtil.addSortNotation(f.sort.value, (targetPage, targetSort) => {
|
||||
f.page.value = targetPage;
|
||||
f.sort.value = targetSort;
|
||||
goSearch();
|
||||
});
|
||||
|
||||
// sort 기능 적용
|
||||
uiUtil.sortable.init(
|
||||
// 드래그 가능 범위 지정 셀렉터
|
||||
'.sortable',
|
||||
// 드래그 핸들바 지정 셀렉터
|
||||
'.handle',
|
||||
// 현재 정렬이 orderNo,DESC 여부 검사 로직
|
||||
() => {
|
||||
return $('input[name=sort]').val() === INIT_SORT
|
||||
},
|
||||
// orderNo,DESC 로 정렬 변경 로직
|
||||
() => {
|
||||
f.sort.value = INIT_SORT;
|
||||
getArticles(0);
|
||||
},
|
||||
// 정렬변경 수행 로직
|
||||
(updateData) => {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
url: '/api/board/secArticles/sort',
|
||||
data: JSON.stringify(updateData),
|
||||
contentType: "application/json; charset=utf-8;",
|
||||
dataType: "json",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function () {
|
||||
alert('[[#{operation.orderNo.updated}]]');
|
||||
getArticles(f.page.value);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 최초 리스트 로드
|
||||
getArticles(document.reqForm.page.value);
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
const goSearch = () => {
|
||||
const f = document.reqForm;
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 초기화
|
||||
function goInit() {
|
||||
const f = document.reqForm;
|
||||
f.searchField.value = '';
|
||||
f.searchValue.value = '';
|
||||
f.searchOpen.value = '';
|
||||
}
|
||||
|
||||
// 저장페이지 이동
|
||||
function goSave() {
|
||||
location.href = '/board/secArticles/create';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
function goUpdate(itemId) {
|
||||
location.href = '/board/secArticles/' + itemId;
|
||||
}
|
||||
|
||||
function goExcel() {
|
||||
const f = document.reqForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
// size 를 제거하면 전체 목록을 가져온다.
|
||||
delete data.size;
|
||||
|
||||
location.href = '/api/board/secArticles/excel?' + new URLSearchParams(data).toString();
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
function toggleCheckbox(oj) {
|
||||
$('input[name=selectIds]').prop("checked", oj.checked);
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
if (!$('input[name=selectIds]').is(':checked')) {
|
||||
alert(/*[[#{operation.common.remove.choose}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
||||
const f = document.reqForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'DELETE',
|
||||
'url': '/api/board/secArticles/remove',
|
||||
'data': {
|
||||
'selectIds': data.selectIds
|
||||
},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
alert('선택한 아이템이 삭제되었습니다.');
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,193 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<form
|
||||
class="fw-bold"
|
||||
method="post" name="reqForm" th:action="@{/board/secArticles/create}">
|
||||
|
||||
<div class="container">
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="title">제목 *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control unescapeText" id="title" name="title"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="boardStartDate">게시일 *</label>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
|
||||
placeholder="게시일을 선택하세요" type="text"/>
|
||||
<a class="input-button" data-toggle title="toggle">
|
||||
<i class="icon-calendar"></i>
|
||||
</a>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
|
||||
placeholder="종료일을 선택하세요" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="open">공개여부</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" id="open" name="visible">
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="content">내용 *</label>
|
||||
<div class="input-group w-100">
|
||||
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4">
|
||||
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
|
||||
<div class="input-group w-50" style="float: left">
|
||||
<input accept="image/*" class="form-control" id="representImgFile"
|
||||
name="representImgFile"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);" type="file">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
|
||||
<!-- <input type="text" class="form-control" name="repImgAlt"-->
|
||||
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
|
||||
<!-- </div>-->
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4 publicFileInputs">
|
||||
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
|
||||
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
|
||||
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
|
||||
<i class="bi bi-arrow-left"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
|
||||
<i class="bi bi-justify"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
|
||||
<i class="bi bi-save2"></i> 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<!-- web editor - tinymce -->
|
||||
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
|
||||
<script src="/static/ui/editorImageUpload.js"></script>
|
||||
|
||||
<script>
|
||||
const goSave = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
|
||||
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
|
||||
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
|
||||
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'POST',
|
||||
'url': '/api/board/secArticles/create',
|
||||
'data': obj,
|
||||
success: (res) => {
|
||||
alert(`'${f.title.value}' 게시물이 생성되었습니다.\n이전 화면으로 이동합니다.`);
|
||||
history.back();
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (res) {
|
||||
const resJson = res.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (res) {
|
||||
$(res.responseJSON).each((idx, oj) => {
|
||||
let target = $(f).find('[name=' + oj.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function addFileInput() {
|
||||
$('.publicFileInputs').append(`
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script th:inline="javascript">
|
||||
// init tinymce editor
|
||||
initEditor('#content');
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// date time picker
|
||||
$(".flatpickr").flatpickr({
|
||||
dateFormat: "Y-m-d\\TH:i",
|
||||
// altInput: true,
|
||||
// altFormat: "Y-m-d H:i",
|
||||
monthSelectorType: 'static',
|
||||
enableTime: true,
|
||||
time_24hr: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const goPrev = () => {
|
||||
history.back();
|
||||
}
|
||||
|
||||
const gotoList = () => {
|
||||
location.href = '/board/secArticles';
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,253 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<form
|
||||
class="fw-bold"
|
||||
method="post" name="reqForm" th:action="@{/board/secArticles/update}">
|
||||
<input name="id" th:value="${id}" type="hidden">
|
||||
<input name="orderNo" type="hidden">
|
||||
<input name="createdAt" type="hidden">
|
||||
<input name="createdBy" type="hidden">
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="title">제목 *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control unescapeText" id="title" name="title"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="boardStartDate">게시일 *</label>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
|
||||
placeholder="게시일을 선택하세요" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
|
||||
placeholder="종료일을 선택하세요" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="open">공개여부</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" id="open" name="visible">
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="content">내용 *</label>
|
||||
<div class="input-group w-100">
|
||||
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4">
|
||||
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
|
||||
<div class="input-group w-50" style="float: left">
|
||||
<input accept="image/*" class="form-control"
|
||||
id="representImgFile"
|
||||
name="representImgFile"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);"
|
||||
type="file">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
|
||||
<!-- <input type="text" class="form-control" name="repImgAlt"-->
|
||||
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
|
||||
<!-- </div>-->
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 mt-4 publicFileInputs">
|
||||
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
|
||||
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
|
||||
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
|
||||
<i class="bi bi-arrow-left"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
|
||||
<i class="bi bi-justify"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
|
||||
<i class="bi bi-save2"></i> 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<!-- web editor - tinymce -->
|
||||
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
|
||||
<script src="/static/ui/editorImageUpload.js"></script>
|
||||
|
||||
<script>
|
||||
const goPrev = () => {
|
||||
history.back();
|
||||
}
|
||||
|
||||
const gotoList = () => {
|
||||
location.href = '/board/secArticles';
|
||||
}
|
||||
|
||||
function addFileInput() {
|
||||
const inputGroup = $(`
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
||||
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
$('.publicFileInputs').append(inputGroup);
|
||||
|
||||
return inputGroup;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// date time picker
|
||||
$(".flatpickr").flatpickr({
|
||||
enableTime: true,
|
||||
dateFormat: "Y-m-d\\TH:i",
|
||||
monthSelectorType: 'static',
|
||||
time_24hr: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const getArticle = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/api/board/secArticles/' + f.id.value,
|
||||
success(res) {
|
||||
console.log(res);
|
||||
|
||||
showAudit(res.title, res.createdBy, uiUtil.isoStrToReadable(res.createdAt)
|
||||
, res.updatedBy, uiUtil.isoStrToReadable(res.updatedAt));
|
||||
|
||||
initEditor('#content', (editor) => {
|
||||
editor.on('init', function () {
|
||||
setTimeout(() => {
|
||||
tinymce.get('content').setContent(uiUtil.unescapeHtml(res.content));
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
f.title.value = uiUtil.unescapeHtml(res.title);
|
||||
f.startDate.value = res.startDate.substring(0, 16);
|
||||
f.endDate.value = res.endDate.substring(0, 16);
|
||||
f.visible.value = res.visible;
|
||||
f.orderNo.value = res.orderNo;
|
||||
f.createdAt.value = res.createdAt;
|
||||
f.createdBy.value = res.createdBy;
|
||||
|
||||
res.uploadFiles.forEach((uploadFile) => {
|
||||
switch (uploadFile.type.name) {
|
||||
// 대표 이미지
|
||||
case 'EXAMPLE_REP':
|
||||
const input = $(f.representImgFile);
|
||||
input.parent().append(
|
||||
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
|
||||
uiUtil.showFileInfo(input, uploadFile, true);
|
||||
break;
|
||||
// 다건 첨부 파일
|
||||
case 'EXAMPLE_PUBLIC':
|
||||
let inputGroup = addFileInput();
|
||||
inputGroup.append(
|
||||
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
|
||||
uiUtil.showFileInfo(inputGroup.find('input[type=file]'), uploadFile, false);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 상세정보 얻기
|
||||
getArticle();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const goSave = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
|
||||
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
|
||||
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
|
||||
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
// 기존 에러 메세지 초기화
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
'method': 'PUT',
|
||||
'url': '/api/board/secArticles/update',
|
||||
'data': obj,
|
||||
success: (res) => {
|
||||
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
|
||||
history.back();
|
||||
}
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (res) {
|
||||
const resJson = res.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (res) {
|
||||
$(res.responseJSON).each((idx, oj) => {
|
||||
let target = $(f).find('[name=' + oj.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,88 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<form class="fw-bold" enctype="multipart/form-data" method="post"
|
||||
th:action="@{/addons/email/form}" th:object="${formDto}">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="id">To *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="id" th:classappend="${#fields.hasErrors('to')} ? 'is-invalid'" th:field="*{to}"
|
||||
type="email"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{to}" th:if="${#fields.hasErrors('to')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="subject">Subject *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="subject" th:classappend="${#fields.hasErrors('subject')} ? 'is-invalid'"
|
||||
th:field="*{subject}"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{subject}"
|
||||
th:if="${#fields.hasErrors('subject')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="msgType">Message Type *</label>
|
||||
<div class="col-sm-4">
|
||||
<input checked class="form-check-input" id="msgType" name="msgType" type="radio"
|
||||
value="HTML"/>
|
||||
<label class="form-check-label" for="msgType">HTML</label>
|
||||
<input class="form-check-input" id="msgType2" name="msgType" type="radio" value="TEXT"/>
|
||||
<label class="form-check-label" for="msgType2">TEXT</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="message">Message *</label>
|
||||
<div class="col-sm-4">
|
||||
<textarea class="form-control" id="message" th:classappend="${#fields.hasErrors('message')} ? 'is-invalid'" th:field="*{message}"
|
||||
type="text"></textarea>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{message}"
|
||||
th:if="${#fields.hasErrors('message')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 publicFileInputs">
|
||||
<label class="form-label d-block" for="formFile1">파일 첨부</label>
|
||||
<input class="form-control w-50 d-inline-block mb-2" id="formFile1" name="multipartFiles"
|
||||
type="file">
|
||||
<button class="btn btn-success d-inline-block align-top" onclick="addFileInput('public');"
|
||||
type="button">추가
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary" type="submit">발송</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function addFileInput(type) {
|
||||
let tmpl = $.templates('#fileInputTmpl');
|
||||
switch (type) {
|
||||
case 'public':
|
||||
$('.publicFileInputs').append(tmpl.render({'name': 'multipartFiles'}));
|
||||
break;
|
||||
case 'private':
|
||||
$('.privateFileInputs').append(tmpl.render({'name': 'privateFiles'}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fileInputTmpl" type="text/x-jsrender">
|
||||
<input class="form-control w-50 mb-2" type="file" name="{{:name}}"/>
|
||||
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,56 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.entity;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditEntity;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class Article extends AuditEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
private Boolean visible;
|
||||
|
||||
private LocalDateTime startDate;
|
||||
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private Integer orderNo;
|
||||
|
||||
private List<UploadFile> uploadFiles = Collections.emptyList();
|
||||
|
||||
private List<ArticleComment> articleComments = Collections.emptyList();
|
||||
|
||||
public Article(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Article(
|
||||
Long id,
|
||||
String title,
|
||||
String content,
|
||||
Boolean visible,
|
||||
LocalDateTime startDate,
|
||||
LocalDateTime endDate,
|
||||
Integer orderNo,
|
||||
List<UploadFile> uploadFiles) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
this.visible = visible;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.orderNo = orderNo;
|
||||
this.uploadFiles = (uploadFiles != null) ? uploadFiles : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.entity;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ArticleComment extends AuditEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String content;
|
||||
|
||||
private Long articleId;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.entity;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ArticleHasUploadFile extends AuditEntity {
|
||||
|
||||
private Long articleId;
|
||||
|
||||
private Long uploadFilesId;
|
||||
|
||||
public ArticleHasUploadFile(Long articleId) {
|
||||
this.articleId = articleId;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.initData;
|
||||
|
||||
import app.module.core.config.adapters.persistence.initData.helper.RemoveAllArticleMapper;
|
||||
import app.module.core.usecase.article.createArticle.ports.CreateArticlePortIn;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.stream.IntStream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class InitArticleData implements ApplicationRunner {
|
||||
|
||||
private final CreateArticlePortIn createArticlePortIn;
|
||||
private final RemoveAllArticleMapper removeAllArticleMapper;
|
||||
|
||||
@Value("${app.initData.core}")
|
||||
private boolean isCoreDataRequired;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
if (!isCoreDataRequired) {
|
||||
return;
|
||||
}
|
||||
|
||||
// article_has_upload_file 테이블 우선 삭제
|
||||
removeAllArticleMapper.deleteAllFiles();
|
||||
// article_comment 테이블 우선 삭제
|
||||
removeAllArticleMapper.deleteAllComments();
|
||||
// article 전체 데이터 삭제
|
||||
removeAllArticleMapper.deleteAll();
|
||||
|
||||
IntStream.range(0, 25)
|
||||
.forEach(
|
||||
idx ->
|
||||
createArticlePortIn.operate(
|
||||
new CreateArticleCmd(
|
||||
String.format("Article No.%s", idx),
|
||||
String.format("Content No.%s", idx),
|
||||
true,
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now().plusMonths(2),
|
||||
null)));
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
|
||||
final String ADMIN = "uri.admin";
|
||||
|
||||
final String ADMIN_BOARD = "uri.admin.board";
|
||||
|
||||
final String ADMIN_ARTICLE = "uri.admin.board.article";
|
||||
final String ADMIN_ARTICLE_CREATE = "uri.admin.board.article.create";
|
||||
final String ADMIN_ARTICLE_UPDATE = "uri.admin.board.article.update.{{pathVar}}";
|
||||
final String ADMIN_ARTICLE_DELETE = "uri.admin.board.article.delete";
|
||||
final String ADMIN_ARTICLE_EXCEL = "uri.admin.board.article.excel";
|
||||
|
||||
final String ADMIN_SETTINGS = "uri.admin.settings";
|
||||
|
||||
final String ADMIN_SETTINGS_ADMIN_GROUP = "uri.admin.settings.admins.group";
|
||||
@@ -69,10 +61,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
"uri.admin.analysis.operationLog.{{pathVar}}";
|
||||
final String ADMIN_ANALYSIS_OPERATION_LOG_EXCEL = "uri.admin.analysis.operationLog.excel";
|
||||
|
||||
final String ADMIN_ADD_ONS = "uri.admin.addons";
|
||||
final String ADMIN_ADD_ONS_SEND_EMAIL = "uri.admin.addons.email";
|
||||
final String ADMIN_ADD_ONS_SEND_EMAIL_CREATE = "uri.admin.addons.email.create";
|
||||
|
||||
// 임가현황 메뉴
|
||||
final String ADMIN_HOUSEHOLD = "uri.admin.household"; // 1depth
|
||||
final String ADMIN_HOUSEHOLD_STATUS = "uri.admin.household.households"; // 2depth 임가 리스트
|
||||
@@ -146,15 +134,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN,
|
||||
ADMIN_BOARD,
|
||||
"게시판",
|
||||
"/board",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN", "ROLE_LOCAL_INSPECTION", "ROLE_RESEARCHER"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN,
|
||||
@@ -164,15 +143,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN,
|
||||
ADMIN_ADD_ONS,
|
||||
"Add-ons (부가기능)",
|
||||
"/add-ons",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN,
|
||||
@@ -304,53 +274,8 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
"/communication/sms",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
// 커뮤니케이션 메뉴 끝
|
||||
|
||||
// 예제 게시판 - 시작
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_BOARD,
|
||||
ADMIN_ARTICLE,
|
||||
"예제 게시판",
|
||||
"/board/articles",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN", "ROLE_LOCAL_INSPECTION", "ROLE_RESEARCHER"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_ARTICLE,
|
||||
ADMIN_ARTICLE_CREATE,
|
||||
"예제 게시판 등록",
|
||||
"/board/articles/create",
|
||||
false,
|
||||
Set.of("ROLE_ADMIN", "ROLE_LOCAL_INSPECTION", "ROLE_RESEARCHER"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_ARTICLE,
|
||||
ADMIN_ARTICLE_UPDATE,
|
||||
"예제 게시판 수정",
|
||||
"/board/articles/{{pathVar}}",
|
||||
false,
|
||||
Set.of("ROLE_ADMIN", "ROLE_LOCAL_INSPECTION", "ROLE_RESEARCHER"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_ARTICLE,
|
||||
ADMIN_ARTICLE_DELETE,
|
||||
"예제 게시판 삭제",
|
||||
"/board/articles/delete",
|
||||
false,
|
||||
Set.of("ROLE_ADMIN", "ROLE_LOCAL_INSPECTION", "ROLE_RESEARCHER"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_ARTICLE,
|
||||
ADMIN_ARTICLE_EXCEL,
|
||||
"예제 게시판 엑셀 다운로드",
|
||||
"/board/articles/excel",
|
||||
false,
|
||||
Set.of("ROLE_ADMIN", "ROLE_LOCAL_INSPECTION", "ROLE_RESEARCHER"));
|
||||
// 예제 게시판 - 끝
|
||||
|
||||
// 분석 메뉴 시작
|
||||
appendURI(
|
||||
@@ -382,27 +307,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
// 분석 메뉴 끝
|
||||
|
||||
|
||||
// Add-ons 메뉴 시작
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_ADD_ONS,
|
||||
ADMIN_ADD_ONS_SEND_EMAIL,
|
||||
"Email 발송",
|
||||
"/addons/email/form",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_ADD_ONS_SEND_EMAIL,
|
||||
ADMIN_ADD_ONS_SEND_EMAIL_CREATE,
|
||||
"Email 입력폼",
|
||||
"/addons/email/form",
|
||||
false,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
// Add-ons 메뉴 끝
|
||||
|
||||
|
||||
// 관리자 시작
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
|
||||
@@ -109,77 +109,5 @@ public class InitUriFrontData implements ApplicationRunner {
|
||||
Set.of("ROLE_GENERAL")),
|
||||
null,
|
||||
false);
|
||||
|
||||
// 예제게시판
|
||||
uriSavePortIn.connect(
|
||||
new URISaveCommand(
|
||||
FRONT_ROOT_ID + ".board.articles",
|
||||
FRONT_ROOT_ID,
|
||||
AppType.FRONT,
|
||||
"/board/articles",
|
||||
true,
|
||||
"예제게시판",
|
||||
null,
|
||||
"예제게시판",
|
||||
"예제게시판 페이지",
|
||||
"예제게시판",
|
||||
null,
|
||||
Set.of("ROLE_GENERAL")),
|
||||
null,
|
||||
false);
|
||||
|
||||
// 예제 게시판 등록
|
||||
uriSavePortIn.connect(
|
||||
new URISaveCommand(
|
||||
FRONT_ROOT_ID + ".board.article.create",
|
||||
FRONT_ROOT_ID,
|
||||
AppType.FRONT,
|
||||
"/board/articles/create",
|
||||
false,
|
||||
"예제 게시판 등록",
|
||||
null,
|
||||
"예제 게시판 등록",
|
||||
"예제 게시판 등록 페이지",
|
||||
"예제 게시판 등록",
|
||||
null,
|
||||
Set.of("ROLE_GENERAL")),
|
||||
null,
|
||||
false);
|
||||
|
||||
// 예제 게시판 상세
|
||||
uriSavePortIn.connect(
|
||||
new URISaveCommand(
|
||||
FRONT_ROOT_ID + ".board.article.{{pathVar}}",
|
||||
FRONT_ROOT_ID,
|
||||
AppType.FRONT,
|
||||
"/board/articles/{{pathVar}}",
|
||||
false,
|
||||
"예제 게시판 상세",
|
||||
null,
|
||||
"예제 게시판 상세",
|
||||
"예제 게시판 상세 페이지",
|
||||
"예제 게시판 상세",
|
||||
null,
|
||||
Set.of("ROLE_GENERAL")),
|
||||
null,
|
||||
false);
|
||||
|
||||
// 예제 게시판 수정
|
||||
uriSavePortIn.connect(
|
||||
new URISaveCommand(
|
||||
FRONT_ROOT_ID + ".board.article.update.{{pathVar}}",
|
||||
FRONT_ROOT_ID,
|
||||
AppType.FRONT,
|
||||
"/board/articles/update/{{pathVar}}",
|
||||
false,
|
||||
"예제 게시판 수정",
|
||||
null,
|
||||
"예제 게시판 수정",
|
||||
"예제 게시판 수정 페이지",
|
||||
"예제 게시판 수정",
|
||||
null,
|
||||
Set.of("ROLE_GENERAL")),
|
||||
null,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package app.module.core.config.adapters.persistence.initData;
|
||||
|
||||
import app.module.core.config.adapters.persistence.initData.helper.RemoveAllArticleMapper;
|
||||
import app.module.core.config.adapters.persistence.initData.helper.RemoveAllMapper;
|
||||
import app.module.core.usecase.article.createArticle.ports.CreateArticlePortIn;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.stream.IntStream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.initData.helper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RemoveAllArticleMapper {
|
||||
void deleteAll();
|
||||
void deleteAllFiles();
|
||||
void deleteAllComments();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.repository;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ArticleCommentRepo {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.repository;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ArticleRepo {
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleComment;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.CreateArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleComment;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class CreateArticleCommentDao implements CreateArticleCommentPortOut {
|
||||
|
||||
private final CreateArticleCommentMapper mapper;
|
||||
|
||||
@Override
|
||||
public Optional<CreateArticleComment> operate(CreateArticleCommentCmd command) {
|
||||
|
||||
ArticleComment articleComment = new ArticleComment(
|
||||
null,
|
||||
command.getContent(),
|
||||
command.getArticleId()
|
||||
);
|
||||
|
||||
mapper.insertArticleComment(articleComment);
|
||||
|
||||
return Optional.of(
|
||||
new CreateArticleComment(
|
||||
articleComment.getId(),
|
||||
articleComment.getContent(),
|
||||
articleComment.getCreatedBy(),
|
||||
articleComment.getUpdatedAt()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CreateArticleCommentMapper {
|
||||
void insertArticleComment(ArticleComment articleComment);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleComment;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateArticleCommentPortIn {
|
||||
|
||||
Optional<CreateArticleComment> operate(CreateArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleComment;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateArticleCommentPortOut {
|
||||
|
||||
Optional<CreateArticleComment> operate(CreateArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.ports.application;
|
||||
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.CreateArticleCommentPortIn;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.CreateArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleComment;
|
||||
import app.module.core.usecase.article.comment.createArticleComment.ports.application.domain.CreateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class CreateArticleCommentService implements CreateArticleCommentPortIn {
|
||||
|
||||
private final CreateArticleCommentPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<CreateArticleComment> operate(CreateArticleCommentCmd command) {
|
||||
return portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.ports.application.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleComment {
|
||||
private Long id;
|
||||
private String content;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.createArticleComment.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleCommentCmd {
|
||||
private Long articleId;
|
||||
private String content;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.GetArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleComment;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleCommentDao implements GetArticleCommentPortOut {
|
||||
|
||||
private final GetArticleCommentMapper mapper;
|
||||
|
||||
@Override
|
||||
public Optional<GetArticleComment> operate(GetArticleCommentCmd command) {
|
||||
return mapper.findArticleCommentById(command.getId());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleComment;
|
||||
import java.util.Optional;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface GetArticleCommentMapper {
|
||||
Optional<GetArticleComment> findArticleCommentById(Long id);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleComment;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetArticleCommentPortIn {
|
||||
|
||||
Optional<GetArticleComment> operate(GetArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleComment;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetArticleCommentPortOut {
|
||||
|
||||
Optional<GetArticleComment> operate(GetArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.ports.application;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.GetArticleCommentPortIn;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.GetArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleComment;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleCommentService implements GetArticleCommentPortIn {
|
||||
|
||||
private final GetArticleCommentPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<GetArticleComment> operate(GetArticleCommentCmd command) {
|
||||
return portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleComment {
|
||||
private Long id;
|
||||
private String content;
|
||||
private Long articleId;
|
||||
private String CreatedBy;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComment.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleCommentCmd {
|
||||
private Long id;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.GetArticleCommentsPortOut;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleComments;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleCommentsCmd;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleCommentsDao implements GetArticleCommentsPortOut {
|
||||
|
||||
private final GetArticleCommentsMapper mapper;
|
||||
|
||||
@Override
|
||||
public Page<GetArticleComments> operate(Pageable pageable, GetArticleCommentsCmd command) {
|
||||
// 댓글 목록 조회
|
||||
List<GetArticleComments> result = mapper.findAll(pageable, command);
|
||||
|
||||
return new PageImpl<>(
|
||||
mapper.findAll(pageable, command),
|
||||
pageable,
|
||||
result.isEmpty() ? 0 : result.get(0).getTotal());
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleComments;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleCommentsCmd;
|
||||
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 GetArticleCommentsMapper {
|
||||
List<GetArticleComments> findAll(@Param("pageable") Pageable pageable,
|
||||
@Param("cmd") GetArticleCommentsCmd cmd);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleComments;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleCommentsCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetArticleCommentsPortIn {
|
||||
|
||||
Page<GetArticleComments> operate(Pageable pageable, GetArticleCommentsCmd command);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleComments;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleCommentsCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetArticleCommentsPortOut {
|
||||
|
||||
Page<GetArticleComments> operate(Pageable pageable, GetArticleCommentsCmd command);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.ports.application;
|
||||
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.GetArticleCommentsPortIn;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.GetArticleCommentsPortOut;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleComments;
|
||||
import app.module.core.usecase.article.comment.getArticleComments.ports.application.domain.GetArticleCommentsCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleCommentsService implements GetArticleCommentsPortIn {
|
||||
|
||||
private final GetArticleCommentsPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Page<GetArticleComments> operate(Pageable pageable, GetArticleCommentsCmd command) {
|
||||
return portOut.operate(pageable, command);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.ports.application.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleComments {
|
||||
private Long id;
|
||||
private String content;
|
||||
private Long articleId;
|
||||
private Boolean isAuthor;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private Integer total;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.getArticleComments.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleCommentsCmd {
|
||||
private Long articleId;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.adapters.persistence.model.RemoveArticleCommentParam;
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.RemoveArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.application.domain.RemoveArticleCommentCmd;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class RemoveArticleCommentDao implements RemoveArticleCommentPortOut {
|
||||
|
||||
private final RemoveArticleCommentMapper mapper;
|
||||
|
||||
@Override
|
||||
public void operate(RemoveArticleCommentCmd command) {
|
||||
String loginUser = CommonUtil.getLoginUsername();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
mapper.deleteById(
|
||||
new RemoveArticleCommentParam(
|
||||
command.getRemoveId(), now, loginUser, now, loginUser));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.adapters.persistence.model.RemoveArticleCommentParam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RemoveArticleCommentMapper {
|
||||
void deleteById(RemoveArticleCommentParam param);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.adapters.persistence.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class RemoveArticleCommentParam {
|
||||
private Long id;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private LocalDateTime deletedAt;
|
||||
private String deletedBy;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.application.domain.RemoveArticleCommentCmd;
|
||||
|
||||
public interface RemoveArticleCommentPortIn {
|
||||
|
||||
void operate(RemoveArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.application.domain.RemoveArticleCommentCmd;
|
||||
|
||||
public interface RemoveArticleCommentPortOut {
|
||||
|
||||
void operate(RemoveArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.ports.application;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.GetArticleCommentPortIn;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleCommentCmd;
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.RemoveArticleCommentPortIn;
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.RemoveArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.removeArticleComment.ports.application.domain.RemoveArticleCommentCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class RemoveArticleCommentService implements RemoveArticleCommentPortIn {
|
||||
|
||||
private final RemoveArticleCommentPortOut portOut;
|
||||
private final GetArticleCommentPortIn getArticleCommentPortIn;
|
||||
|
||||
@Override
|
||||
public void operate(RemoveArticleCommentCmd command) {
|
||||
|
||||
getArticleCommentPortIn.operate(new GetArticleCommentCmd(command.getRemoveId()))
|
||||
.filter(comment -> comment.getCreatedBy().equals(CommonUtil.getLoginUsername()))
|
||||
.orElseThrow(() -> new RuntimeException("삭제 권한이 없는 사용자입니다."));
|
||||
|
||||
portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.removeArticleComment.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveArticleCommentCmd {
|
||||
private Long removeId;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleComment;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.UpdateArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleComment;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class UpdateArticleCommentDao implements UpdateArticleCommentPortOut {
|
||||
|
||||
private final UpdateArticleCommentMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Optional<UpdateArticleComment> operate(UpdateArticleCommentCmd cmd) {
|
||||
|
||||
ArticleComment comment =
|
||||
new ArticleComment(cmd.getCommentId(), cmd.getContent(), cmd.getArticleId());
|
||||
|
||||
mapper.updateComment(comment);
|
||||
|
||||
return Optional.of(new UpdateArticleComment(comment.getId(), comment.getContent()));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UpdateArticleCommentMapper {
|
||||
void updateComment(ArticleComment articleComment);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleComment;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UpdateArticleCommentPortIn {
|
||||
|
||||
Optional<UpdateArticleComment> operate(UpdateArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.ports;
|
||||
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleComment;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UpdateArticleCommentPortOut {
|
||||
|
||||
Optional<UpdateArticleComment> operate(UpdateArticleCommentCmd command);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.ports.application;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.GetArticleCommentPortIn;
|
||||
import app.module.core.usecase.article.comment.getArticleComment.ports.application.domain.GetArticleCommentCmd;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.UpdateArticleCommentPortIn;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.UpdateArticleCommentPortOut;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleComment;
|
||||
import app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain.UpdateArticleCommentCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class UpdateArticleCommentService implements UpdateArticleCommentPortIn {
|
||||
|
||||
private final UpdateArticleCommentPortOut portOut;
|
||||
private final GetArticleCommentPortIn getArticleCommentPortIn;
|
||||
|
||||
@Override
|
||||
public Optional<UpdateArticleComment> operate(UpdateArticleCommentCmd command) {
|
||||
|
||||
getArticleCommentPortIn.operate(new GetArticleCommentCmd(command.getCommentId()))
|
||||
.filter(comment -> comment.getCreatedBy().equals(CommonUtil.getLoginUsername()))
|
||||
.orElseThrow(() -> new RuntimeException("수정 권한이 없는 사용자입니다."));
|
||||
|
||||
return portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateArticleComment {
|
||||
private Long id;
|
||||
private String content;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.core.usecase.article.comment.updateArticleComment.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateArticleCommentCmd {
|
||||
private Long commentId;
|
||||
private String content;
|
||||
private Long articleId;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.createArticle.adapters.persistence.model.CreateArticleDto;
|
||||
import app.module.core.usecase.article.createArticle.adapters.persistence.model.CreateArticleHasUploadFilesParam;
|
||||
import app.module.core.usecase.article.createArticle.ports.CreateArticlePortOut;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticle;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class CreateArticleDao implements CreateArticlePortOut {
|
||||
|
||||
private final CreateArticleMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Optional<CreateArticle> operate(CreateArticleCmd command) {
|
||||
// max orderNo
|
||||
int maxOrderNo = mapper.getArticleOrderNo();
|
||||
|
||||
CreateArticleDto dto =
|
||||
new CreateArticleDto(
|
||||
null,
|
||||
command.getTitle(),
|
||||
command.getContent(),
|
||||
command.getVisible(),
|
||||
maxOrderNo,
|
||||
command.getStartDate(),
|
||||
command.getEndDate(),
|
||||
command.getFileMappingId(),
|
||||
command.getCreatedAt(),
|
||||
command.getCreatedBy(),
|
||||
command.getUpdatedAt(),
|
||||
command.getUpdatedBy());
|
||||
|
||||
mapper.createArticle(dto);
|
||||
|
||||
if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) {
|
||||
mapper.createArticleHasUploadFile(new CreateArticleHasUploadFilesParam(
|
||||
dto.getId(),
|
||||
dto.getFileMappingId().stream()
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList()),
|
||||
dto.getCreatedAt(),
|
||||
dto.getCreatedBy(),
|
||||
dto.getUpdatedAt(),
|
||||
dto.getUpdatedBy()
|
||||
));
|
||||
}
|
||||
|
||||
return Optional.of(new CreateArticle(dto.getOrderNo(), dto.getId()));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.createArticle.adapters.persistence.model.CreateArticleDto;
|
||||
import app.module.core.usecase.article.createArticle.adapters.persistence.model.CreateArticleHasUploadFilesParam;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface CreateArticleMapper {
|
||||
int getArticleOrderNo();
|
||||
void createArticle(CreateArticleDto dto);
|
||||
void createArticleHasUploadFile(CreateArticleHasUploadFilesParam param);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.adapters.persistence.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateArticleDto {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private Integer orderNo;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private List<String> fileMappingId;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.adapters.persistence.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateArticleHasUploadFilesParam {
|
||||
private Long id;
|
||||
private List<Long> fileMappingIds;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.ports;
|
||||
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticle;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateArticlePortIn {
|
||||
|
||||
Optional<CreateArticle> operate(CreateArticleCmd command);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.ports;
|
||||
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticle;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateArticlePortOut {
|
||||
|
||||
Optional<CreateArticle> operate(CreateArticleCmd command);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.ports.application;
|
||||
|
||||
import app.module.core.config.application.annotation.CreateCommand;
|
||||
import app.module.core.usecase.article.createArticle.ports.CreateArticlePortIn;
|
||||
import app.module.core.usecase.article.createArticle.ports.CreateArticlePortOut;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticle;
|
||||
import app.module.core.usecase.article.createArticle.ports.application.domain.CreateArticleCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class CreateArticleService implements CreateArticlePortIn {
|
||||
|
||||
private final CreateArticlePortOut portOut;
|
||||
|
||||
@Override
|
||||
@CreateCommand
|
||||
public Optional<CreateArticle> operate(CreateArticleCmd command) {
|
||||
return portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticle {
|
||||
Integer orderNo;
|
||||
private Long id;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package app.module.core.usecase.article.createArticle.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateArticleCmd extends AuditCommand {
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private List<String> fileMappingId;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.enums.FileStorageType;
|
||||
import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleUploadFile;
|
||||
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleDao implements GetArticlePortOut {
|
||||
|
||||
private final GetArticleMapper mapper;
|
||||
private final FileUrlPortIn fileUrlPortIn;
|
||||
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Optional<GetArticle> operate(GetArticleCmd command) {
|
||||
GetArticle secArticle = mapper.getArticle(command.getId());
|
||||
|
||||
List<GetArticleUploadFile> setArticleUploadFile =
|
||||
mapper.getUploadFiles(command.getId());
|
||||
|
||||
secArticle.setUploadFiles(
|
||||
setArticleUploadFile.stream()
|
||||
.map(
|
||||
uploadFile -> {
|
||||
// 참조 URL 전달
|
||||
uploadFile.setReferURL(
|
||||
fileUrlPortIn.getInline(
|
||||
FileStorageType.valueOf(uploadStorageType),
|
||||
uploadFile.getPath(),
|
||||
uploadFile.getName()));
|
||||
// attachment URL 전달
|
||||
uploadFile.setAttachmentURL(
|
||||
fileUrlPortIn.getAttachment(
|
||||
FileStorageType.valueOf(uploadStorageType), uploadFile.getId()));
|
||||
|
||||
return uploadFile;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return Optional.of(secArticle);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleUploadFile;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface GetArticleMapper {
|
||||
GetArticle getArticle(Long id);
|
||||
List<GetArticleUploadFile> getUploadFiles(Long id);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.ports;
|
||||
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetArticlePortIn {
|
||||
|
||||
Optional<GetArticle> operate(GetArticleCmd command);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.ports;
|
||||
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetArticlePortOut {
|
||||
|
||||
Optional<GetArticle> operate(GetArticleCmd command);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.ports.application;
|
||||
|
||||
import app.module.core.usecase.article.getArticle.ports.GetArticlePortIn;
|
||||
import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetArticleService implements GetArticlePortIn {
|
||||
|
||||
private final GetArticlePortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<GetArticle> operate(GetArticleCmd command) {
|
||||
return portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.ports.application.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticle {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private Integer orderNo;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private List<GetArticleUploadFile> uploadFiles;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetArticleCmd {
|
||||
|
||||
private Long id;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticle.ports.application.domain;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* DTO for {@link app.module.core.config.adapters.persistence.entity.UploadFile}
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GetArticleUploadFile implements Serializable {
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private Long id;
|
||||
private FileUploadType type;
|
||||
private String path;
|
||||
private String name;
|
||||
private String originName;
|
||||
private Long fileLength;
|
||||
private String referURL;
|
||||
private String attachmentURL;
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package app.module.core.usecase.article.getArticles.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.repository.ArticleRepo;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import app.module.core.usecase.article.getArticles.adapters.persistence.model.GetArticlesDto;
|
||||
import app.module.core.usecase.article.getArticles.ports.GetArticlesPortOut;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticleFiles;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticles;
|
||||
import app.module.core.usecase.article.getArticles.ports.application.domain.GetArticlesCmd;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetArticlesDao implements GetArticlesPortOut {
|
||||
|
||||
private final GetArticlesMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Page<GetArticles> operate(Pageable pageable, GetArticlesCmd command) {
|
||||
// 게시물 목록 얻기
|
||||
List<GetArticlesDto> contents =
|
||||
ListUtils.emptyIfNull(mapper.getArticles(pageable, command));
|
||||
|
||||
// 대표 이미지 목록 얻기
|
||||
List<GetArticleFiles> uploadFiles =
|
||||
contents.isEmpty()
|
||||
? Collections.emptyList()
|
||||
: ListUtils.emptyIfNull(
|
||||
mapper.getUploadFiles(
|
||||
contents.stream().map(GetArticlesDto::getId)
|
||||
.collect(Collectors.toList()),
|
||||
FileUploadType.PUBLIC));
|
||||
|
||||
return new PageImpl<>(
|
||||
contents.stream()
|
||||
.map(
|
||||
article ->
|
||||
new GetArticles(
|
||||
article.getId(),
|
||||
article.getUpdatedBy(),
|
||||
article.getUpdatedAt(),
|
||||
article.getTitle(),
|
||||
article.getContent(),
|
||||
article.getVisible(),
|
||||
article.getStartDate(),
|
||||
article.getEndDate(),
|
||||
article.getOrderNo(),
|
||||
uploadFiles.stream()
|
||||
.filter(file -> file.getArticleId().equals(article.getId()))
|
||||
.findFirst()
|
||||
.orElse(null)))
|
||||
.collect(Collectors.toList()),
|
||||
pageable,
|
||||
contents.isEmpty() ? 0 : contents.get(0).getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<GetArticles> operateList(GetArticlesCmd 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;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user