[삭제] 미사용 파일 삭제 - 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,35 +0,0 @@
package app.module.front.usecase.article.comment.createArticleComment.adapter.web;
import app.module.core.usecase.article.comment.createArticleComment.ports.CreateArticleCommentPortIn;
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 app.module.front.usecase.article.comment.createArticleComment.adapter.web.model.CreateArticleCommentReqVO;
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 CreateArticleCommentController {
private final CreateArticleCommentPortIn createArticleCommentPortIn;
@PostMapping(path = "/api/front/board/articles/comment/create")
ResponseEntity<?> operate(@Valid CreateArticleCommentReqVO reqVO, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
CreateArticleComment comment =
createArticleCommentPortIn.operate(
new CreateArticleCommentCmd(reqVO.getArticleId(), reqVO.getCommentContent()))
.orElseThrow();
return ResponseEntity.status(HttpStatus.OK).body(comment);
}
}

View File

@@ -1,23 +0,0 @@
package app.module.front.usecase.article.comment.createArticleComment.adapter.web.model;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.text.StringEscapeUtils;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class CreateArticleCommentReqVO {
private Long articleId;
@NotBlank(message = "{valid.article.comment.required}")
private String commentContent;
public String getCommentContent() {
return StringEscapeUtils.escapeHtml4(commentContent);
}
}

View File

@@ -1,34 +0,0 @@
package app.module.front.usecase.article.comment.getArticleComments.adapter.web;
import app.module.core.usecase.article.comment.getArticleComments.ports.GetArticleCommentsPortIn;
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 app.module.front.usecase.article.comment.getArticleComments.adapter.web.model.GetArticleCommentsReqVO;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
class GetArticleCommentsController {
private final GetArticleCommentsPortIn getArticleCommentsPortIn;
@GetMapping(path = "/api/front/board/articles/comments")
ResponseEntity<?> operate(
@PageableDefault(sort = "id", direction = Sort.Direction.DESC, page = 0, size = 10) Pageable pageable,
GetArticleCommentsReqVO reqVO) {
Page<GetArticleComments> comments =
getArticleCommentsPortIn.operate(pageable,
new GetArticleCommentsCmd(reqVO.getArticleId()));
return ResponseEntity.status(HttpStatus.OK).body(comments);
}
}

View File

@@ -1,15 +0,0 @@
package app.module.front.usecase.article.comment.getArticleComments.adapter.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetArticleCommentsReqVO {
private Long articleId;
}

View File

@@ -1,31 +0,0 @@
package app.module.front.usecase.article.comment.removeArticleComment.adapter.web;
import app.module.core.usecase.article.comment.removeArticleComment.ports.RemoveArticleCommentPortIn;
import app.module.core.usecase.article.comment.removeArticleComment.ports.application.domain.RemoveArticleCommentCmd;
import app.module.front.usecase.article.comment.removeArticleComment.adapter.web.model.RemoveArticleCommentReqVO;
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 RemoveArticleCommentController {
private final RemoveArticleCommentPortIn removeArticleCommentPortIn;
@DeleteMapping(path = "/api/front/board/articles/comment/remove")
ResponseEntity<?> operate(@Valid RemoveArticleCommentReqVO reqVO, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
removeArticleCommentPortIn.operate(new RemoveArticleCommentCmd(reqVO.getRemoveId()));
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
}
}

View File

@@ -1,15 +0,0 @@
package app.module.front.usecase.article.comment.removeArticleComment.adapter.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class RemoveArticleCommentReqVO {
private Long removeId;
}

View File

@@ -1,38 +0,0 @@
package app.module.front.usecase.article.comment.updateArticleComment.adapter.web;
import app.module.core.usecase.article.comment.updateArticleComment.ports.UpdateArticleCommentPortIn;
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 app.module.front.usecase.article.comment.updateArticleComment.adapter.web.model.UpdateArticleCommentReqVO;
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 UpdateArticleCommentController {
private final UpdateArticleCommentPortIn updateArticleCommentPortIn;
@PutMapping(path = "/api/front/board/articles/comment/update")
ResponseEntity<?> operate(@Valid UpdateArticleCommentReqVO reqVO, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
UpdateArticleComment comment =
updateArticleCommentPortIn.operate(
new UpdateArticleCommentCmd(
reqVO.getCommentId(),
reqVO.getCommentContent(),
reqVO.getArticleId()))
.orElseThrow();
return ResponseEntity.status(HttpStatus.OK).body(comment);
}
}

View File

@@ -1,24 +0,0 @@
package app.module.front.usecase.article.comment.updateArticleComment.adapter.web.model;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.text.StringEscapeUtils;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class UpdateArticleCommentReqVO {
private Long commentId;
@NotBlank(message = "{valid.article.comment.required}")
private String commentContent;
private Long articleId;
public String getCommentContent() {
return StringEscapeUtils.escapeHtml4(commentContent);
}
}

View File

