[삭제] 미사용 파일 삭제 - Article, Email

This commit is contained in:
김현주
2025-07-11 10:21:45 +09:00
parent 45250c126a
commit f1d6ec02e8
202 changed files with 1 additions and 7982 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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"));
}
}
}
}

View File

@@ -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());
}
}

View File

@@ -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";
}
}

View File

@@ -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 {
}

View File

@@ -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}";
}
}

View File

@@ -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 {
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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();
}
}
}
}

View File

@@ -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;
}

View File

@@ -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";
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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"));
}
}
}
}

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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";
}
}

View File

@@ -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";
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>