Merge branch 'dev' into susu
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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.communication.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.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;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.admin.usecase.household.createHousehold.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateResearcherHasHouseholdCmd;
|
||||
import app.module.core.config.application.annotation.CreateCommand;
|
||||
import app.module.core.config.application.util.AuditUtil;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdHasRoleCmd;
|
||||
@@ -7,6 +8,7 @@ import app.module.admin.usecase.household.createHousehold.ports.application.doma
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortOut;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
@@ -14,13 +16,22 @@ class CreateHouseholdDao implements CreateHouseholdPortOut {
|
||||
private final CreateHouseholdMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@CreateCommand
|
||||
public void operate(CreateHouseholdOutCmd outCmd) {
|
||||
// 임가 등록
|
||||
mapper.createHousehold(outCmd);
|
||||
|
||||
if(outCmd.getResearcherSeq() != null) {
|
||||
// 임가 역할 등록
|
||||
if(outCmd.getRoleIds() != null && !outCmd.getRoleIds().isEmpty()) {
|
||||
mapper.createHouseholdHasRole(
|
||||
AuditUtil.create(new CreateHouseholdHasRoleCmd(outCmd.getSeq(), outCmd.getRoleIds())));
|
||||
}
|
||||
|
||||
// 임가 담당 조사원 등록
|
||||
if(outCmd.getAdminSeq() != null) {
|
||||
mapper.createResearcherHasHousehold(
|
||||
AuditUtil.create(new CreateResearcherHasHouseholdCmd(outCmd.getSeq(), outCmd.getAdminSeq())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@ package app.module.admin.usecase.household.createHousehold.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdHasRoleCmd;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdOutCmd;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateResearcherHasHouseholdCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CreateHouseholdMapper {
|
||||
void createHousehold(CreateHouseholdOutCmd outCmd);
|
||||
void createHouseholdHasRole(CreateHouseholdHasRoleCmd cmd);
|
||||
void createResearcherHasHousehold(CreateResearcherHasHouseholdCmd cmd);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.admin.usecase.household.createHousehold.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.household.createHousehold.adapters.web.model.CreateHouseholdResVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortIn;
|
||||
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdInCmd;
|
||||
@@ -50,13 +51,13 @@ class CreateHouseholdController {
|
||||
reqVO.getIndustryMiddleCode(),
|
||||
reqVO.getIndustrySubMiddle(),
|
||||
reqVO.getIndustryDetail(),
|
||||
reqVO.getResearcherSeq(),
|
||||
reqVO.getAdminSeq(),
|
||||
reqVO.getIsPanel(),
|
||||
reqVO.getMemo()
|
||||
)
|
||||
);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(messageUtil.getMessage("operation.common.save.done"));
|
||||
.body(new CreateHouseholdResVO(reqVO.getHouseholdNum()));
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class CreateHouseholdReqVO {
|
||||
private String industryMiddleCode;
|
||||
private String industrySubMiddle;
|
||||
private String industryDetail;
|
||||
private Long researcherSeq;
|
||||
private Long adminSeq;
|
||||
private Boolean isPanel;
|
||||
private String memo;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ import lombok.Setter;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateHouseholdResVO {
|
||||
private String householdNum;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CreateHouseholdOutCmd extends AuditCommand {
|
||||
private String industryMiddleCode;
|
||||
private String industrySubMiddle;
|
||||
private String industryDetail;
|
||||
private Long researcherSeq;
|
||||
private Long adminSeq;
|
||||
private Boolean isPanel;
|
||||
private String memo;
|
||||
private List<String> roleIds;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.admin.usecase.household.createHousehold.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateResearcherHasHouseholdCmd extends AuditCommand {
|
||||
private Long householdSeq;
|
||||
private Long adminSeq;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.DeleteResearcherMappingCmd;
|
||||
import app.module.core.config.application.util.AuditUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.CreateResearcherMappingCmd;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.CreateResearcherMappingPortOut;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class CreateResearcherMappingDao implements CreateResearcherMappingPortOut {
|
||||
private final CreateResearcherMappingMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void operate(CreateResearcherMappingCmd cmd) {
|
||||
// 조사원 임가 매핑 되어있던 것 delete
|
||||
mapper.deleteResearcherMapping(
|
||||
AuditUtil.delete(new DeleteResearcherMappingCmd(cmd.getHouseholdSeqs())));
|
||||
|
||||
// 조사원 임가 매핑 새로 insert
|
||||
mapper.createResearcherMapping(
|
||||
AuditUtil.create(new CreateResearcherMappingCmd(cmd.getAdminSeq(), cmd.getHouseholdSeqs())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.CreateResearcherMappingCmd;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.DeleteResearcherMappingCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CreateResearcherMappingMapper {
|
||||
void deleteResearcherMapping(DeleteResearcherMappingCmd cmd);
|
||||
void createResearcherMapping(CreateResearcherMappingCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.CreateResearcherMappingPortIn;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.CreateResearcherMappingCmd;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.adapters.web.model.CreateResearcherMappingReqVO;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.adapters.web.model.CreateResearcherMappingResVO;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class CreateResearcherMappingController {
|
||||
|
||||
private final CreateResearcherMappingPortIn portIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PostMapping(path = "/api/household/researcherMapping/create")
|
||||
ResponseEntity<?> operate(@Valid @RequestBody CreateResearcherMappingReqVO reqVO,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(bindingResult);
|
||||
}
|
||||
|
||||
// 등록
|
||||
portIn.operate(
|
||||
new CreateResearcherMappingCmd(reqVO.getAdminSeq(), reqVO.getHouseholdSeqs()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new CreateResearcherMappingResVO(reqVO.getAdminSeq(), reqVO.getHouseholdSeqs()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateResearcherMappingReqVO {
|
||||
private Long adminSeq;
|
||||
private List<Long> householdSeqs;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateResearcherMappingResVO {
|
||||
private Long adminSeq;
|
||||
private List<Long> householdSeqs;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.ports;
|
||||
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.CreateResearcherMappingCmd;
|
||||
|
||||
public interface CreateResearcherMappingPortIn {
|
||||
void operate(CreateResearcherMappingCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.ports;
|
||||
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.CreateResearcherMappingCmd;
|
||||
|
||||
public interface CreateResearcherMappingPortOut {
|
||||
void operate(CreateResearcherMappingCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.ports.application;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.application.domain.CreateResearcherMappingCmd;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.CreateResearcherMappingPortIn;
|
||||
import app.module.admin.usecase.household.createResearcherMapping.ports.CreateResearcherMappingPortOut;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class CreateResearcherMappingService implements CreateResearcherMappingPortIn {
|
||||
private final CreateResearcherMappingPortOut portOut;
|
||||
|
||||
@Override
|
||||
public void operate(CreateResearcherMappingCmd cmd) {
|
||||
portOut.operate(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CreateResearcherMappingCmd extends AuditCommand {
|
||||
private Long adminSeq;
|
||||
private List<Long> householdSeqs;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.household.createResearcherMapping.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class DeleteResearcherMappingCmd extends AuditCommand {
|
||||
private List<Long> householdSeqs;
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import lombok.Setter;
|
||||
public class GetBankAutoTransferExpenseRecords {
|
||||
private Long id;
|
||||
private String categoryText;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
private Integer count;
|
||||
private String unitText;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class GetBankAutoTransferIncomeRecords {
|
||||
private Long id;
|
||||
private String cropText;
|
||||
private String categoryText;
|
||||
private String categorySelf;
|
||||
private String target;
|
||||
private String sourcePurpose;
|
||||
private Integer count;
|
||||
private String unitText;
|
||||
|
||||
@@ -18,11 +18,11 @@ public class GetForestProductsStatus {
|
||||
private String cropName;
|
||||
private String landArea;
|
||||
private String mainYield;
|
||||
private String mainYieldText;
|
||||
private String mainYieldUnitText;
|
||||
private String mainSaleAmount;
|
||||
private String mainSaleAmountText;
|
||||
private String mainSaleAmountUnitText;
|
||||
private String subYield;
|
||||
private String subYieldText;
|
||||
private String subYieldUnitText;
|
||||
private String subSaleAmount;
|
||||
private String subSaleAmountText;
|
||||
private String subSaleAmountUnitText;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.adapters.persistence;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchers;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchersCmd;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.GetPopupResearchersPortOut;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetPopupResearchersDao implements GetPopupResearchersPortOut {
|
||||
private final GetPopupResearchersMapper mapper;
|
||||
|
||||
@Override
|
||||
public Page<GetPopupResearchers> operate(Pageable pageable, GetPopupResearchersCmd cmd) {
|
||||
List<GetPopupResearchers> result = mapper.getPopupResearchers(pageable, cmd);
|
||||
|
||||
return new PageImpl<>(result, pageable, result.isEmpty() ? 0 : result.get(0).getTotal());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchers;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchersCmd;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@Mapper
|
||||
public interface GetPopupResearchersMapper {
|
||||
List<GetPopupResearchers> getPopupResearchers(@Param("pageable") Pageable pageable,
|
||||
@Param("cmd") GetPopupResearchersCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.GetPopupResearchersPortIn;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchersCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.adapters.web.model.GetPopupResearchersReqVO;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.adapters.web.model.GetPopupResearchersResVO;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetPopupResearchersController {
|
||||
|
||||
private final GetPopupResearchersPortIn portIn;
|
||||
|
||||
@GetMapping(path = "/api/popupResearchers")
|
||||
ResponseEntity<?> operate(
|
||||
@PageableDefault(size = 10) Pageable pageable, GetPopupResearchersReqVO reqVO) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(portIn.operate(pageable,
|
||||
new GetPopupResearchersCmd(reqVO.getSearchField(), reqVO.getSearchValue(),
|
||||
reqVO.getRegionMainCode())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetPopupResearchersReqVO {
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String regionMainCode;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.communication.notice.getNoticeUI.model;
|
||||
package app.module.admin.usecase.household.getPopupResearchers.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,5 +9,5 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetNoticesReqVO {
|
||||
public class GetPopupResearchersResVO {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.ports;
|
||||
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchers;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchersCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetPopupResearchersPortIn {
|
||||
Page<GetPopupResearchers> operate(Pageable pageable, GetPopupResearchersCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.ports;
|
||||
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchers;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchersCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetPopupResearchersPortOut {
|
||||
Page<GetPopupResearchers> operate(Pageable pageable, GetPopupResearchersCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.ports.application;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchers;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchersCmd;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.GetPopupResearchersPortIn;
|
||||
import app.module.admin.usecase.household.getPopupResearchers.ports.GetPopupResearchersPortOut;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetPopupResearchersService implements GetPopupResearchersPortIn {
|
||||
private final GetPopupResearchersPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Page<GetPopupResearchers> operate(Pageable pageable, GetPopupResearchersCmd cmd) {
|
||||
return portOut.operate(pageable, cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetPopupResearchers {
|
||||
private Long adminSeq;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String regionMainName;
|
||||
private Integer householdCount;
|
||||
private Integer total;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.admin.usecase.household.getPopupResearchers.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetPopupResearchersCmd {
|
||||
private String searchField;
|
||||
private String searchValue;
|
||||
private String regionMainCode;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace="app.module.admin.usecase.household.createHousehold.adapters.persistence.CreateHouseholdMapper">
|
||||
|
||||
<insert id="createHousehold">
|
||||
/* createHousehold : 임가 등록 */
|
||||
<selectKey keyProperty="seq" resultType="long" order="BEFORE">
|
||||
SELECT nextval('household_seq')
|
||||
</selectKey>
|
||||
@@ -81,6 +82,7 @@
|
||||
</insert>
|
||||
|
||||
<insert id="createHouseholdHasRole">
|
||||
/* createHouseholdHasRole : 임가 역할 등록 */
|
||||
INSERT INTO household_has_role (id,
|
||||
household_seq,
|
||||
role_id,
|
||||
@@ -95,4 +97,22 @@
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="createResearcherHasHousehold">
|
||||
/* createResearcherHasHousehold : 임가 등록 시 담당 조사원 매핑 */
|
||||
INSERT INTO researcher_has_household
|
||||
(
|
||||
id,
|
||||
household_seq,
|
||||
admin_seq,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
nextval('researcher_has_household_seq'),
|
||||
#{householdSeq},
|
||||
#{adminSeq},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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.admin.usecase.household.createResearcherMapping.adapters.persistence.CreateResearcherMappingMapper">
|
||||
|
||||
<update id="deleteResearcherMapping">
|
||||
/* deleteResearcherMapping : 조사원 임가 매핑 삭제 */
|
||||
UPDATE researcher_has_household
|
||||
SET <include refid="common.fields.DeleteBaseSet"/>
|
||||
WHERE is_deleted = false
|
||||
AND household_seq IN
|
||||
<foreach collection="householdSeqs" item="householdSeq" open="(" separator="," close=")">
|
||||
#{householdSeq}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<insert id="createResearcherMapping">
|
||||
/* createResearcherMapping : 조사원 임가 매핑 등록 */
|
||||
INSERT INTO researcher_has_household
|
||||
(
|
||||
id,
|
||||
admin_seq,
|
||||
household_seq,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="householdSeqs" item="householdSeq" separator=",">
|
||||
(
|
||||
nextval('researcher_has_household_seq'),
|
||||
#{adminSeq},
|
||||
#{householdSeq},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -6,38 +6,77 @@
|
||||
<select id="getBankAutoTransferIncomeRecords"
|
||||
resultType="app.module.admin.usecase.household.getBankAutoTransferRecords.ports.application.domain.GetBankAutoTransferIncomeRecords">
|
||||
/* getBankAutoTransferIncomeRecords : 은행자동이체 (수입) 내역 목록 조회 */
|
||||
SELECT bat.id, /* 수입 id */
|
||||
ui_crop.code_text AS cropText, /* 재배형태 */
|
||||
ui_category.code_text AS categoryText, /* 수입의 종류 (코드명) */
|
||||
bat.transfer_category AS categorySelf, /* 수입의 종류 (텍스트입력) */
|
||||
bat.source_purpose AS sourcePurpose, /* 수입원 */
|
||||
bat.count, /* 수량 */
|
||||
ui_unit.code_text AS unitText, /* 단위 */
|
||||
bat.price /* 현금(원) */
|
||||
SELECT bat.id, /* 수입 id */
|
||||
ui_crop.code_text AS cropText, /* 재배형태 */
|
||||
-- TODO(ks) : 이게 맞나 싶지만.. 일단 .. case when 으로 ..
|
||||
CASE
|
||||
WHEN ui_category.id = 'code.bank.input.self'
|
||||
THEN bat.transfer_category
|
||||
ELSE ui_category.code_text
|
||||
END AS categoryText, /* 수입의 종류 */
|
||||
CASE
|
||||
WHEN ui_category.id = 'code.bank.input.self'
|
||||
THEN '-'
|
||||
ELSE bat.transfer_category
|
||||
END AS target, /* 대상(수입의 종류 텍스트입력) */
|
||||
bat.source_purpose AS sourcePurpose, /* 수입원 */
|
||||
bat.count, /* 수량 */
|
||||
CASE
|
||||
WHEN ui_unit.id = 'code.record.unit.self'
|
||||
THEN bat.unit
|
||||
ELSE ui_unit.code_text
|
||||
END AS unitText, /* 단위 */
|
||||
bat.price AS price /* 현금(원) */
|
||||
FROM bank_auto_transfer bat
|
||||
LEFT JOIN uicode ui_crop ON ui_crop.parent_id = 'code.record.crop' AND ui_crop.id = bat.crop_code
|
||||
LEFT JOIN uicode ui_unit ON ui_unit.parent_id = 'code.record.unit' AND ui_unit.id = bat.unit_code
|
||||
LEFT JOIN uicode ui_category ON ui_category.parent_id = 'code.bank.input' AND ui_category.id = bat.transfer_category_code
|
||||
LEFT JOIN uicode ui_crop
|
||||
ON ui_crop.parent_id = 'code.record.crop'
|
||||
AND ui_crop.id = bat.crop_code
|
||||
AND ui_crop.is_deleted = false
|
||||
LEFT JOIN uicode ui_unit
|
||||
ON ui_unit.parent_id = 'code.record.unit'
|
||||
AND ui_unit.id = bat.unit_code
|
||||
AND ui_unit.is_deleted = false
|
||||
LEFT JOIN uicode ui_category
|
||||
ON ui_category.parent_id = 'code.bank.input'
|
||||
AND ui_category.id = bat.transfer_category_code
|
||||
AND ui_category.is_deleted = false
|
||||
WHERE bat.transfer_type = 'code.bank.input'
|
||||
AND bat.household_seq = #{householdSeq}
|
||||
AND bat.month = #{recordMonth}
|
||||
AND bat.is_deleted = false
|
||||
</select>
|
||||
|
||||
<select id="getBankAutoTransferExpenseRecords"
|
||||
resultType="app.module.admin.usecase.household.getBankAutoTransferRecords.ports.application.domain.GetBankAutoTransferExpenseRecords">
|
||||
/* getBankAutoTransferExpenseRecords : 은행자동이체 (지출) 내역 목록 조회 */
|
||||
SELECT bat.id, /* 지출 id */
|
||||
ui_category.code_text AS cropText, /* 지출의 종류 (코드명) */
|
||||
bat.transfer_category AS categorySelf, /* 지출의 종류 (텍스트입력) */
|
||||
bat.source_purpose AS sourcePurpose, /* 용도 */
|
||||
bat.count, /* 수량 */
|
||||
ui_unit.code_text AS unitText, /* 단위 */
|
||||
bat.price /* 현금(원) */
|
||||
SELECT bat.id, /* 지출 id */
|
||||
CASE
|
||||
WHEN ui_category.id = 'code.bank.input.self'
|
||||
THEN bat.transfer_category
|
||||
ELSE ui_category.code_text
|
||||
END AS categoryText, /* 지출의 종류 */
|
||||
bat.source_purpose AS sourcePurpose, /* 용도 */
|
||||
bat.count, /* 수량 */
|
||||
CASE
|
||||
WHEN ui_unit.id = 'code.record.unit.self'
|
||||
THEN bat.unit
|
||||
ELSE ui_unit.code_text
|
||||
END AS unitText, /* 단위 */
|
||||
bat.price /* 현금(원) */
|
||||
FROM bank_auto_transfer bat
|
||||
LEFT JOIN uicode ui_unit ON ui_unit.parent_id = 'code.record.unit' AND ui_unit.id = bat.unit_code
|
||||
LEFT JOIN uicode ui_category ON ui_category.parent_id = 'code.bank.input' AND ui_category.id = bat.transfer_category_code
|
||||
LEFT JOIN
|
||||
uicode ui_unit
|
||||
ON ui_unit.parent_id = 'code.record.unit'
|
||||
AND ui_unit.id = bat.unit_code
|
||||
AND ui_unit.is_deleted = false
|
||||
LEFT JOIN
|
||||
uicode ui_category
|
||||
ON ui_category.parent_id = 'code.bank.output'
|
||||
AND ui_category.id = bat.transfer_category_code
|
||||
AND ui_category.is_deleted = false
|
||||
WHERE bat.transfer_type = 'code.bank.output'
|
||||
AND bat.household_seq = #{householdSeq}
|
||||
AND bat.month = #{recordMonth}
|
||||
AND bat.is_deleted = false
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -16,27 +16,55 @@
|
||||
<select id="getForestProductsStatus"
|
||||
resultType="app.module.admin.usecase.household.getForestProductsStatus.ports.application.domain.GetForestProductsStatus">
|
||||
/* getForestProductsStatus : 임가 현황의 임산물 현황 목록 조회 */
|
||||
SELECT df.id, /* 임산물 현황 id */
|
||||
df.street_num, /* 지번 */
|
||||
df.land_type, /* 지목 */
|
||||
df.town, /* 읍면동 */
|
||||
df.available_area, /* 가능면적 */
|
||||
df.crop_name, /* 재배작물명 */
|
||||
df.land_area, /* 면적 */
|
||||
df.main_yield, /* 주생산물 수확량 */
|
||||
ui_main_yield.code_text, /* 주생산물 수확량 단위 */
|
||||
df.main_sale_amount, /* 주생산물 판매량 */
|
||||
ui_main_sale.code_text , /* 주생산물 판매량 단위 */
|
||||
df.sub_yield, /* 부생산물 수확량 */
|
||||
ui_sub_yield.code_text , /* 주생산물 판매량 단위 */
|
||||
df.sub_sale_amount, /* 부생산물 판매량 */
|
||||
ui_sub_sale.code_text /* 부생산물 판매량 단위 */
|
||||
SELECT df.id, /* 임산물 현황 id */
|
||||
df.street_num, /* 지번 */
|
||||
df.land_type, /* 지목 */
|
||||
df.town, /* 읍면동 */
|
||||
df.available_area, /* 가능면적 */
|
||||
df.crop_name, /* 재배작물명 */
|
||||
df.land_area, /* 면적 */
|
||||
df.main_yield, /* 주생산물 수확량 */
|
||||
CASE
|
||||
WHEN ui_main_yield.id = 'code.record.unit.self'
|
||||
THEN df.main_yield_unit
|
||||
ELSE ui_main_yield.code_text
|
||||
END AS main_yield_unit_text, /* 주생산물 수확량 단위 */
|
||||
df.main_sale_amount, /* 주생산물 판매량 */
|
||||
CASE
|
||||
WHEN ui_main_sale.id = 'code.record.unit.self'
|
||||
THEN df.main_sale_unit
|
||||
ELSE ui_main_sale.code_text
|
||||
END AS main_sale_unit_text, /* 주생산물 판매량 단위 */
|
||||
df.sub_yield, /* 부생산물 수확량 */
|
||||
CASE
|
||||
WHEN ui_sub_yield.id = 'code.record.unit.self'
|
||||
THEN df.sub_yield_unit
|
||||
ELSE ui_sub_yield.code_text
|
||||
END AS sub_yield_unit_text, /* 부생산물 수확량 단위 */
|
||||
df.sub_sale_amount, /* 부생산물 판매량 */
|
||||
CASE
|
||||
WHEN ui_sub_sale.id = 'code.record.unit.self'
|
||||
THEN df.sub_sale_unit
|
||||
ELSE ui_sub_sale.code_text
|
||||
END AS sub_sale_unit_text /* 부생산물 판매량 단위 */
|
||||
FROM forest_product df
|
||||
-- TODO(ks) : 일단 전부 join.. 추후에 view 로 만들든지 개선해보기..
|
||||
LEFT JOIN uicode ui_main_yield ON ui_main_yield.parent_id = 'code.record.unit' AND ui_main_yield.id = df.main_yield_unit_code
|
||||
LEFT JOIN uicode ui_main_sale ON ui_main_sale.parent_id = 'code.record.unit' AND ui_main_sale.id = df.main_sale_unit_code
|
||||
LEFT JOIN uicode ui_sub_yield ON ui_sub_yield.parent_id = 'code.record.unit' AND ui_sub_yield.id = df.sub_yield_unit_code
|
||||
LEFT JOIN uicode ui_sub_sale ON ui_sub_sale.parent_id = 'code.record.unit' AND ui_sub_sale.id = df.sub_sale_unit_code
|
||||
LEFT JOIN uicode ui_main_yield
|
||||
ON ui_main_yield.parent_id = 'code.record.unit'
|
||||
AND ui_main_yield.id = df.main_yield_unit_code
|
||||
AND ui_main_yield.is_deleted = false
|
||||
LEFT JOIN uicode ui_main_sale
|
||||
ON ui_main_sale.parent_id = 'code.record.unit'
|
||||
AND ui_main_sale.id = df.main_sale_unit_code
|
||||
AND ui_main_sale.is_deleted = false
|
||||
LEFT JOIN uicode ui_sub_yield
|
||||
ON ui_sub_yield.parent_id = 'code.record.unit'
|
||||
AND ui_sub_yield.id = df.sub_yield_unit_code
|
||||
AND ui_sub_yield.is_deleted = false
|
||||
LEFT JOIN uicode ui_sub_sale
|
||||
ON ui_sub_sale.parent_id = 'code.record.unit'
|
||||
AND ui_sub_sale.id = df.sub_sale_unit_code
|
||||
AND ui_sub_sale.is_deleted = false
|
||||
WHERE df.household_seq = #{householdSeq}
|
||||
AND df.month = #{recordMonth}
|
||||
AND df.is_deleted = false
|
||||
|
||||
@@ -7,57 +7,77 @@
|
||||
<select id="getHouseholdsStatus"
|
||||
resultType="app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus">
|
||||
/* getHouseholdsStatus : 임가현황 리스트 조회 */
|
||||
WITH record_progress AS (
|
||||
SELECT ROUND(
|
||||
100.0 *
|
||||
(SELECT COUNT(*)
|
||||
FROM daily_record
|
||||
WHERE record_month = #{cmd.recordMonth} AND all_status = 'DONE')
|
||||
/ NULLIF(
|
||||
(SELECT COUNT(*)
|
||||
FROM daily_day_group
|
||||
WHERE end_day <= EXTRACT(DAY FROM CURRENT_DATE)), 0
|
||||
),
|
||||
2
|
||||
) AS progress_percent
|
||||
) /* 일계부 입력 진행 완료 퍼센테이지 (이번달 작성 완료일 수 / 현재날짜 기준 전체 입력 가능 날짜 수) */
|
||||
WITH daily_progress AS (
|
||||
/* 임가별 이번달 완료된 일 수 계산 */
|
||||
SELECT
|
||||
household_seq,
|
||||
COUNT(*) as completed_days
|
||||
FROM daily_record
|
||||
WHERE record_month = #{cmd.recordMonth}
|
||||
AND all_status IN ('DONE', 'TODAY_NONE')
|
||||
GROUP BY household_seq
|
||||
),
|
||||
total_days AS (
|
||||
/* 오늘 날짜 기준 전체 입력 가능 날짜 수 */
|
||||
SELECT COUNT(*) as total_possible_days
|
||||
FROM daily_day_group
|
||||
WHERE end_day <= EXTRACT(DAY FROM CURRENT_DATE)
|
||||
),
|
||||
visit_summary AS (
|
||||
/* 임가별 1차임가방문, 2차임가방문, 답례품전달여부 */
|
||||
SELECT
|
||||
rhh.household_seq,
|
||||
MIN(v.visit_date) AS first_visit_date,
|
||||
MAX(v.visit_date) AS second_visit_date,
|
||||
BOOL_OR(v.is_gift_sent) AS is_gift_sent
|
||||
FROM household_visit v
|
||||
JOIN researcher_has_household rhh ON v.household_seq = rhh.household_seq
|
||||
WHERE rhh.is_deleted = false
|
||||
AND TO_CHAR(v.visit_date, 'YYYYMM') = #{cmd.recordMonth}
|
||||
GROUP BY rhh.household_seq
|
||||
)
|
||||
SELECT
|
||||
hvr.*,
|
||||
COUNT(*) OVER () AS total
|
||||
FROM (
|
||||
SELECT
|
||||
r.admin_seq AS adminSeq,
|
||||
h.seq AS householdSeq,
|
||||
h.household_num AS householdNum,
|
||||
h.owner_name AS householdName,
|
||||
h.phone AS householdPhone,
|
||||
h.region_main_code AS regionMainCode,
|
||||
h.region_main_name AS regionMainName,
|
||||
h.region_sub_code AS regionSubCode,
|
||||
h.region_sub_name AS regionSubName,
|
||||
h.region_detail_code AS regionDetailCode,
|
||||
h.region_detail_name AS regionDetailName,
|
||||
h.industry_large_code as industryLargeCode,
|
||||
h.industry_large_name AS industryLargeName,
|
||||
h.industry_middle_code as industryMiddleCode,
|
||||
h.industry_middle_name AS industryMiddleName,
|
||||
h.is_panel AS isPanel,
|
||||
ps.progress_percent AS progressPercent,
|
||||
v.first_visit_date AS firstVisitDate,
|
||||
v.second_visit_date AS secondVisitDate,
|
||||
COALESCE(v.is_gift_sent, false) AS isGiftSent,
|
||||
r.researcher_name AS researcherName,
|
||||
r.researcher_phone AS researcherPhone
|
||||
r.admin_seq AS adminSeq,
|
||||
h.seq AS householdSeq,
|
||||
h.household_num AS householdNum,
|
||||
h.owner_name AS householdName,
|
||||
h.phone AS householdPhone,
|
||||
h.region_main_code AS regionMainCode,
|
||||
h.region_main_name AS regionMainName,
|
||||
h.region_sub_code AS regionSubCode,
|
||||
h.region_sub_name AS regionSubName,
|
||||
h.region_detail_code AS regionDetailCode,
|
||||
h.region_detail_name AS regionDetailName,
|
||||
h.industry_large_code AS industryLargeCode,
|
||||
h.industry_large_name AS industryLargeName,
|
||||
h.industry_middle_code AS industryMiddleCode,
|
||||
h.industry_middle_name AS industryMiddleName,
|
||||
h.is_panel AS isPanel,
|
||||
/* 일계부 입력 진행 완료 퍼센테이지 (이번달 작성 완료일 수 / 현재날짜 기준 전체 입력 가능 날짜 수) */
|
||||
ROUND(
|
||||
100.0 * COALESCE(dp.completed_days, 0) / NULLIF(td.total_possible_days, 0),
|
||||
2
|
||||
) AS progressPercent,
|
||||
vs.first_visit_date AS firstVisitDate,
|
||||
vs.second_visit_date AS secondVisitDate,
|
||||
COALESCE(vs.is_gift_sent, false) AS isGiftSent,
|
||||
r.researcher_name AS researcherName,
|
||||
r.researcher_phone AS researcherPhone
|
||||
FROM v_household_with_code h
|
||||
LEFT JOIN v_household_visit v ON h.seq = v.household_seq
|
||||
CROSS JOIN total_days td
|
||||
LEFT JOIN daily_progress dp ON h.seq = dp.household_seq
|
||||
LEFT JOIN visit_summary vs ON h.seq = vs.household_seq
|
||||
LEFT JOIN v_household_researcher r ON h.seq = r.household_seq
|
||||
CROSS JOIN record_progress ps
|
||||
) AS hvr
|
||||
|
||||
<where>
|
||||
1=1
|
||||
|
||||
<if test="cmd.ownerField != null and cmd.ownerField != ''">
|
||||
<if test="cmd.ownerField != null and cmd.ownerField != '' and cmd.ownerValue != ''">
|
||||
/* 경영주 검색 */
|
||||
<choose>
|
||||
<when test="cmd.ownerField eq 'name'">
|
||||
@@ -69,7 +89,7 @@
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<if test="cmd.researcherField != null and cmd.researcherField != ''">
|
||||
<if test="cmd.researcherField != null and cmd.researcherField != '' and cmd.researcherValue != ''">
|
||||
/* 조사원 검색 */
|
||||
<choose>
|
||||
<when test="cmd.researcherField eq 'name'">
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.admin.usecase.household.getPopupResearchers.adapters.persistence.GetPopupResearchersMapper">
|
||||
<select id="getPopupResearchers"
|
||||
resultType="app.module.admin.usecase.household.getPopupResearchers.ports.application.domain.GetPopupResearchers">
|
||||
SELECT
|
||||
a.seq AS adminSeq,
|
||||
a.name,
|
||||
a.phone,
|
||||
u.code_text AS regionMainName,
|
||||
COUNT(DISTINCT rhh.household_seq) AS householdCount,
|
||||
COUNT(*) OVER() AS total
|
||||
FROM admin a
|
||||
JOIN admin_has_role ahr
|
||||
ON a.seq = ahr.admin_seq
|
||||
AND ahr.role_id = 'ROLE_RESEARCHER'
|
||||
AND ahr.is_deleted = false
|
||||
LEFT JOIN uicode u
|
||||
ON u.parent_id = 'code.region.main'
|
||||
AND u.id = a.region_main_code
|
||||
LEFT JOIN researcher_has_household rhh
|
||||
ON rhh.admin_seq = a.seq
|
||||
AND rhh.is_deleted = false
|
||||
WHERE a.is_deleted = false AND a.account_disabled = false
|
||||
|
||||
<if test="cmd.searchField != null and cmd.searchField != '' and cmd.searchValue != ''">
|
||||
/* 조사원 검색 */
|
||||
<choose>
|
||||
<when test="cmd.searchField eq 'name'">
|
||||
AND a.name ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
<when test="cmd.searchField eq 'phone'">
|
||||
AND a.phone ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<if test="cmd.regionMainCode != null and cmd.regionMainCode != ''">
|
||||
/* 실사 검색 */
|
||||
AND a.region_main_code = #{cmd.regionMainCode}
|
||||
</if>
|
||||
|
||||
GROUP BY a.seq, a.name, a.phone, u.code_text, a.region_main_code
|
||||
ORDER BY a.region_main_code ASC
|
||||
|
||||
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -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.admin.usecase.communication.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="fileMappingIds" item="fileId" separator=",">
|
||||
(
|
||||
#{id},
|
||||
#{fileId},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
||||
49
admin/src/main/resources/mappers/notice/GetNoticeMapper.xml
Normal file
49
admin/src/main/resources/mappers/notice/GetNoticeMapper.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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.admin.usecase.communication.notice.getNotice.adapters.persistence.GetNoticeMapper">
|
||||
<select id="getNotice"
|
||||
resultType="app.module.admin.usecase.communication.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.admin.usecase.communication.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} AND awuf.is_deleted = false
|
||||
</select>
|
||||
</mapper>
|
||||
97
admin/src/main/resources/mappers/notice/GetNoticesMapper.xml
Normal file
97
admin/src/main/resources/mappers/notice/GetNoticesMapper.xml
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.GetNoticesMapper">
|
||||
|
||||
<select id="getNotices"
|
||||
resultType="app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model.GetNoticesDto">
|
||||
/* getNotices : 게시물 리스트 */
|
||||
SELECT
|
||||
a.id,
|
||||
a.updated_by,
|
||||
a.updated_at,
|
||||
a.created_by,
|
||||
a.created_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 'titleContent'">
|
||||
AND ( a.title ILIKE '%' || #{cmd.searchValue} || '%' OR a.content ILIKE '%' || #{cmd.searchValue} || '%' )
|
||||
</when>
|
||||
|
||||
<when test="cmd.searchField eq 'title'">
|
||||
AND a.title ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
<when test="cmd.searchField eq 'content'">
|
||||
AND a.content 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>
|
||||
<when test="order.property eq 'createdBy'">a.created_by</when>
|
||||
<when test="order.property eq 'createdAt'">a.created_at</when>
|
||||
<otherwise>a.id</otherwise>
|
||||
</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.admin.usecase.communication.notice.getNoticesUI.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.admin.usecase.communication.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,45 @@
|
||||
<?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.admin.usecase.communication.notice.updateNotice.adapters.persistence.UpdateNoticeMapper">
|
||||
|
||||
<update id="deleteFileUploads">
|
||||
/* deleteFileUploads 게시글 수정 시, 첨부파일 join 데이터 삭제 */
|
||||
UPDATE notice_has_upload_file
|
||||
SET
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
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>
|
||||
@@ -37,6 +37,9 @@ let uiUtil = {
|
||||
isoStrToReadable(isoStr) {
|
||||
return isoStr.replace(/T/, ' ').substring(0, 19);
|
||||
},
|
||||
isoStrToDateOnly(isoStr) {
|
||||
return isoStr.split('T')[0];
|
||||
},
|
||||
// Pagination UI 생성 함수
|
||||
getPagingUI(curPageNo, size, totalPages, moveHandler) {
|
||||
curPageNo = parseInt(curPageNo);
|
||||
@@ -280,6 +283,8 @@ uiUtil.showFileInfo = (input, uploadFile, showImg) => {
|
||||
|
||||
inputGroup.find('.fileInfo').remove();
|
||||
|
||||
|
||||
|
||||
inputGroup.append(`
|
||||
<div class="fileInfo row text-muted fw-normal" style="display: none">
|
||||
<img src="${showImg ? uploadFile.referURL : ''}" class="w-75 mt-3 mb-3"/>
|
||||
@@ -292,6 +297,7 @@ uiUtil.showFileInfo = (input, uploadFile, showImg) => {
|
||||
</div>
|
||||
`);
|
||||
|
||||
|
||||
const fileInfo = inputGroup.find('.fileInfo');
|
||||
if (!showImg) {
|
||||
fileInfo.find('img').remove();
|
||||
@@ -453,7 +459,7 @@ const showAudit = (auditItem, createdBy, createdAt, updatedBy, updatedAt) => {
|
||||
})
|
||||
})();
|
||||
|
||||
const ifNullDash = (value, fallback = '-') => {
|
||||
const ifNullHyphen = (value, fallback = '-') => {
|
||||
return value !== null && value !== undefined && value !== '' ? value : fallback;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<div class="layer-wrap" th:fragment="modalFragment">
|
||||
<form autocomplete="off" method="get" name="reqResearcherForm">
|
||||
<input name="page" value="0" type="hidden"/>
|
||||
<input name="size" value="10" type="hidden">
|
||||
|
||||
<div class="component-modal mypage-wrap modal01" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
@@ -51,9 +52,7 @@
|
||||
실사
|
||||
</p>
|
||||
</div>
|
||||
<select class="select-list" name="searchArea" id="regionMainCodeSelect" required>
|
||||
<option value="" disabled hidden>선택해주세요.</option>
|
||||
<option value="" selected>전체</option>
|
||||
<select class="select-list" name="regionMainCode" id="regionMainCodeSelect" required>
|
||||
<!-- ajax 호출 -->
|
||||
</select>
|
||||
</div>
|
||||
@@ -64,10 +63,10 @@
|
||||
<!-- 버튼 그룹 -->
|
||||
<div class="component-btns">
|
||||
<div class="btns-row">
|
||||
<button type="button" class="btn">
|
||||
<button type="button" class="btn" onclick="goReset();">
|
||||
<span class="btn-txt">초기화</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary">
|
||||
<button type="button" class="btn btn-primary" onclick="getResearchers(0);">
|
||||
<span class="btn-txt">검색</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -75,6 +74,7 @@
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<p class="input-label" style="font-size: 16px;">총 <span id="researcherTotal">0</span>건</p>
|
||||
<!-- 테이블 영역 -->
|
||||
<table>
|
||||
<thead>
|
||||
@@ -88,46 +88,8 @@
|
||||
<th>담당임가 수</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="listTBody">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<label class="radio-inner">
|
||||
<input type="radio" id="temp_radio_0001" name="temp_radio_0001">
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>홍길동</td>
|
||||
<td>010-0000-0000</td>
|
||||
<td>서울</td>
|
||||
<td>40</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<label class="radio-inner">
|
||||
<input type="radio" id="temp_radio_0002" name="temp_radio_0002">
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>홍길동</td>
|
||||
<td>010-0000-0000</td>
|
||||
<td>서울</td>
|
||||
<td>40</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<label class="radio-inner">
|
||||
<input type="radio" id="temp_radio_0003" name="temp_radio_0003">
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>홍길동</td>
|
||||
<td>010-0000-0000</td>
|
||||
<td>서울</td>
|
||||
<td>40</td>
|
||||
</tr>
|
||||
<tbody id="researcherListTbody">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -136,7 +98,7 @@
|
||||
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary">
|
||||
<button type="button" class="btn btn-primary" onclick="setResearcher();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -151,6 +113,8 @@
|
||||
</form>
|
||||
|
||||
<script th:inline="javascript">
|
||||
let researcherList = [];
|
||||
|
||||
const showResearcherModal = () => {
|
||||
document.querySelector(".modal01").ui.open();
|
||||
|
||||
@@ -160,7 +124,7 @@
|
||||
{},
|
||||
(response) => {
|
||||
const select = document.getElementById('regionMainCodeSelect');
|
||||
|
||||
select.innerHTML = '<option value="" selected>전체</option>';
|
||||
response.forEach(item => {
|
||||
const option = document.createElement('option');
|
||||
option.value = item.id;
|
||||
@@ -174,8 +138,11 @@
|
||||
'get',
|
||||
'json'
|
||||
);
|
||||
|
||||
getResearchers(document.reqResearcherForm.page.value);
|
||||
}
|
||||
|
||||
// 조사원 리스트 가져오기
|
||||
const getResearchers = (pageNo) => {
|
||||
const f = document.reqResearcherForm;
|
||||
f.page.value = pageNo;
|
||||
@@ -183,31 +150,33 @@
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/mapping/researchers',
|
||||
'/api/popupResearchers',
|
||||
dataOj,
|
||||
function (response) {
|
||||
$('#totalElements').text(response.totalElements);
|
||||
$('#researcherTotal').text(response.totalElements);
|
||||
|
||||
researcherList = response.content;
|
||||
|
||||
// List 구성하기
|
||||
const tbody = $('#listTBody');
|
||||
const tbody = $('#researcherListTbody');
|
||||
tbody.empty();
|
||||
|
||||
$(response.content).each((idx, ct) => {
|
||||
tbody.append(
|
||||
`
|
||||
<!-- <tr>-->
|
||||
<!-- <td>-->
|
||||
<!-- <div class="component-input">-->
|
||||
<!-- <label class="radio-inner">-->
|
||||
<!-- <input type="radio" id="temp_radio_0003" name="temp_radio_0003">-->
|
||||
<!-- </label>-->
|
||||
<!-- </div>-->
|
||||
<!-- </td>-->
|
||||
<!-- <td>홍길동</td>-->
|
||||
<!-- <td>010-0000-0000</td>-->
|
||||
<!-- <td>서울</td>-->
|
||||
<!-- <td>40</td>-->
|
||||
<!-- </tr>-->
|
||||
<tr>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<label class="radio-inner">
|
||||
<input type="radio" id="temp_radio_000${ct.adminSeq}" name="adminSeq" value="${ct.adminSeq}">
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>${ct.name}</td>
|
||||
<td>${ifNullHyphen(ct.phone)}</td>
|
||||
<td>${ct.regionMainName}</td>
|
||||
<td>${ct.householdCount}</td>
|
||||
</tr>
|
||||
`
|
||||
);
|
||||
});
|
||||
@@ -227,7 +196,7 @@
|
||||
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
|
||||
(movePageNo) => {
|
||||
f.page.value = movePageNo;
|
||||
goSearch();
|
||||
getResearchers();
|
||||
}));
|
||||
|
||||
},
|
||||
@@ -240,5 +209,37 @@
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const setResearcher = () => {
|
||||
const selectedAdminSeq = $('input[name="adminSeq"]:checked').val();
|
||||
|
||||
if (!selectedAdminSeq) {
|
||||
alert("조사원을 선택해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedResearcher = researcherList.find(r => r.adminSeq == selectedAdminSeq);
|
||||
|
||||
console.log("선택된 조사원 : ", selectedResearcher);
|
||||
|
||||
// import 해준 html 에서 아래 함수를 선언해주면 selectedResearcher 값을 사용할 수 있음.
|
||||
getSelectedResearcher(selectedResearcher, () => {
|
||||
document.querySelector(".modal01").ui.close();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const goReset = () => {
|
||||
const f = document.reqResearcherForm;
|
||||
|
||||
f.searchField.value = "";
|
||||
f.searchValue.value = "";
|
||||
f.regionMainCode.value = "";
|
||||
|
||||
getResearchers(0);
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,182 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<form autocomplete="off"
|
||||
th:action="@{/communication/notices/create}"
|
||||
method="post" class="fw-bold" name="reqForm">
|
||||
<div class="content-inner">
|
||||
<!-- 테이블 영역 -->
|
||||
<table class="type-form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>제목<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td colspan="3">
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="text" name="title" id="title" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>내용<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td colspan="3">
|
||||
<textarea class="form-control" id="noticeContent" rows="10" name="content"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>첨부파일<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td colspan="3">
|
||||
<div class="btns-row align-left publicFileInputs">
|
||||
<button type="button" class="btn btn-secondary" onclick="addFileInput();">
|
||||
<span class="btn-txt">다건 파일 첨부</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>게시기간<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td colspan="2">
|
||||
<div class="d-flex">
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="boardStartDate" class="form-control flatpickr" name="startDate" type="text" placeholder="시작일을 선택하세요"/>
|
||||
</div>
|
||||
</div>-
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="boardEndDate" class="form-control flatpickr" name="endDate" type="text" placeholder="종료일을 선택하세요"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>노출여부<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td>
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="visible" id="open">
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-secondary" onclick="location.href='/household/households'">
|
||||
<span class="btn-txt">취소</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script src="/static/library/tinymce/6.0.3/tinymce.min.js" referrerpolicy="origin"></script>
|
||||
<script src="/static/ui/editorImageUpload.js"></script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
initEditor('#noticeContent');
|
||||
$(".flatpickr").flatpickr({
|
||||
dateFormat: "Y-m-d\\TH:i",
|
||||
// altInput: true,
|
||||
// altFormat: "Y-m-d H:i",
|
||||
monthSelectorType: 'static',
|
||||
enableTime: true,
|
||||
time_24hr: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
|
||||
function addFileInput() {
|
||||
$('.publicFileInputs').append(`
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
||||
onchange="uiUtil.uploadFile('NOTICE', this);">
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
|
||||
const goSave = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
|
||||
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
|
||||
f.content.value = uiUtil.unescapeHtml(tinymce.get('noticeContent').getContent());
|
||||
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
if(obj.fileMappingId) {
|
||||
if (!Array.isArray(obj.fileMappingId)) {
|
||||
obj.fileMappingId = [obj.fileMappingId];
|
||||
}
|
||||
}
|
||||
const csrfToken = $('meta[name="_csrf"]').attr('content');
|
||||
const csrfHeader = $('meta[name="_csrf_header"]').attr('content');
|
||||
$.ajax({
|
||||
'method': 'POST',
|
||||
'url': '/api/communication/notices/create',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(obj),
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader(csrfHeader, csrfToken);
|
||||
},
|
||||
// 'data': obj,
|
||||
success: (res) => {
|
||||
alert(`'${f.title.value}' 게시물이 생성되었습니다.\n이전 화면으로 이동합니다.`);
|
||||
history.back();
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (res) {
|
||||
const resJson = res.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (res) {
|
||||
alert("error");
|
||||
// $(res.responseJSON).each((idx, oj) => {
|
||||
// let target = $(f).find('[name=' + oj.field + ']');
|
||||
// target.addClass('is-invalid');
|
||||
//
|
||||
// target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
||||
// });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,237 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<form autocomplete="off" method="get" name="reqForm" th:action="@{/communication/notices}"
|
||||
th:object="${reqVO}">
|
||||
|
||||
<input name="page" th:field="*{page}" type="hidden"/>
|
||||
<input name="size" th:field="*{size}" type="hidden"/>
|
||||
|
||||
<input name="userRole" th:value="${userRole}" type="hidden"/>
|
||||
<input name="userRegionMainCode" th:value="${userRegionMainCode}" type="hidden"/>
|
||||
|
||||
<div class="content-inner">
|
||||
<!-- 필터 영역 -->
|
||||
<section class="filter-wrap">
|
||||
<div class="form-area">
|
||||
<!-- 검색필드 -->
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt">
|
||||
검색필드
|
||||
</p>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" th:field="*{searchField}" id="searchField">
|
||||
<option value="all" selected>전체</option>
|
||||
<option value="title">제목</option>
|
||||
<option value="updatedBy">작성자</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt">
|
||||
검색필드
|
||||
</p>
|
||||
</div>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="text" id="searchValue" th:field="*{searchValue}" placeholder="검색어를 입력하세요.">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt">
|
||||
검색필드
|
||||
</p>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" th:field="*{searchOpen}" id="searchOpen">
|
||||
<option value="" selected>전체</option>
|
||||
<option value="true">Y</option>
|
||||
<option value="false">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 버튼 그룹 -->
|
||||
<div class="component-btns">
|
||||
<div class="btns-row">
|
||||
<button type="button" class="btn" onclick="location.href = location.pathname">
|
||||
<span class="btn-txt">초기화</span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<span class="btn-txt">검색</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<p class="input-label" style="font-size: 16px;">총 <span id="totalElements">0</span>건</p>
|
||||
<!-- 테이블 영역 -->
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:50px">
|
||||
<div class="component-input">
|
||||
<label class="checkbox-inner">
|
||||
<input type="checkbox" id="temp_checkbox_0003" name="temp_checkbox_0001">
|
||||
</label>
|
||||
</div>
|
||||
</th>
|
||||
<th>제목</th>
|
||||
<th style="width:120px">게시일</th>
|
||||
<th>게시기간</th>
|
||||
<th style="width:80px">노출<br>여부</th>
|
||||
<th style="width:250px">최종수정자</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="listTBody">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 페이지네이션 -->
|
||||
<div class="row paging"></div>
|
||||
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<!-- 관리자만 노출 -->
|
||||
<button type="button" class="btn btn-danger" th:if="${userRole == 'ROLE_ADMIN'}" onclick="goRemove()">
|
||||
<span class="btn-txt">삭제 </span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn" th:if="${userRole == 'ROLE_ADMIN'}"
|
||||
onclick="location.href='/communication/notices/create'">
|
||||
<span class="btn-txt">등록 </span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
// 임가 목록 조회
|
||||
const getHouseholds = (pageNo) => {
|
||||
const f = document.reqForm;
|
||||
f.page.value = pageNo;
|
||||
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/communication/notices',
|
||||
dataOj,
|
||||
function(response) { // 성공
|
||||
console.log("response", response);
|
||||
|
||||
$('#totalElements').text(response.totalElements);
|
||||
|
||||
const tbody = $('#listTBody');
|
||||
tbody.empty();
|
||||
|
||||
$(response.content).each((idx, ct) => {
|
||||
tbody.append(
|
||||
`
|
||||
<tr>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<label class="checkbox-inner">
|
||||
<input type="checkbox" name="selectIds" value="${ct.id}">
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="underline"><a href="/communication/notices/${ct.id}">${ct.title}</a></td>
|
||||
<td>${uiUtil.isoStrToDateOnly(ct.createdAt)}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.startDate)} ~ ${uiUtil.isoStrToReadable(ct.endDate)}</td>
|
||||
<td>${ct.visible ? 'Y' : 'N'}</td>
|
||||
<td>${ct.updatedBy}(${uiUtil.isoStrToReadable(ct.updatedAt)})</td>
|
||||
|
||||
</tr>
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
// nodata 처리
|
||||
if (!$(response.content).length) {
|
||||
tbody.append(`
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted">공지사항이 존재하지 않습니다.</td>
|
||||
</tr>
|
||||
`);
|
||||
}
|
||||
|
||||
// Pagination 구성하기
|
||||
const paging = $('.paging');
|
||||
paging.empty();
|
||||
paging.append(
|
||||
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
|
||||
(movePageNo) => {
|
||||
f.page.value = movePageNo;
|
||||
goSearch();
|
||||
}));
|
||||
},
|
||||
function (code, rstData) { // 실패
|
||||
console.log("error : ", code);
|
||||
},
|
||||
'get',
|
||||
'json'
|
||||
);
|
||||
}
|
||||
|
||||
// 최초 리스트 로드
|
||||
getHouseholds(document.reqForm.page.value);
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
const goSearch = () => {
|
||||
const f = document.reqForm;
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
function goRemove() {
|
||||
if (!$('input[name=selectIds]').is(':checked')) {
|
||||
alert(/*[[#{operation.common.remove.choose}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
||||
const f = document.reqForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'DELETE',
|
||||
'url': '/api/communication/notices/remove',
|
||||
'data': {
|
||||
'selectIds': data.selectIds
|
||||
},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res){
|
||||
alert('선택한 아이템이 삭제되었습니다.');
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user