@@ -1,46 +0,0 @@
package app.module.front.usecase.article.createArticle.adapters.web;
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 app.module.front.usecase.article.createArticle.adapters.web.model.CreateArticleReqVO;
import app.module.front.usecase.article.createArticle.adapters.web.validator.CreateArticleValidator;
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/front/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.front.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.front.usecase.article.createArticle.adapters.web.validator;
import app.module.core.config.application.util.MessageUtil;
import app.module.front.usecase.article.createArticle.adapters.web.model.CreateArticleReqVO;
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,21 +0,0 @@
package app.module.front.usecase.article.createArticleUI;
import app.module.front.usecase.article.createArticleUI.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.front.usecase.article.createArticleUI.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.front.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/front/board/articles/{id}")
ResponseEntity<?> operate(@PathVariable Long id) {
return ResponseEntity.status(HttpStatus.OK)
.body(getArticlePortIn.operate(new GetArticleCmd(id)).orElseThrow());
}
}

View File

@@ -1,37 +0,0 @@
package app.module.front.usecase.article.getArticleUI.adapters.web;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.usecase.article.getArticle.ports.GetArticlePortIn;
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.front.usecase.article.getArticleUI.adapters.web.model.GetArticleUIReqVO;
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 GetArticleUIController {
private final GetArticlePortIn getArticlePortIn;
@GetMapping(path = "/board/articles/{id}")
String operate(
Model model,
@PathVariable @ModelAttribute("id") Long id,
@ModelAttribute("reqVO") GetArticleUIReqVO reqVO) {
GetArticle getArticle =
getArticlePortIn.operate(new GetArticleCmd(id)).orElseThrow();
// 로그인 사용자와 게시물 작성자가 동일한지 체크
model.addAttribute("isAuthor",
getArticle.getCreatedBy().equals(CommonUtil.getLoginUsername()));
model.addAttribute("article", getArticle);
return "board/articles/{id}";
}
}

View File

@@ -1,14 +0,0 @@
package app.module.front.usecase.article.getArticleUI.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetArticleUIReqVO {
}

View File

@@ -1,32 +0,0 @@
package app.module.front.usecase.article.getArticles.adapters.web;
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.front.usecase.article.getArticles.adapters.web.model.GetArticlesReqVO;
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.front.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,26 +0,0 @@
package app.module.front.usecase.article.getArticlesUI;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.usecase.article.getArticlesUI.model.GetArticlesUIReqVO;
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(
Model model,
@ModelAttribute("reqVO") GetArticlesUIReqVO reqVO) {
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
return "board/articles";
}
}

View File

