공지사항
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortOut;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.admin.usecase.communication.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()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CreateNoticeMapper {
|
||||
void createNotice(CreateNoticeDto dto);
|
||||
void createNoticeHasUploadFile(CreateNoticeHasUploadFilesParam param);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeReqVO;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortIn;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class CreateNoticeController {
|
||||
|
||||
private final CreateNoticePortIn createNoticePortIn;
|
||||
@PostMapping(path = "/api/communication/notices/create")
|
||||
ResponseEntity<?> operate(@RequestBody @Valid CreateNoticeReqVO reqVO, BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
CreateNotice article =
|
||||
createNoticePortIn
|
||||
.operate(
|
||||
new CreateNoticeCmd(
|
||||
reqVO.getTitle(),
|
||||
reqVO.getContent(),
|
||||
reqVO.getVisible(),
|
||||
reqVO.getStartDate(),
|
||||
reqVO.getEndDate(),
|
||||
reqVO.getFileMappingId()))
|
||||
.orElseThrow();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(article);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeReqVO;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class CreateNoticeUIController {
|
||||
|
||||
@GetMapping(path = "/communication/notices/create")
|
||||
String operate(
|
||||
Model model,
|
||||
@ModelAttribute("reqVO") CreateNoticeUIReqVO reqVO) {
|
||||
|
||||
return "communication/notice/create";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateNoticeReqVO {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateNoticeUIReqVO {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateNoticePortIn {
|
||||
|
||||
Optional<CreateNotice> operate(CreateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateNoticePortOut {
|
||||
|
||||
Optional<CreateNotice> operate(CreateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.admin.usecase.communication.notice.createNotice.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortIn;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortOut;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||
import app.module.core.config.application.annotation.CreateCommand;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortOut;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
|
||||
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticeDao implements GetNoticePortOut {
|
||||
|
||||
private final GetNoticeMapper mapper;
|
||||
private final FileUrlPortIn fileUrlPortIn;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Optional<GetNotice> operate(GetNoticeCmd command) {
|
||||
GetNotice secArticle = mapper.getNotice(command);
|
||||
|
||||
List<GetNoticeUploadFile> setArticleUploadFile =
|
||||
mapper.getUploadFiles(command.getId());
|
||||
|
||||
secArticle.setUploadFiles(
|
||||
setArticleUploadFile.stream()
|
||||
.map(
|
||||
uploadFile -> {
|
||||
// 참조 URL 전달
|
||||
uploadFile.setReferURL(
|
||||
fileUrlPortIn.getInline(
|
||||
uploadFile.getType().getFileStorageType(),
|
||||
uploadFile.getPath(),
|
||||
uploadFile.getName()));
|
||||
// attachment URL 전달
|
||||
uploadFile.setAttachmentURL(
|
||||
fileUrlPortIn.getAttachment(
|
||||
uploadFile.getType().getFileStorageType(), uploadFile.getId()));
|
||||
|
||||
return uploadFile;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return Optional.of(secArticle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface GetNoticeMapper {
|
||||
|
||||
GetNotice getNotice(GetNoticeCmd command);
|
||||
|
||||
List<GetNoticeUploadFile> getUploadFiles(Long id);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticeController {
|
||||
private final GetNoticePortIn getNoticePortIn;
|
||||
|
||||
@GetMapping(path = "/api/communication/notices/{id}")
|
||||
ResponseEntity<?> operate(@PathVariable Long id) {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(getNoticePortIn.operate(new GetNoticeCmd(id)).orElseThrow());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetNoticePortIn {
|
||||
|
||||
Optional<GetNotice> operate(GetNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetNoticePortOut {
|
||||
|
||||
Optional<GetNotice> operate(GetNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortOut;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticeService implements GetNoticePortIn {
|
||||
|
||||
private final GetNoticePortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<GetNotice> operate(GetNoticeCmd command) {
|
||||
return portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.ports.application.domain;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNotice {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private List<GetNoticeUploadFile> uploadFiles;
|
||||
public boolean getNewDate() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return now.toLocalDate().isEqual(createdAt.toLocalDate());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticeUI.model;
|
||||
package app.module.admin.usecase.communication.notice.getNotice.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,5 +9,6 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNoticesReqVO {
|
||||
public class GetNoticeCmd {
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.admin.usecase.communication.notice.getNotice.ports.application.domain;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* DTO for {@link app.module.core.config.adapters.persistence.entity.UploadFile}
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GetNoticeUploadFile implements Serializable {
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private Long id;
|
||||
private FileUploadType type;
|
||||
private String path;
|
||||
private String name;
|
||||
private String originName;
|
||||
private Long fileLength;
|
||||
private String referURL;
|
||||
private String attachmentURL;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticeUI;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import app.module.admin.usecase.communication.notice.getNoticeUI.model.GetNoticesReqVO;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticesUIController {
|
||||
|
||||
@GetMapping(path = "/communication/notices")
|
||||
String operate(
|
||||
Model model,
|
||||
@ModelAttribute("reqVO") GetNoticesReqVO reqVO) {
|
||||
|
||||
return "communication/notices";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model.GetNoticesDto;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortOut;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticesDao implements GetNoticesPortOut {
|
||||
|
||||
private final GetNoticesMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command) {
|
||||
// 게시물 목록 얻기
|
||||
List<GetNoticesDto> contents =
|
||||
ListUtils.emptyIfNull(mapper.getNotices(pageable, command));
|
||||
|
||||
// 대표 이미지 목록 얻기
|
||||
List<GetNoticeFiles> uploadFiles =
|
||||
contents.isEmpty()
|
||||
? Collections.emptyList()
|
||||
: ListUtils.emptyIfNull(
|
||||
mapper.getUploadFiles(
|
||||
contents.stream().map(GetNoticesDto::getId)
|
||||
.collect(Collectors.toList()),
|
||||
FileUploadType.NOTICE));
|
||||
|
||||
return new PageImpl<>(
|
||||
contents.stream()
|
||||
.map(
|
||||
article ->
|
||||
new GetNotices(
|
||||
article.getId(),
|
||||
article.getUpdatedBy(),
|
||||
article.getUpdatedAt(),
|
||||
article.getCreatedBy(),
|
||||
article.getCreatedAt(),
|
||||
article.getTitle(),
|
||||
article.getContent(),
|
||||
article.getVisible(),
|
||||
article.getStartDate(),
|
||||
article.getEndDate(),
|
||||
uploadFiles.stream()
|
||||
.filter(file -> file.getNoticeId().equals(article.getId()))
|
||||
.findFirst()
|
||||
.orElse(null)))
|
||||
.collect(Collectors.toList()),
|
||||
pageable,
|
||||
contents.isEmpty() ? 0 : contents.get(0).getTotal());
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model.GetNoticesDto;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface GetNoticesMapper {
|
||||
List<GetNoticesDto> getNotices(
|
||||
@Param("pageable") Pageable pageable, @Param("cmd") GetNoticesCmd cmd);
|
||||
List<GetNoticeFiles> getUploadFiles(
|
||||
@Param("ids") List<Long> ids, @Param("fileUploadType") FileUploadType fileUploadType);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class GetNoticesDto {
|
||||
private Long id;
|
||||
private String updatedBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime createdAt;
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private Long total;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticesController {
|
||||
|
||||
private final GetNoticesPortIn getNoticesPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@GetMapping(path = "/api/communication/notices")
|
||||
ResponseEntity<?> operate(
|
||||
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, page = 0, size = 10) Pageable pageable,
|
||||
GetNoticesReqVO reqVO) {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(getNoticesPortIn.operate(pageable, new GetNoticesCmd(
|
||||
reqVO.getSearchField(),
|
||||
reqVO.getSearchValue(),
|
||||
reqVO.getSearchOpen()
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.AdminUtil;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticesUIController {
|
||||
|
||||
private final GetNoticesPortIn getNoticesPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@GetMapping(path = "/communication/notices")
|
||||
String operate(Model model, @PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, page = 0, size = 10) Pageable pageable
|
||||
, GetNoticesReqVO reqVO) {
|
||||
|
||||
Page<GetNotices> notices =
|
||||
getNoticesPortIn.operate(
|
||||
pageable,
|
||||
new GetNoticesCmd(
|
||||
reqVO.getSearchField(), reqVO.getSearchValue(), reqVO.getSearchOpen()));
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("notices", notices);
|
||||
|
||||
model.addAttribute("userRole", AdminUtil.getLoginUserRole());
|
||||
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
||||
|
||||
return "communication/notice/notices";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.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 GetNoticesReqVO {
|
||||
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String searchOpen;
|
||||
|
||||
|
||||
private Integer page;
|
||||
private String sort;
|
||||
private Integer size;
|
||||
|
||||
public Integer getPage() {
|
||||
// 요청 페이지 넘버 - 초기값 `0`
|
||||
return page != null ? page : 0;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
// 정렬 값 - 초기값 `orderNo 내림차순`
|
||||
return StringUtils.isEmpty(sort) ? "createdAt,DESC" : sort;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
// 페이지 당 아이템 수 - 초기값 `10`
|
||||
return size != null ? size : 10;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.ports;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GetNoticesPortIn {
|
||||
|
||||
Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command);
|
||||
|
||||
List<GetNotices> operateList(GetNoticesCmd command);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.ports;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GetNoticesPortOut {
|
||||
|
||||
Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command);
|
||||
|
||||
List<GetNotices> operateList(GetNoticesCmd command);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortOut;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetNoticesService implements GetNoticesPortIn {
|
||||
|
||||
private final GetNoticesPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command) {
|
||||
return portOut.operate(pageable, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GetNotices> operateList(GetNoticesCmd command) {
|
||||
return portOut.operateList(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNoticeFiles {
|
||||
private Long noticeId;
|
||||
private Long id;
|
||||
private FileUploadType type;
|
||||
private String path;
|
||||
private String name;
|
||||
private String originName;
|
||||
private Long fileLength;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNotices {
|
||||
private Long id;
|
||||
private String updatedBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime createdAt;
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private GetNoticeFiles uploadFile;
|
||||
|
||||
public boolean getNewDate() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return now.toLocalDate().isEqual(createdAt.toLocalDate());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNoticesCmd {
|
||||
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String searchOpen;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortOut;
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RemoveNoticesMapper {
|
||||
void deleteNotices(RemoveNoticesParam param);
|
||||
void deleteNoticeHasFiles(RemoveNoticesParam param);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.adapters.web.model.RemoveNoticesReqVO;
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||
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 RemoveNoticesController {
|
||||
private final RemoveNoticesPortIn removeNoticesPortIn;
|
||||
|
||||
@DeleteMapping(path = "/api/communication/notices/remove")
|
||||
ResponseEntity<?> operate(@Valid RemoveNoticesReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
removeNoticesPortIn.operate(new RemoveNoticesCmd(reqVO.getSelectIds()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveNoticesReqVO {
|
||||
private Set<Long> selectIds;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||
|
||||
public interface RemoveNoticesPortIn {
|
||||
void operate(RemoveNoticesCmd command);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||
|
||||
public interface RemoveNoticesPortOut {
|
||||
void operate(RemoveNoticesCmd command);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.communication.notice.removeNotices.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortOut;
|
||||
import app.module.admin.usecase.communication.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
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 NoticeHasUploadFile(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()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
|
||||
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UpdateNoticeMapper {
|
||||
void updateNotice(UpdateNoticeDto dto);
|
||||
void deleteFileUploads(NoticeHasUploadFile noticeHasUploadFile);
|
||||
void createFileUploads(CreateUploadFileParam param);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model.UpdateNoticeReqVO;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class UpdateNoticeController {
|
||||
private final UpdateNoticePortIn updateNoticePortIn;
|
||||
|
||||
@PutMapping(path = "/api/communication/notices/update")
|
||||
ResponseEntity<?> operate(@RequestBody @Valid UpdateNoticeReqVO reqVO, BindingResult bindingResult) {
|
||||
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
updateNoticePortIn.operate(
|
||||
new UpdateNoticeCmd(
|
||||
reqVO.getId(),
|
||||
reqVO.getTitle(),
|
||||
reqVO.getContent(),
|
||||
reqVO.getVisible(),
|
||||
reqVO.getStartDate(),
|
||||
reqVO.getEndDate(),
|
||||
reqVO.getFileMappingId()
|
||||
));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.AdminUtil;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class UpdateNoticeUIController {
|
||||
|
||||
private final UpdateNoticePortIn updateNoticePortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@GetMapping(path = "/communication/notices/{id}")
|
||||
String operate(Model model
|
||||
, @PathVariable @ModelAttribute("id") Long id) {
|
||||
|
||||
|
||||
return "communication/notice/{id}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateNoticeReqVO {
|
||||
@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 LocalDateTime startDate;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private List<String> fileMappingId;
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
public String getTitle() {
|
||||
return StringEscapeUtils.escapeHtml4(title);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return StringEscapeUtils.escapeHtml4(content);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||
|
||||
public interface UpdateNoticePortIn {
|
||||
|
||||
void operate(UpdateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.ports;
|
||||
|
||||
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||
|
||||
public interface UpdateNoticePortOut {
|
||||
|
||||
void operate(UpdateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.communication.notice.updateNotice.ports.application;
|
||||
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut;
|
||||
import app.module.admin.usecase.communication.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.module.admin.usecase.communication.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;
|
||||
}
|
||||
Reference in New Issue
Block a user