공지사항 코어 추가.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package app.module.core.usecase.notice.createNotice.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
|
||||
import app.module.core.usecase.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
|
||||
import app.module.core.usecase.notice.createNotice.ports.CreateNoticePortOut;
|
||||
import app.module.core.usecase.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.core.usecase.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.core.usecase.notice.createNotice.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
|
||||
import app.module.core.usecase.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.core.usecase.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.core.usecase.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,11 @@
|
||||
package app.module.core.usecase.notice.createNotice.ports;
|
||||
|
||||
import app.module.core.usecase.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.core.usecase.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CreateNoticePortIn {
|
||||
|
||||
Optional<CreateNotice> operate(CreateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.core.usecase.notice.createNotice.ports;
|
||||
|
||||
import app.module.core.usecase.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.core.usecase.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.core.usecase.notice.createNotice.ports.application;
|
||||
|
||||
import app.module.core.config.application.annotation.CreateCommand;
|
||||
import app.module.core.usecase.notice.createNotice.ports.CreateNoticePortIn;
|
||||
import app.module.core.usecase.notice.createNotice.ports.CreateNoticePortOut;
|
||||
import app.module.core.usecase.notice.createNotice.ports.application.domain.CreateNotice;
|
||||
import app.module.core.usecase.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.core.usecase.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.core.usecase.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.core.usecase.notice.getNotice.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||
import app.module.core.usecase.notice.getNotice.ports.GetNoticePortOut;
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
|
||||
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.getId());
|
||||
|
||||
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,13 @@
|
||||
package app.module.core.usecase.notice.getNotice.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface GetNoticeMapper {
|
||||
GetNotice getNotice(Long id);
|
||||
List<GetNoticeUploadFile> getUploadFiles(Long id);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.core.usecase.notice.getNotice.ports;
|
||||
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GetNoticePortIn {
|
||||
|
||||
Optional<GetNotice> operate(GetNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.core.usecase.notice.getNotice.ports;
|
||||
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.core.usecase.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.core.usecase.notice.getNotice.ports.application;
|
||||
|
||||
import app.module.core.usecase.notice.getNotice.ports.GetNoticePortIn;
|
||||
import app.module.core.usecase.notice.getNotice.ports.GetNoticePortOut;
|
||||
import app.module.core.usecase.notice.getNotice.ports.application.domain.GetNotice;
|
||||
import app.module.core.usecase.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,27 @@
|
||||
package app.module.core.usecase.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;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.core.usecase.notice.getNotice.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNoticeCmd {
|
||||
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.core.usecase.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;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package app.module.core.usecase.notice.getNotices.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import app.module.core.usecase.notice.getNotices.adapters.persistence.model.GetNoticesDto;
|
||||
import app.module.core.usecase.notice.getNotices.ports.GetNoticesPortOut;
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNoticeFiles;
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNotices;
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNoticesCmd;
|
||||
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.EXAMPLE_REP));
|
||||
|
||||
return new PageImpl<>(
|
||||
contents.stream()
|
||||
.map(
|
||||
article ->
|
||||
new GetNotices(
|
||||
article.getId(),
|
||||
article.getUpdatedBy(),
|
||||
article.getUpdatedAt(),
|
||||
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.core.usecase.notice.getNotices.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import app.module.core.usecase.notice.getNotices.adapters.persistence.model.GetNoticesDto;
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNoticeFiles;
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNoticesCmd;
|
||||
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,22 @@
|
||||
package app.module.core.usecase.notice.getNotices.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 title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private Long total;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.core.usecase.notice.getNotices.ports;
|
||||
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNotices;
|
||||
import app.module.core.usecase.notice.getNotices.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.core.usecase.notice.getNotices.ports;
|
||||
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNotices;
|
||||
import app.module.core.usecase.notice.getNotices.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.core.usecase.notice.getNotices.ports.application;
|
||||
|
||||
import app.module.core.usecase.notice.getNotices.ports.GetNoticesPortIn;
|
||||
import app.module.core.usecase.notice.getNotices.ports.GetNoticesPortOut;
|
||||
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNotices;
|
||||
import app.module.core.usecase.notice.getNotices.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.core.usecase.notice.getNotices.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,24 @@
|
||||
package app.module.core.usecase.notice.getNotices.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 title;
|
||||
private String content;
|
||||
private Boolean visible;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private GetNoticeFiles uploadFile;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.core.usecase.notice.getNotices.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.core.usecase.notice.removeNotices.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
|
||||
import app.module.core.usecase.notice.removeNotices.ports.RemoveNoticesPortOut;
|
||||
import app.module.core.usecase.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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.core.usecase.notice.removeNotices.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.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.core.usecase.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,7 @@
|
||||
package app.module.core.usecase.notice.removeNotices.ports;
|
||||
|
||||
import app.module.core.usecase.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||
|
||||
public interface RemoveNoticesPortIn {
|
||||
void operate(RemoveNoticesCmd command);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.core.usecase.notice.removeNotices.ports;
|
||||
|
||||
import app.module.core.usecase.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||
|
||||
public interface RemoveNoticesPortOut {
|
||||
void operate(RemoveNoticesCmd command);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.core.usecase.notice.removeNotices.ports.application;
|
||||
|
||||
import app.module.core.usecase.notice.removeNotices.ports.RemoveNoticesPortIn;
|
||||
import app.module.core.usecase.notice.removeNotices.ports.RemoveNoticesPortOut;
|
||||
import app.module.core.usecase.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.core.usecase.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,52 @@
|
||||
package app.module.core.usecase.notice.updateNotice.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
|
||||
import app.module.core.usecase.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
|
||||
import app.module.core.usecase.notice.updateNotice.ports.UpdateNoticePortOut;
|
||||
import app.module.core.usecase.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()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.module.core.usecase.notice.updateNotice.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
|
||||
import app.module.core.usecase.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
|
||||
import app.module.core.usecase.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);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.core.usecase.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.core.usecase.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,8 @@
|
||||
package app.module.core.usecase.notice.updateNotice.ports;
|
||||
|
||||
import app.module.core.usecase.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||
|
||||
public interface UpdateNoticePortIn {
|
||||
|
||||
void operate(UpdateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.notice.updateNotice.ports;
|
||||
|
||||
import app.module.core.usecase.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||
|
||||
public interface UpdateNoticePortOut {
|
||||
|
||||
void operate(UpdateNoticeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.core.usecase.notice.updateNotice.ports.application;
|
||||
|
||||
import app.module.core.usecase.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||
import app.module.core.usecase.notice.updateNotice.ports.UpdateNoticePortOut;
|
||||
import app.module.core.usecase.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.core.usecase.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;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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.core.usecase.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>
|
||||
48
core/src/main/resources/mappers/notice/GetNoticeMapper.xml
Normal file
48
core/src/main/resources/mappers/notice/GetNoticeMapper.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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.core.usecase.notice.getNotice.adapters.persistence.GetNoticeMapper">
|
||||
<select id="getNotice"
|
||||
resultType="app.module.core.usecase.notice.getNotice.ports.application.domain.GetNotice">
|
||||
/* getNotice 상세 게시글 조회 */
|
||||
<if test="id != null">
|
||||
SELECT
|
||||
a.id AS id,
|
||||
a.title AS title,
|
||||
a.content AS content,
|
||||
a.visible AS visible,
|
||||
a.start_date AS startDate,
|
||||
a.end_date AS endDate,
|
||||
a.created_at AS createdAt,
|
||||
a.created_by AS createdBy,
|
||||
a.updated_at AS updatedAt,
|
||||
a.updated_by AS updatedBy
|
||||
FROM notice a
|
||||
WHERE a.id = #{id}
|
||||
AND a.is_deleted = false
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getUploadFiles"
|
||||
resultType="app.module.core.usecase.notice.getNotice.ports.application.domain.GetNoticeUploadFile">
|
||||
/* getUploadFiles 상세 게시글 조회 시, 첨부파일 조회 */
|
||||
SELECT
|
||||
awuf.notice_id AS noticeId,
|
||||
awuf.upload_files_id AS uploadfileId,
|
||||
uf.id AS id,
|
||||
uf.created_at AS createdAt,
|
||||
uf.created_by AS createdBy,
|
||||
uf.updated_at AS updatedAt,
|
||||
uf.updated_by AS updatedBy,
|
||||
uf.file_length AS fileLength,
|
||||
uf.name AS name,
|
||||
uf.origin_name AS originName,
|
||||
uf.path AS path,
|
||||
uf.type AS type
|
||||
FROM notice_has_upload_file awuf
|
||||
INNER JOIN upload_file uf
|
||||
ON awuf.upload_files_id = uf.id
|
||||
WHERE awuf.notice_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
85
core/src/main/resources/mappers/notice/GetNoticesMapper.xml
Normal file
85
core/src/main/resources/mappers/notice/GetNoticesMapper.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?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.core.usecase.notice.getNotices.adapters.persistence.GetNoticesMapper">
|
||||
|
||||
<select id="getNotices"
|
||||
resultType="app.module.core.usecase.notice.getNotices.adapters.persistence.model.GetNoticesDto">
|
||||
/* getNotices : 게시물 리스트 */
|
||||
SELECT
|
||||
a.id,
|
||||
a.updated_by,
|
||||
a.updated_at,
|
||||
a.title,
|
||||
a.content,
|
||||
a.visible,
|
||||
a.start_date,
|
||||
a.end_date,
|
||||
COUNT(*) OVER () AS total
|
||||
FROM notice a
|
||||
WHERE a.is_deleted = false
|
||||
|
||||
<if test="cmd.searchField != null and cmd.searchField != ''">
|
||||
<choose>
|
||||
<when test="cmd.searchField eq 'title'">
|
||||
AND a.title ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
<when test="cmd.searchField eq 'updatedBy'">
|
||||
AND a.updated_by ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<if test="cmd.searchOpen != null and cmd.searchOpen != ''">
|
||||
<choose>
|
||||
<when test="cmd.searchOpen eq 'true'">
|
||||
AND a.visible = true
|
||||
</when>
|
||||
<when test="cmd.searchOpen eq 'false'">
|
||||
AND a.visible = false
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<if test="pageable.sort != null and !pageable.sort.isEmpty()">
|
||||
ORDER BY
|
||||
<foreach collection="pageable.sort" item="order" separator=",">
|
||||
<choose>
|
||||
<when test="order.property eq 'title'">a.title</when>
|
||||
<when test="order.property eq 'visible'">a.visible</when>
|
||||
<when test="order.property eq 'startDate'">a.start_date</when>
|
||||
<when test="order.property eq 'endDate'">a.end_date</when>
|
||||
<when test="order.property eq 'updatedBy'">a.updated_by</when>
|
||||
<when test="order.property eq 'updatedAt'">a.updated_at</when>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="order.direction.toString() eq 'DESC'">DESC</when>
|
||||
<otherwise>ASC</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getUploadFiles"
|
||||
resultType="app.module.core.usecase.notice.getNotices.ports.application.domain.GetNoticeFiles">
|
||||
/* getUploadFiles : 게시물 리스트의 대표 이미지 */
|
||||
SELECT
|
||||
awuf.notice_id,
|
||||
uf.id,
|
||||
uf.type,
|
||||
uf.path,
|
||||
uf.name,
|
||||
uf.origin_name,
|
||||
uf.file_length
|
||||
FROM notice_has_upload_file awuf
|
||||
INNER JOIN upload_file uf ON awuf.upload_files_id = uf.id
|
||||
WHERE awuf.notice_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND uf.type = #{fileUploadType}
|
||||
AND uf.is_deleted = false
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.core.usecase.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>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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.core.usecase.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>
|
||||
@@ -1822,6 +1822,40 @@ COMMENT ON COLUMN notice.deleted_by IS '삭제자';
|
||||
COMMENT ON COLUMN notice.is_deleted IS '삭제여부';
|
||||
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- TABLE : notice_has_upload_file
|
||||
-- DESC : 공지사항 파일 매핑 테이블
|
||||
-- ============================================
|
||||
CREATE TABLE notice_has_upload_file (
|
||||
upload_files_id bigint NOT NULL, -- 업로드 파일 ID (FK)
|
||||
notice_id varchar(255) NOT NULL, -- 공지사항 ID (FK)
|
||||
created_at timestamp(6), -- 생성일
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일
|
||||
updated_by varchar(255), -- 수정자
|
||||
deleted_at timestamp(6), -- 삭제일
|
||||
deleted_by varchar(255), -- 삭제자
|
||||
is_deleted boolean DEFAULT false NOT NULL -- 삭제 여부
|
||||
);
|
||||
|
||||
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__notice FOREIGN KEY (notice_id) REFERENCES notice(id);
|
||||
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__upload_file FOREIGN KEY (upload_files_id) REFERENCES upload_file(id);
|
||||
|
||||
COMMENT ON TABLE notice_has_upload_file IS '공지사항 파일 매핑 테이블';
|
||||
|
||||
COMMENT ON COLUMN notice_has_upload_file.upload_files_id IS '업로드 파일 ID';
|
||||
COMMENT ON COLUMN notice_has_upload_file.notice_id IS '공지사항 ID';
|
||||
COMMENT ON COLUMN notice_has_upload_file.created_at IS '생성일';
|
||||
COMMENT ON COLUMN notice_has_upload_file.created_by IS '생성자';
|
||||
COMMENT ON COLUMN notice_has_upload_file.updated_at IS '수정일';
|
||||
COMMENT ON COLUMN notice_has_upload_file.updated_by IS '수정자';
|
||||
COMMENT ON COLUMN notice_has_upload_file.deleted_at IS '삭제일';
|
||||
COMMENT ON COLUMN notice_has_upload_file.deleted_by IS '삭제자';
|
||||
COMMENT ON COLUMN notice_has_upload_file.is_deleted IS '삭제여부';
|
||||
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- TABLE : address
|
||||
-- DESC : 주소마스터 테이블
|
||||
|
||||
Reference in New Issue
Block a user