@@ -1,36 +0,0 @@
package app.module.front.usecase.article.getArticlesUI.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.front.usecase.article.removeArticles.adapters.web;
import app.module.core.usecase.article.removeArticles.ports.RemoveArticlesPortIn;
import app.module.core.usecase.article.removeArticles.ports.application.domain.RemoveArticlesCmd;
import app.module.front.usecase.article.removeArticles.adapters.web.model.RemoveArticlesReqVO;
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/front/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.front.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,46 +0,0 @@
package app.module.front.usecase.article.updateArticle.adapters.web;
import app.module.core.usecase.article.updateArticle.ports.UpdateArticlePortIn;
import app.module.core.usecase.article.updateArticle.ports.application.domain.UpdateArticleCmd;
import app.module.front.usecase.article.updateArticle.adapters.web.model.UpdateArticleReqVO;
import app.module.front.usecase.article.updateArticle.adapters.web.validator.UpdateArticleValidator;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@Slf4j
class UpdateArticleController {
private final UpdateArticlePortIn updateArticlePortIn;
private final UpdateArticleValidator updateArticleValidator;
@PutMapping(path = "/api/front/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,49 +0,0 @@
package app.module.front.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.Setter;
import org.apache.commons.text.StringEscapeUtils;
@Getter
@Setter
@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.front.usecase.article.updateArticle.adapters.web.validator;
import app.module.core.config.application.util.MessageUtil;
import app.module.front.usecase.article.updateArticle.adapters.web.model.UpdateArticleReqVO;
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

@@ -1,32 +0,0 @@
package app.module.front.usecase.article.updateArticleUI.adapters.web;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.usecase.article.getArticle.ports.GetArticlePortIn;
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
import app.module.front.usecase.article.updateArticleUI.adapters.web.model.UpdateArticleUIReqVO;
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 UpdateArticleUIController {
private final GetArticlePortIn getArticlePortIn;
@GetMapping(path = "/board/articles/update/{id}")
String operate(
Model model,
@PathVariable @ModelAttribute("id") Long id,
@ModelAttribute("reqVO") UpdateArticleUIReqVO reqVO) {
getArticlePortIn.operate(new GetArticleCmd(id))
.filter(article -> article.getCreatedBy().equals(CommonUtil.getLoginUsername()))
.orElseThrow(() -> new RuntimeException("수정 권한이 없는 사용자입니다."));
return "board/articles/update/{id}";
}
}

View File

@@ -1,14 +0,0 @@
package app.module.front.usecase.article.updateArticleUI.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class UpdateArticleUIReqVO {
}

View File

@@ -1,57 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.adapters.persistence;
import app.module.front.usecase.info.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
import app.module.front.usecase.info.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
import app.module.front.usecase.info.notice.createNotice.ports.CreateNoticePortOut;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNotice;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNoticeCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import java.util.stream.Collectors;
@Repository
@RequiredArgsConstructor
class CreateNoticeDao implements CreateNoticePortOut {
private final CreateNoticeMapper mapper;
@Override
@Transactional
public Optional<CreateNotice> operate(CreateNoticeCmd command) {
CreateNoticeDto dto =
new CreateNoticeDto(
null,
command.getTitle(),
command.getContent(),
command.getVisible(),
command.getStartDate(),
command.getEndDate(),
command.getFileMappingId(),
command.getCreatedAt(),
command.getCreatedBy(),
command.getUpdatedAt(),
command.getUpdatedBy());
mapper.createNotice(dto);
if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) {
mapper.createNoticeHasUploadFile(new CreateNoticeHasUploadFilesParam(
dto.getId(),
dto.getFileMappingId().stream()
.map(Long::parseLong)
.collect(Collectors.toList()),
dto.getCreatedAt(),
dto.getCreatedBy(),
dto.getUpdatedAt(),
dto.getUpdatedBy()
));
}
return Optional.of(new CreateNotice(dto.getId()));
}
}

View File

@@ -1,11 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.adapters.persistence;
import app.module.front.usecase.info.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
import app.module.front.usecase.info.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CreateNoticeMapper {
void createNotice(CreateNoticeDto dto);
void createNoticeHasUploadFile(CreateNoticeHasUploadFilesParam param);
}

View File

@@ -1,27 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CreateNoticeDto {
private Long id;
private String title;
private String content;
private Boolean visible;
private LocalDateTime startDate;
private LocalDateTime endDate;
private List<String> fileMappingId;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -1,22 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CreateNoticeHasUploadFilesParam {
private Long id;
private List<Long> fileMappingIds;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -1,11 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.ports;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNotice;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNoticeCmd;
import java.util.Optional;
public interface CreateNoticePortIn {
Optional<CreateNotice> operate(CreateNoticeCmd command);
}

View File

@@ -1,11 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.ports;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNotice;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNoticeCmd;
import java.util.Optional;
public interface CreateNoticePortOut {
Optional<CreateNotice> operate(CreateNoticeCmd command);
}

View File

@@ -1,24 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.ports.application;
import app.module.core.config.application.annotation.CreateCommand;
import app.module.front.usecase.info.notice.createNotice.ports.CreateNoticePortIn;
import app.module.front.usecase.info.notice.createNotice.ports.CreateNoticePortOut;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNotice;
import app.module.front.usecase.info.notice.createNotice.ports.application.domain.CreateNoticeCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
@RequiredArgsConstructor
class CreateNoticeService implements CreateNoticePortIn {
private final CreateNoticePortOut portOut;
@Override
@CreateCommand
public Optional<CreateNotice> operate(CreateNoticeCmd command) {
return portOut.operate(command);
}
}

View File

@@ -1,14 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class CreateNotice {
private Long id;
}

View File

@@ -1,23 +0,0 @@
package app.module.front.usecase.info.notice.createNotice.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class CreateNoticeCmd extends AuditCommand {
private String title;
private String content;
private Boolean visible;
private LocalDateTime startDate;
private LocalDateTime endDate;
private List<String> fileMappingId;
}

View File

@@ -1,28 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.adapters.persistence;
import app.module.core.config.application.util.CommonUtil;
import app.module.front.usecase.info.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
import app.module.front.usecase.info.notice.removeNotices.ports.RemoveNoticesPortOut;
import app.module.front.usecase.info.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
@Repository
@RequiredArgsConstructor
class RemoveNoticesDao implements RemoveNoticesPortOut {
private final RemoveNoticesMapper mapper;
@Override
public void operate(RemoveNoticesCmd command) {
String loginUser = CommonUtil.getLoginUsername();;
LocalDateTime now = LocalDateTime.now();
mapper.deleteNoticeHasFiles(
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));
mapper.deleteNotices(
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));
}
}

View File

@@ -1,10 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.adapters.persistence;
import app.module.front.usecase.info.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RemoveNoticesMapper {
void deleteNotices(RemoveNoticesParam param);
void deleteNoticeHasFiles(RemoveNoticesParam param);
}

View File

@@ -1,19 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Set;
@Getter
@Setter
@AllArgsConstructor
public class RemoveNoticesParam {
private Set<Long> removeIds;
private LocalDateTime updatedAt;
private String updatedBy;
private LocalDateTime deletedAt;
private String deletedBy;
}

View File

@@ -1,7 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.ports;
import app.module.front.usecase.info.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
public interface RemoveNoticesPortIn {
void operate(RemoveNoticesCmd command);
}

View File

@@ -1,7 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.ports;
import app.module.front.usecase.info.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
public interface RemoveNoticesPortOut {
void operate(RemoveNoticesCmd command);
}

View File

@@ -1,19 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.ports.application;
import app.module.front.usecase.info.notice.removeNotices.ports.RemoveNoticesPortIn;
import app.module.front.usecase.info.notice.removeNotices.ports.RemoveNoticesPortOut;
import app.module.front.usecase.info.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class RemoveNoticesService implements RemoveNoticesPortIn {
private final RemoveNoticesPortOut portOut;
@Override
public void operate(RemoveNoticesCmd command) {
portOut.operate(command);
}
}

View File

@@ -1,16 +0,0 @@
package app.module.front.usecase.info.notice.removeNotices.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.Set;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class RemoveNoticesCmd {
private Set<Long> removeIds;
}

View File

@@ -1,52 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.adapters.persistence;
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
import app.module.core.config.application.util.CommonUtil;
import app.module.front.usecase.info.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
import app.module.front.usecase.info.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
import app.module.front.usecase.info.notice.updateNotice.ports.UpdateNoticePortOut;
import app.module.front.usecase.info.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
@Repository
@RequiredArgsConstructor
class UpdateNoticeDao implements UpdateNoticePortOut {
private final UpdateNoticeMapper mapper;
@Override
public void operate(UpdateNoticeCmd command) {
mapper.updateNotice(
new UpdateNoticeDto(
command.getId(),
command.getTitle(),
command.getContent(),
command.getVisible(),
command.getStartDate(),
command.getEndDate(),
command.getFileMappingId(),
LocalDateTime.now(),
CommonUtil.getLoginUsername()
));
// 첨부파일 초기화
mapper.deleteFileUploads(new ArticleHasUploadFile(command.getId()));
// 첨부파일 있을 시, 등록
if (command.getFileMappingId() != null && !command.getFileMappingId().isEmpty()) {
mapper.createFileUploads(new CreateUploadFileParam(
command.getId(),
command.getFileMappingId().stream()
.map(Long::parseLong)
.toList(),
LocalDateTime.now(),
CommonUtil.getLoginUsername(),
LocalDateTime.now(),
CommonUtil.getLoginUsername()
));
}
}
}

View File

@@ -1,13 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.adapters.persistence;
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
import app.module.front.usecase.info.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
import app.module.front.usecase.info.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UpdateNoticeMapper {
void updateNotice(UpdateNoticeDto dto);
void deleteFileUploads(ArticleHasUploadFile articleHasUploadFile);
void createFileUploads(CreateUploadFileParam param);
}

View File

@@ -1,18 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@AllArgsConstructor
public class CreateUploadFileParam {
private Long id;
private List<Long> fileMappingId;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -1,25 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class UpdateNoticeDto {
private Long id;
private String title;
private String content;
private Boolean visible;
private LocalDateTime startDate;
private LocalDateTime endDate;
private List<String> fileMappingId;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -1,8 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.ports;
import app.module.front.usecase.info.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
public interface UpdateNoticePortIn {
void operate(UpdateNoticeCmd command);
}

View File

@@ -1,8 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.ports;
import app.module.front.usecase.info.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
public interface UpdateNoticePortOut {
void operate(UpdateNoticeCmd command);
}

View File

@@ -1,19 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.ports.application;
import app.module.front.usecase.info.notice.updateNotice.ports.UpdateNoticePortIn;
import app.module.front.usecase.info.notice.updateNotice.ports.UpdateNoticePortOut;
import app.module.front.usecase.info.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class UpdateNoticeService implements UpdateNoticePortIn {
private final UpdateNoticePortOut portOut;
@Override
public void operate(UpdateNoticeCmd command) {
portOut.operate(command);
}
}

View File

@@ -1,23 +0,0 @@
package app.module.front.usecase.info.notice.updateNotice.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class UpdateNoticeCmd {
private Long id;
private String title;
private String content;
private Boolean visible;
private LocalDateTime startDate;
private LocalDateTime endDate;
private List<String> fileMappingId;
}

View File

@@ -1,59 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace="app.module.front.usecase.info.notice.createNotice.adapters.persistence.CreateNoticeMapper">
<insert id="createNotice" keyProperty="id">
<!-- createNotice 게시글 등록 -->
<selectKey keyProperty="id" order="BEFORE" resultType="long">
SELECT nextval('notice_seq')
</selectKey>
INSERT INTO notice (
id,
content,
end_date,
start_date,
title,
visible,
created_at,
created_by,
updated_at,
updated_by,
is_deleted
) VALUES (
#{id},
#{content},
#{endDate},
#{startDate},
#{title},
#{visible},
#{createdAt},
#{createdBy},
#{updatedAt},
#{updatedBy},
false
)
</insert>
<insert id="createNoticeHasUploadFile">
<!-- createNoticeHasUploadFile 게시글 등록 시, 첨부파일 join 데이터 등록 -->
INSERT INTO notice_has_upload_file
(
notice_id,
upload_files_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
<foreach collection="fileMappingId" item="fileId" separator=",">
(
#{id},
#{fileId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</foreach>
</insert>
</mapper>

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace="app.module.front.usecase.info.notice.removeNotices.adapters.persistence.RemoveNoticesMapper">
<update id="deleteNotices">
/* deleteNotices : 게시물 삭제 */
UPDATE notice
SET <include refid="common.fields.DeleteBaseSet" />
WHERE id IN
<foreach collection="removeIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<update id="deleteNoticeHasFiles">
/* deleteNoticeHasFiles : 게시물-파일 매핑 논리 삭제 */
UPDATE notice_has_upload_file
SET <include refid="common.fields.DeleteBaseSet" />
WHERE notice_id IN
<foreach collection="removeIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

View File

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace="app.module.front.usecase.info.notice.updateNotice.adapters.persistence.UpdateNoticeMapper">
<update id="deleteFileUploads">
/* deleteFileUploads 게시글 수정 시, 첨부파일 join 데이터 삭제 */
UPDATE notice_has_upload_file
SET <include refid="common.fields.UpdateBaseSet"/>
WHERE notice_id = #{noticeId}
</update>
<insert id="createFileUploads">
/* createFileUploads 게시글 수정 시, 첨부파일 join 데이터 등록 */
INSERT INTO notice_has_upload_file
(
notice_id,
upload_files_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
<foreach collection="fileMappingId" item="fileId" separator=",">
(
#{id},
#{fileId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</foreach>
</insert>
<update id="updateNotice">
/* updateNotice 게시글 수정 */
UPDATE notice
SET
content = #{content},
end_date = #{endDate},
start_date = #{startDate},
title = #{title},
visible = #{visible},
<include refid="common.fields.UpdateBaseSet"/>
WHERE id = #{id}
</update>
</mapper>

View File

@@ -1,266 +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">
<style type="text/css">
table, td {
border: 1px solid
}
table {
width: 60%;
height: 100px;
text-align: center;
}
</style>
<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 type="button" class="btn btn-outline-secondary" onclick="goExcel();">
<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>
</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 ? ct.uploadFile.referURL
: '/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();
});
}
})
}
// 최초 리스트 로드
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);
}
</script>
</section>
</html>

View File

@@ -1,202 +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">
<style>
.content {
margin-bottom: 20px;
}
.content label {
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.content div {
padding: 8px 0;
}
.tox-tinymce {
border: none;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
textarea.is-invalid ~ .invalid-feedback {
display: block;
}
</style>
<form
class="fw-bold"
method="post" name="reqForm" th:action="@{/board/articles/create}">
<div class="content">
<label>제목 *</label>
<div>
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-row">
<div class="input-group">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
<div class="input-group">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
</div>
<div class="content">
<label>공개여부</label>
<div>
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="content" style="max-width: 60rem;">
<label for="content">내용 *</label>
<div>
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label for="representImgFile">대표 이미지</label>
<div class="input-group">
<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>
<div class="content 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>
</form>
<button onclick="gotoList();">목록</button>
<button onclick="goSave();">저장</button>
</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();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
traditional: true,
method: 'POST',
url: '/api/front/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 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>
// 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 th:inline="javascript">
// init tinymce editor
initEditor('#content');
</script>
</section>
</html>

View File

@@ -1,251 +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">
<style>
.content {
margin-bottom: 20px;
}
.content label {
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.content div {
padding: 8px 0;
}
.tox-tinymce {
border: none;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
textarea.is-invalid ~ .invalid-feedback {
display: block;
}
</style>
<form method="post" name="reqForm">
<input name="id" th:value="${id}" type="hidden">
<input name="orderNo" type="hidden">
<div class="content">
<label>제목 *</label>
<div>
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-row">
<div class="input-group">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
<div class="input-group">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
</div>
<div class="content">
<label>공개여부</label>
<div>
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="content" style="max-width: 60rem;">
<label for="content">내용 *</label>
<div>
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label for="representImgFile">대표 이미지</label>
<div class="input-group">
<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>
<div class="content 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>
</form>
<button onclick="gotoList();">목록</button>
<button onclick="goSave();">저장</button>
</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>
function 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/front/board/articles/' + f.id.value,
success(res) {
console.log(res);
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({
traditional: true,
method: 'PUT',
url: '/api/front/board/articles/update',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.`)) {
location.href = '/board/articles/' + res.id;
}
},
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,427 +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">
<style>
.content {
margin-bottom: 20px;
}
.content label {
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.content div {
padding: 8px 0;
}
.comment-info {
display: flex;
align-items: center;
gap: 10px;
}
.comment-actions {
display: flex;
gap: 5px;
}
</style>
<form class="fw-bold" name="reqForm">
<input name="articleId" th:value="${id}" type="hidden">
<!-- pageable parameters -->
<input name="page" type="hidden"/>
<div class="content">
<label>제목</label>
<div id="title" name="title"></div>
</div>
<div class="content">
<label>게시일</label>
<div id="postDate" name="postDate"></div>
</div>
<div class="content">
<label>공개여부</label>
<div id="visible" name="visible"></div>
</div>
<div class="content">
<label>내용</label>
<div id="content" name="content"></div>
</div>
<div class="content uploadFile representImgFile">
<label for="representImgFile">대표 이미지</label>
<div class="input-group">
<div id="representImgFile" name="representImgFile"></div>
</div>
</div>
<div class="content uploadFile publicFileInputs">
<label>다건 파일</label>
</div>
<div class="button-group" style="margin-bottom: 50px;">
<button onclick="gotoList();" type="button">목록</button>
<button onclick="goUpdate();" th:if="${isAuthor}" type="button">수정</button>
<button onclick="goRemove();" th:if="${isAuthor}" type="button">삭제</button>
</div>
<!-- 댓글 -->
<div class="comment-section" style="margin-bottom: 50px;">
<div class="comment-form">
<label>댓글</label>
<div class="input-group">
<input id="newCommentInput" name="commentContent" placeholder="댓글을 입력하세요" type="text">
<button onclick="saveComment()" type="button">등록</button>
</div>
</div>
<!-- 댓글 리스트 -->
<div id="commentList"></div>
<button id="moreBtn" onclick="moreCommentBtn();" style="display: none;" type="button">
더보기
</button>
</div>
</form>
</section>
<section layout:fragment="script">
<script>
function gotoList() {
location.href = '/board/articles';
}
function goUpdate() {
const f = document.reqForm;
location.href = '/board/articles/update/' + f.articleId.value;
}
function addFileInput() {
const inputGroup = $(`
<div class="input-group">
<div class="multiFile"></div>
</div>
`);
$('.publicFileInputs').append(inputGroup);
return inputGroup;
}
</script>
<script>
// 게시물 데이터 조회
const getArticle = () => {
const f = document.reqForm;
$.ajax({
method: 'GET',
url: '/api/front/board/articles/' + f.articleId.value,
success(res) {
console.log("data : ", res);
$('#title').text(uiUtil.unescapeHtml(res.title));
$('#postDate').text(
res.startDate.substring(0, 10) + ' - ' + res.endDate.substring(0, 10));
$('#visible').text(res.visible ? 'Y' : 'N');
$('#content').html(uiUtil.unescapeHtml(res.content));
$('#orderNo').val(res.orderNo);
$('.uploadFile').hide();
res.uploadFiles.forEach((uploadFile) => {
switch (uploadFile.type.name) {
// 대표 이미지
case 'EXAMPLE_REP':
const input = $("#representImgFile");
input.parent().append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFrontFileInfo(input, uploadFile, true);
$('.representImgFile').show();
break;
// 다건 첨부 파일
case 'EXAMPLE_PUBLIC':
let inputGroup = addFileInput();
inputGroup.append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFrontFileInfo(inputGroup.find('.multiFile'), uploadFile, false);
$('.publicFileInputs').show();
break;
}
});
}
});
}
getArticle();
</script>
<script th:inline="javascript">
const goRemove = () => {
if (confirm(/*[[#{operation.board.article.remove.ask}]]*/)) {
const f = document.reqForm;
const obj = $(f).serializeObject();
$.ajax({
'method': 'DELETE',
'url': '/api/front/board/articles/remove',
'data': {
'selectIds': obj.articleId
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
alert('게시물이 삭제되었습니다.');
gotoList();
},
statusCode: {
// error
400: function (response) {
const resJson = response.responseJSON;
alert(resJson.message);
}
}
});
}
}
</script>
<script>
// 댓글 데이터 조회
const getArticleComments = () => {
const f = document.reqForm;
const obj = $(f).serializeObject();
$.ajax({
method: 'GET',
url: '/api/front/board/articles/comments',
data: obj,
success(res) {
// 댓글 렌더링
res.content.forEach((comment) => {
const commentElement = createCommentElement(comment);
$('#commentList').append(commentElement);
});
// 더보기 버튼 표시/숨김 처리
f.page.value = res.number;
const currentPage = parseInt(f.page.value);
const pageSize = parseInt(res.size);
const totalPages = Math.ceil(res.totalElements / pageSize);
if (currentPage >= totalPages - 1) {
$('#moreBtn').hide();
} else {
$('#moreBtn').show();
}
}
});
};
// 초기 로드 호출
getArticleComments();
</script>
<script>
// 댓글 더보기 버튼
function moreCommentBtn() {
const f = document.reqForm;
const pageInput = $(f).find('input[name="page"]');
// 현재 페이지 증가
pageInput.val(parseInt(pageInput.val()) + 1);
getArticleComments();
}
</script>
<script th:inline="javascript">
// 댓글 추가 html
function createCommentElement(data) {
return $(`
<div class="comment" data-comment-id="${data.id}">
<div class="comment-header">
<div class="comment-info">
<label class="author">${data.createdBy}</label>
<span class="date">${formatDate(data.updatedAt)}</span>
<div class="comment-actions">
${data.isAuthor == null || data.isAuthor ? `
<button type="button" onclick="editComment(this)">수정</button>
<button type="button" onclick="removeComment(this)">삭제</button>
` : ''}
</div>
</div>
</div>
<div class="comment-body">
<div class="content">${data.content}</div>
<div class="edit-form" style="display: none;">
<input type="text" class="edit-input" value="${data.content}">
<button type="button" onclick="saveEdit(this)">저장</button>
<button type="button" onclick="cancelEdit(this)">취소</button>
</div>
</div>
</div>
`);
}
// 댓글 저장
function saveComment() {
const f = document.reqForm;
const obj = $(f).serializeObject();
$.ajax({
method: 'POST',
url: '/api/front/board/articles/comment/create',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
const commentElement = createCommentElement(res);
$('#commentList').prepend(commentElement);
$('#newCommentInput').val('');
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
alert(oj.defaultMessage);
});
}
}
});
}
// 댓글 수정 모드로 전환
function editComment(button) {
const comment = $(button).closest('.comment');
const content = comment.find('.content');
const editForm = comment.find('.edit-form');
const editInput = comment.find('.edit-input');
const commentActions = comment.find('.comment-actions');
commentActions.hide();
content.hide();
editForm.show();
editInput.val(content.text()).focus();
}
// 댓글 수정 저장
function saveEdit(button) {
const f = document.reqForm;
const comment = $(button).closest('.comment');
const commentId = comment.data('comment-id');
const editInput = comment.find('.edit-input');
const commentContent = editInput.val();
$.ajax({
method: 'PUT',
url: '/api/front/board/articles/comment/update',
data: {
commentId: commentId,
commentContent: commentContent,
articleId: f.articleId.value
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
const content = comment.find('.content');
const editForm = comment.find('.edit-form');
const commentActions = comment.find('.comment-actions');
content.text(res.content).show();
editForm.hide();
commentActions.show();
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
alert(oj.defaultMessage);
});
}
}
});
}
// 댓글 수정 취소
function cancelEdit(button) {
const comment = $(button).closest('.comment');
const content = comment.find('.content');
const editForm = comment.find('.edit-form');
const commentActions = comment.find('.comment-actions');
content.show();
editForm.hide();
commentActions.show();
}
// 댓글 삭제
function removeComment(button) {
const comment = $(button).closest('.comment');
const commentId = comment.data('comment-id');
if (confirm(/*[[#{operation.board.article.comment.remove.ask}]]*/)) {
$.ajax({
'method': 'DELETE',
'url': '/api/front/board/articles/comment/remove',
'data': {
'removeId': commentId
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
$(button).closest('.comment').remove();
},
statusCode: {
// error
400: function (response) {
const resJson = response.responseJSON;
alert(resJson.message);
}
}
});
}
}
</script>
<script>
function formatDate(isoString) {
const date = new Date(isoString);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
</script>
</section>
</html>

View File

@@ -1,138 +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 enctype="multipart/form-data"
method="post"
name="updateForm" th:action="@{/board/exampleBoard/} + ${formDto.editMode ? 'update' : 'create'}"
th:object="${formDto}">
<input name="editMode" th:value="${formDto.editMode}" type="hidden"/>
<input name="id" th:if="${formDto.editMode}" th:value="${formDto.id}" type="hidden"/>
<div>
<h1 th:text="${formDto.title}">
</h1>
<div>
<label>게시일 *</label>
<div>
<span th:text="${formDto.boardStartDate}"></span> ~ <span
th:text="${formDto.boardEndDate}"></span>
</div>
</div>
<div>
<label>공개여부</label>
<div th:text="${formDto.visible}">
</div>
<div th:utext="${formDto.content}">
</div>
<div th:if="${formDto.editMode}">
<label for="content" style="padding-top: 0;">public 파일</label>
<div>
<div th:each="item, status : ${formDto.uploadedFiles}">
<a th:attr="data-file-seq=${item.seq}" th:href="${@commonUtil.getPublicIOPath(item)}"
th:text="${item.originalFilename}"
></a>
<a href="javascript:void(0);" onclick="removeFile(this);"
th:attr="data-del-file-seq=${item.seq}"><i
></i></a>
<a href="javascript:void(0);" onclick="cancelRemove(this);" style="display: none;"
th:attr="data-cancel-file-seq=${item.seq}"
> (취소)</a>
</div>
</div>
</div>
<div th:if="${formDto.editMode}">
<label for="content" style="padding-top: 0;">private 파일</label>
<div>
<div th:each="item, status : ${formDto.uploadedPrivates}">
<a th:attr="data-file-seq=${item.seq}" th:href="${@commonUtil.getPrivateIOPath(item)}"
th:text="${item.originalFilename}"
></a>
<a href="javascript:void(0);" onclick="removeFile(this);"
th:attr="data-del-file-seq=${item.seq}"><i
></i></a>
<a href="javascript:void(0);" onclick="cancelRemove(this);" style="display: none;"
th:attr="data-cancel-file-seq=${item.seq}"
> (취소)</a>
</div>
</div>
</div>
</div>
<button onclick="gotoList();return false;" type="button">목록으로 이동</button>
</form>
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
<form method="get" name="prevParamForm" th:action="@{/board/exampleBoard}"
th:if="${formDto.editMode}"
th:object="${paramDto}">
<input th:field="*{searchField}" type="hidden">
<input th:field="*{searchValue}" type="hidden">
<input th:field="*{searchOpen}" type="hidden">
<input th:field="*{page}" type="hidden">
<input th:field="*{size}" type="hidden">
<input th:field="*{sort}" type="hidden">
</form>
<script>
function gotoList() {
document.prevParamForm ? document.prevParamForm.submit()
: location.href = '/board/exampleBoard';
}
function removeFile(oj) {
const fileSeq = $(oj).data('del-file-seq');
const el = $('a[data-file-seq=' + fileSeq + ']');
el.addClass('text-decoration-line-through');
$(oj).hide();
const cancelEl = $('a[data-cancel-file-seq=' + fileSeq + ']');
cancelEl.show();
const f = document.updateForm;
let input = $('<input type="hidden" name="delFileSeq">');
input.val(fileSeq);
input.attr('id', 'del_' + fileSeq);
$(f).append(input);
}
function cancelRemove(oj) {
const fileSeq = $(oj).data('cancel-file-seq');
const el = $('a[data-file-seq=' + fileSeq + ']');
el.removeClass('text-decoration-line-through');
$('#del_' + fileSeq).remove();
$('a[data-del-file-seq=' + fileSeq + ']').show();
$(oj).hide();
}
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 type="file" name="{{:name}}"/>
</script>
</section>
</html>

View File

@@ -1,174 +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 method="post" name="paramForm" onsubmit="goSearch();"
th:action="@{/board/exampleBoard}" th:object="${paramDto}">
<!-- hidden parameters -->
<input name="page" th:value="${listOutput.pageable.pageNumber}" type="hidden"/>
<input name="sort" th:value="${listOutput.pageable.sort}" type="hidden"/>
<div style="--bs-bg-opacity: .2;">
<div>
<label for="searchField">검색필드</label>
<select id="searchField"
th:field="*{searchField}">
<option selected value="">선택</option>
<option value="title">제목</option>
<option value="createdBy">작성자</option>
</select> <label>
<input placeholder="검색어를 입력하세요."
style="width: 250px;" th:field="*{searchValue}"
type="text">
</label>
</div>
<div>
<label for="searchOpen">공개여부</label>
<select id="searchOpen"
th:field="*{searchOpen}">
<option selected value="">전체</option>
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
<div>
<button onclick="goSearch();"
type="button">검색
</button>
<button onclick="goInit();" type="button">초기화
</button>
</div>
</div>
<div>
<div>
<div>
Total: <span th:text="${listOutput.totalElements}"></span>
</div>
</div>
<div>
<i></i> <label> <select
onchange="goSearch()"
th:field="*{size}">
<option
th:each="item : ${pageRows}"
th:selected="${#strings.toString(listOutput.pageable.pageSize) eq item.codeValue}" th:text="${item.codeText}"
th:value="${item.codeValue}"></option>
</select>
</label>
</div>
</div>
<table>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"><label>
<input
onchange="toggleCheckbox(this);" type="checkbox"/></label>
</th>
<th scope="col"><a data-sort-field="title"
href="#">제목</a></th>
<th scope="col"><a data-sort-field="open"
href="#">공개여부</a></th>
<th scope="col"><a data-sort-field="boardStartDate"
href="#">게시일</a></th>
<th scope="col"><a data-sort-field="boardEndDate"
href="#">종료일</a></th>
<th scope="col"><a data-sort-field="updatedBy"
href="#">수정자</a></th>
<th scope="col"><a data-sort-field="updatedAt"
href="#">최근 수정일</a></th>
</tr>
</thead>
<tbody>
<tr th:each="item, status : ${listOutput.content}">
<th
scope="row"
th:text="${status.count + (listOutput.pageable.pageNumber * listOutput.pageable.pageSize)}">게시물번호
</th>
<td><label>
<input
name="checkedIds" th:value="${item.id}" type="checkbox"/></label>
<td><a th:href="|javascript:goSave('${item.id}')|"
th:text="${item.title}">Title</a></td>
<td><i th:if="${item.visible}"></i> <i
th:if="${!item.visible}"></i></td>
<td
th:text="${#temporals.format(item.boardStartDate, 'yyyy-MM-dd hh:mm')}">게시일
</td>
<td
th:text="${#temporals.format(item.boardEndDate, 'yyyy-MM-dd hh:mm')}">종료일
</td>
<td th:text="${item.updatedBy}">작성자</td>
<td
th:text="${#temporals.format(item.updatedAt, 'yyyy-MM-dd hh:mm')}">수정일
</td>
</tr>
</tbody>
</table>
</form>
<div th:replace="common/list-components :: pagination(${listOutput})"></div>
<script th:inline="javascript">
// 검색
function goSearch() {
const f = document.paramForm;
f.action = '/board/exampleBoard';
f.page.value = 0;
f.sort.value = convertToPageableSortValue(f.sort.value);
f.method = 'get';
f.submit();
}
// 초기화
function goInit() {
const f = document.paramForm;
f.searchField.value = '';
f.searchValue.value = '';
f.searchOpen.value = '';
}
// 수정페이지 이동
function goSave(itemId) {
const f = document.paramForm;
f.action = '/board/exampleBoard/update/' + itemId;
f.method = 'get';
f.submit();
}
function goExcel() {
const f = document.paramForm;
f.action = '/board/exampleBoard/excel';
f.method = 'get';
f.submit();
}
// 체크박스 선택/해제
function toggleCheckbox(oj) {
$('input[name=checkedIds]').prop("checked", oj.checked);
}
function goRemove() {
if (!$('input[name=checkedIds]').is(':checked')) {
alert(/*[[#{operation.common.remove.choose}]]*/);
return;
}
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
const f = document.paramForm;
f.action = '/board/exampleBoard/delete';
f.method = 'post';
f.submit();
}
}
</script>
</section>
</html>