Merge branch 'dev' into 0623_fetch
This commit is contained in:
@@ -27,6 +27,8 @@ public class AuditCommand {
|
||||
public void update() {
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = getCurrentUsername();
|
||||
this.deletedAt = LocalDateTime.now();
|
||||
this.deletedBy = getCurrentUsername();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
@@ -10,4 +10,9 @@ public enum FileStorageType {
|
||||
S3("AWS S3 스토리지"),
|
||||
SFTP("SFTP");
|
||||
private final String desc;
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ import lombok.RequiredArgsConstructor;
|
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||
public enum FileUploadType {
|
||||
// URI og:image 용 이미지 파일
|
||||
OG_IMAGE(FileStorageType.LOCAL, "/ogImage", Set.of(AcceptableFileType.IMAGE)),
|
||||
OG_IMAGE(Set.of(FileStorageType.LOCAL), "/ogImage", Set.of(AcceptableFileType.IMAGE)),
|
||||
// WEB Editor 이미지 파일
|
||||
EDITOR_IMAGE(FileStorageType.LOCAL, "/editorImage", Set.of(AcceptableFileType.IMAGE)),
|
||||
EDITOR_IMAGE(Set.of(FileStorageType.SFTP,FileStorageType.LOCAL), "/editorImage", Set.of(AcceptableFileType.IMAGE)),
|
||||
|
||||
PUBLIC(
|
||||
FileStorageType.LOCAL,
|
||||
Set.of(FileStorageType.LOCAL),
|
||||
"/common",
|
||||
Set.of(
|
||||
AcceptableFileType.IMAGE,
|
||||
@@ -28,7 +28,7 @@ public enum FileUploadType {
|
||||
AcceptableFileType.PDF,
|
||||
AcceptableFileType.ZIP)),
|
||||
PRIVATE(
|
||||
FileStorageType.LOCAL,
|
||||
Set.of(FileStorageType.LOCAL),
|
||||
"/private",
|
||||
Set.of(
|
||||
AcceptableFileType.IMAGE,
|
||||
@@ -41,7 +41,10 @@ public enum FileUploadType {
|
||||
AcceptableFileType.PDF,
|
||||
AcceptableFileType.ZIP)),
|
||||
NOTICE(
|
||||
FileStorageType.SFTP,
|
||||
Set.of(
|
||||
FileStorageType.SFTP,
|
||||
FileStorageType.LOCAL
|
||||
),
|
||||
"/notice",
|
||||
Set.of(
|
||||
AcceptableFileType.IMAGE,
|
||||
@@ -55,15 +58,15 @@ public enum FileUploadType {
|
||||
AcceptableFileType.ZIP)),
|
||||
|
||||
RECEIPT(
|
||||
FileStorageType.SFTP,
|
||||
"/receipt",
|
||||
Set.of(FileStorageType.SFTP,FileStorageType.LOCAL),
|
||||
"/receipt",
|
||||
Set.of(
|
||||
AcceptableFileType.IMAGE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
private final FileStorageType fileStorageType;
|
||||
private final Set<FileStorageType> fileStorageType;
|
||||
private final String subPath;
|
||||
private final Set<AcceptableFileType> acceptableFileTypes;
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package app.module.core.config.application.util;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
@@ -10,6 +13,7 @@ import java.util.Locale;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class DailyUtil {
|
||||
|
||||
/**
|
||||
@@ -103,4 +107,25 @@ public class DailyUtil {
|
||||
|
||||
return (limitStart.isBefore(startDate) || limitStart.isEqual(startDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자형 타입의 숫자에 콤마 적용
|
||||
*
|
||||
* @param value 입력 데이터
|
||||
* @return 숫자(콤마, 도트)
|
||||
*/
|
||||
public String getStringComma(String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
String[] values = value.split("\\.");
|
||||
if (values.length > 1) {
|
||||
Double input = Double.parseDouble(values[0]);
|
||||
|
||||
return new DecimalFormat("###,###").format(input) + "." + values[1];
|
||||
}
|
||||
|
||||
return new DecimalFormat("###,###").format(Double.parseDouble(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package app.module.core.config.application.util;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.UploadFile;
|
||||
import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector;
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
@@ -28,7 +28,7 @@ public class SftpFileDeleteUtil {
|
||||
* @throws JSchException SFTP 연결 오류
|
||||
* @throws SftpException SFTP 작업 오류
|
||||
*/
|
||||
public void deleteRealFile(UploadFile deleteFile) throws JSchException, SftpException {
|
||||
public void deleteRealFile(UploadFileDto deleteFile) throws JSchException, SftpException {
|
||||
if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) {
|
||||
log.error("Invalid file information: {}", deleteFile);
|
||||
throw new IllegalArgumentException("Invalid file information");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.core.usecase.article.getArticle.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.enums.FileStorageType;
|
||||
import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
|
||||
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||
@@ -9,6 +10,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -19,6 +21,9 @@ class GetArticleDao implements GetArticlePortOut {
|
||||
private final GetArticleMapper mapper;
|
||||
private final FileUrlPortIn fileUrlPortIn;
|
||||
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Optional<GetArticle> operate(GetArticleCmd command) {
|
||||
@@ -34,13 +39,13 @@ class GetArticleDao implements GetArticlePortOut {
|
||||
// 참조 URL 전달
|
||||
uploadFile.setReferURL(
|
||||
fileUrlPortIn.getInline(
|
||||
uploadFile.getType().getFileStorageType(),
|
||||
FileStorageType.valueOf(uploadStorageType),
|
||||
uploadFile.getPath(),
|
||||
uploadFile.getName()));
|
||||
// attachment URL 전달
|
||||
uploadFile.setAttachmentURL(
|
||||
fileUrlPortIn.getAttachment(
|
||||
uploadFile.getType().getFileStorageType(), uploadFile.getId()));
|
||||
FileStorageType.valueOf(uploadStorageType), uploadFile.getId()));
|
||||
|
||||
return uploadFile;
|
||||
})
|
||||
|
||||
@@ -77,6 +77,7 @@ public class DailyRecordDao implements DailyRecordPortOut {
|
||||
);
|
||||
|
||||
if ("ALL".equals(targetType)) {
|
||||
// 전체 입력상태 변경
|
||||
String allStatus = this.getUpdateAllStatus(recordMonth, dayGroupNo, householdSeq);
|
||||
if (allStatus != null) {
|
||||
command.setAllStatus(allStatus);
|
||||
@@ -88,7 +89,11 @@ public class DailyRecordDao implements DailyRecordPortOut {
|
||||
}
|
||||
|
||||
} else {
|
||||
// 항목 입력상태 변경
|
||||
dailyRecordMapper.updateDailyRecordStatus(command);
|
||||
|
||||
// 전체 입력상태 변경
|
||||
this.updateByAllStatus(command.getRecordMonth(), command.getDayGroupNo(), command.getHouseholdSeq());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,10 @@ public interface DailyRecordPortIn {
|
||||
/**
|
||||
* 일계부 항목 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 항목 상세
|
||||
* @param recordMonth
|
||||
* @param dayGroupNo
|
||||
* @param householdSeq
|
||||
* @return 항목 상세
|
||||
*/
|
||||
DailyRecordDto detail(String recordMonth, Integer dayGroupNo, Long householdSeq);
|
||||
|
||||
|
||||
@@ -15,7 +15,16 @@ public class UpdateDailyRecordStatusCmd extends AuditCommand {
|
||||
private Integer dayGroupNo;
|
||||
private Long householdSeq;
|
||||
|
||||
/**
|
||||
* 전체 입력상태
|
||||
*/
|
||||
private String allStatus;
|
||||
/**
|
||||
* 변경 대상
|
||||
*/
|
||||
private String targetType;
|
||||
/**
|
||||
* 변경 대상 입력상태
|
||||
*/
|
||||
private String targetStatus;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package app.module.core.usecase.file.createFile.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.UploadFile;
|
||||
import app.module.core.config.application.enums.FileStorageType;
|
||||
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
|
||||
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@@ -15,6 +17,10 @@ class CreateFileDao implements CreateFilePortOut {
|
||||
private final CreateFileMapper mapper;
|
||||
private final FileUrlPortIn fileUrlPortIn;
|
||||
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<CreateFile> operate(CreateFileCmd command) {
|
||||
UploadFile uploadFile = new UploadFile(
|
||||
@@ -23,7 +29,7 @@ class CreateFileDao implements CreateFilePortOut {
|
||||
command.getPath(),
|
||||
command.getName(),
|
||||
command.getOriginName(),
|
||||
command.getFileLength());
|
||||
command.getFileLength() );
|
||||
|
||||
mapper.insertFile(uploadFile);
|
||||
|
||||
@@ -37,11 +43,11 @@ class CreateFileDao implements CreateFilePortOut {
|
||||
uploadFile.getFileLength(),
|
||||
// 참조 URL 전달
|
||||
fileUrlPortIn.getInline(
|
||||
uploadFile.getType().getFileStorageType(),
|
||||
FileStorageType.valueOf(uploadStorageType),
|
||||
uploadFile.getPath(),
|
||||
uploadFile.getName()),
|
||||
// attachment URL 전달
|
||||
fileUrlPortIn.getAttachment(
|
||||
uploadFile.getType().getFileStorageType(), uploadFile.getId())));
|
||||
FileStorageType.valueOf(uploadStorageType), uploadFile.getId())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.tika.Tika;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -30,6 +31,8 @@ public class SaveToStorageService implements SaveToStoragePortIn {
|
||||
private final MessageUtil messageUtil;
|
||||
private final Tika tika;
|
||||
private final Set<FileUploadStrategy> fileUploadStrategies;
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
@Override
|
||||
public Optional<SaveToStorage> operate(FileUploadType fileUploadType,
|
||||
@@ -45,7 +48,7 @@ public class SaveToStorageService implements SaveToStoragePortIn {
|
||||
String subPath = getDirPath(fileUploadType.getSubPath());
|
||||
String createFilename = getUUIDFilename(getFileExtension(originalFilename).orElse(null));
|
||||
|
||||
getFileUploadStrategy(fileUploadType.getFileStorageType())
|
||||
getFileUploadStrategy(FileStorageType.valueOf(uploadStorageType))
|
||||
.operate(multipartFile, subPath, createFilename);
|
||||
|
||||
return Optional.of(
|
||||
@@ -128,6 +131,6 @@ public class SaveToStorageService implements SaveToStoragePortIn {
|
||||
() ->
|
||||
new NoSuchElementException(
|
||||
String.format("No file upload strategy found: %s",
|
||||
fileStorageType.name())));
|
||||
fileStorageType.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package app.module.core.usecase.file.updateFile.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.UploadFile;
|
||||
import app.module.core.config.application.annotation.DeleteCommand;
|
||||
import app.module.core.config.application.annotation.UpdateCommand;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.config.application.util.SftpFileDeleteUtil;
|
||||
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
|
||||
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortOut;
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
|
||||
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class UpdateFileDao implements UpdateFilePortOut {
|
||||
private final UpdateFileMapper mapper;
|
||||
private final SftpFileDeleteUtil sftpFileDeleteUtil;
|
||||
|
||||
@Override
|
||||
@DeleteCommand
|
||||
public void operate(UpdateFileCmd command) {
|
||||
|
||||
List<UploadFileDto> deletedFileList = mapper.findDeleteFileList(new UpdateUploadFileParam(
|
||||
command.getId(),
|
||||
command.getFileMappingIds(),
|
||||
command.getType().getName()
|
||||
));
|
||||
|
||||
for (UploadFileDto file : deletedFileList) {
|
||||
try {
|
||||
sftpFileDeleteUtil.deleteRealFile(file);
|
||||
} catch (JSchException | SftpException e) {
|
||||
log.error("Failed to delete file from SFTP for mapping ID {}: {}", file.getId(), e.getMessage(), e);
|
||||
throw new RuntimeException("Failed to delete file from SFTP", e);
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error while deleting file for mapping ID {}: {}", file.getId(), e.getMessage(), e);
|
||||
throw new RuntimeException("Unexpected error while deleting file", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!deletedFileList.isEmpty()) {
|
||||
mapper.deleteFile(
|
||||
new UpdateUploadFileParam(
|
||||
command.getId(),
|
||||
deletedFileList.stream().map(UploadFileDto::getId).toList(),
|
||||
command.getType().getName()));
|
||||
}
|
||||
|
||||
command.getFileMappingIds().forEach(fileId -> mapper.updateFile(new UploadFileDto(fileId, command.getId(),command.getType().getName())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.core.usecase.file.updateFile.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UpdateFileMapper {
|
||||
List<UploadFileDto> findDeleteFileList(UpdateUploadFileParam uploadFile);
|
||||
void deleteFile(UpdateUploadFileParam uploadFile);
|
||||
void updateFile(UploadFileDto uploadFile);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.file.updateFile.ports;
|
||||
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
|
||||
|
||||
|
||||
public interface UpdateFilePortIn {
|
||||
void operate(UpdateFileCmd command);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.file.updateFile.ports;
|
||||
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
|
||||
|
||||
|
||||
public interface UpdateFilePortOut {
|
||||
void operate(UpdateFileCmd command);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.core.usecase.file.updateFile.ports.application;
|
||||
|
||||
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortIn;
|
||||
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortOut;
|
||||
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class UpdateFileService implements UpdateFilePortIn {
|
||||
|
||||
private final UpdateFilePortOut portOut;
|
||||
|
||||
@Override
|
||||
public void operate(UpdateFileCmd command) {
|
||||
portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.core.usecase.file.updateFile.ports.application.domain;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateFileCmd {
|
||||
private Long id;
|
||||
private List<Long> fileMappingIds;
|
||||
private FileUploadType type;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.core.usecase.file.updateFile.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class UpdateUploadFileParam extends AuditCommand {
|
||||
private Long id;
|
||||
private List<Long> fileMappingIds;
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package app.module.core.usecase.file.updateFile.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import app.module.core.config.adapters.persistence.component.AuditEntity;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UploadFileDto extends AuditCommand {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long mappingId;
|
||||
|
||||
private String type;
|
||||
|
||||
private String path;
|
||||
|
||||
private String name;
|
||||
|
||||
private String originName;
|
||||
|
||||
private Long fileLength;
|
||||
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
private String updatedBy;
|
||||
|
||||
public UploadFileDto(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public UploadFileDto(Long id, Long mappingId, String type) {
|
||||
this.id = id;
|
||||
this.mappingId = mappingId;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.core.usecase.getAttachment.adapters.web;
|
||||
|
||||
import app.module.core.config.application.enums.FileStorageType;
|
||||
import app.module.core.usecase.file.getFile.ports.GetFilePortIn;
|
||||
import app.module.core.usecase.file.getFile.ports.application.domain.GetFile;
|
||||
import app.module.core.usecase.file.getFile.ports.application.domain.GetFileCmd;
|
||||
@@ -27,6 +28,8 @@ class GetAttachmentController {
|
||||
private String cloudFrontDomain;
|
||||
@Value("${app.aws.s3.bucketFolder:null}")
|
||||
private String bucketFolder;
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
@GetMapping(path = "/content-disposition/attachment/{fileId}")
|
||||
ResponseEntity<?> operate(@PathVariable Long fileId) throws MalformedURLException {
|
||||
@@ -55,7 +58,7 @@ class GetAttachmentController {
|
||||
|
||||
UrlResource resource = null;
|
||||
|
||||
switch (getFile.getType().getFileStorageType()) {
|
||||
switch (FileStorageType.valueOf(uploadStorageType)) {
|
||||
case LOCAL:
|
||||
String filePath =
|
||||
Paths.get(publicPath, getFile.getPath(), getFile.getName())
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.core.usecase.loggedinuser.save.adapter.persistence;
|
||||
|
||||
import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortOut;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
|
||||
import app.module.core.config.adapters.persistence.entity.LoggedInUser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class LoggedInUserSaveDao implements LoggedInUserSavePortOut {
|
||||
|
||||
private final LoggedInUserSaveMapper mapper;
|
||||
|
||||
@Override
|
||||
public void connect(LoggedInUserSaveCmd saveCommand) {
|
||||
|
||||
LoggedInUser loggedInUser = new LoggedInUser(
|
||||
saveCommand.getLoggedInUserId().getAppType(),
|
||||
saveCommand.getLoggedInUserId().getId(),
|
||||
saveCommand.getClientIP(),
|
||||
saveCommand.getLastLoggedInAt()
|
||||
);
|
||||
|
||||
mapper.insert(loggedInUser);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.core.usecase.loggedinuser.save.adapter.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.LoggedInUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface LoggedInUserSaveMapper {
|
||||
void insert(LoggedInUser loggedInUser);
|
||||
void update(LoggedInUser loggedInUser);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.loggedinuser.save.ports;
|
||||
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
|
||||
|
||||
public interface LoggedInUserSavePortIn {
|
||||
|
||||
void connect(LoggedInUserSaveCmd loggedInUserSaveCmd);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.loggedinuser.save.ports;
|
||||
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
|
||||
|
||||
public interface LoggedInUserSavePortOut {
|
||||
|
||||
void connect(LoggedInUserSaveCmd loggedInUser);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.core.usecase.loggedinuser.save.ports.application;
|
||||
|
||||
import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortOut;
|
||||
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LoggedInUserSaveService implements LoggedInUserSavePortIn {
|
||||
|
||||
private final LoggedInUserSavePortOut portOut;
|
||||
|
||||
@Override
|
||||
public void connect(LoggedInUserSaveCmd loggedInUserSaveCmd) {
|
||||
portOut.connect(loggedInUserSaveCmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.core.usecase.loggedinuser.save.ports.application.domain;
|
||||
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoggedInUserIdSaveCmd {
|
||||
private AppType appType;
|
||||
private String id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.core.usecase.loggedinuser.save.ports.application.domain;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoggedInUserSaveCmd {
|
||||
private LoggedInUserIdSaveCmd loggedInUserId;
|
||||
private String clientIP;
|
||||
private LocalDateTime lastLoggedInAt;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.module.core.usecase.uicode.view.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.repository.UICodeRepo;
|
||||
import app.module.core.usecase.uicode.view.ports.UICodeViewPortOut;
|
||||
import app.module.core.usecase.uicode.view.ports.application.domain.UICodeView;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.core.usecase.uri.save.ports.application;
|
||||
|
||||
import app.module.core.config.application.enums.FileStorageType;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import app.module.core.config.application.exception.AlreadyExistItemException;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
@@ -11,6 +12,7 @@ import app.module.core.usecase.uri.save.ports.URISavePortIn;
|
||||
import app.module.core.usecase.uri.save.ports.URISavePortOut;
|
||||
import app.module.core.usecase.uri.save.ports.application.domain.URISaveCommand;
|
||||
import app.module.core.usecase.uri.view.ports.URIViewPortIn;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.io.IOException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -28,6 +30,8 @@ class URISaveService implements URISavePortIn {
|
||||
private final MessageUtil messageUtil;
|
||||
private final SaveToStoragePortIn saveToStoragePortIn;
|
||||
private final FileUrlPortIn fileUrlPortIn;
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
@Transactional
|
||||
@CacheEvict(
|
||||
@@ -59,7 +63,7 @@ class URISaveService implements URISavePortIn {
|
||||
|
||||
uri.setOgImage(
|
||||
fileUrlPortIn.getInline(
|
||||
ogImg.getType().getFileStorageType(), ogImg.getPath(), ogImg.getName()));
|
||||
FileStorageType.valueOf(uploadStorageType), ogImg.getPath(), ogImg.getName()));
|
||||
}
|
||||
|
||||
return uriSavePortOut.connect(uri);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.core.usecase.user.findUser.ports.application;
|
||||
|
||||
import app.module.core.config.application.enums.FileStorageType;
|
||||
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||
import app.module.core.usecase.user.findUser.ports.FindUserPortIn;
|
||||
import app.module.core.usecase.user.findUser.ports.FindUserPortOut;
|
||||
@@ -8,6 +9,7 @@ import app.module.core.usecase.user.findUser.ports.application.domain.FindUser;
|
||||
import app.module.core.usecase.user.findUser.ports.application.domain.FindUserCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -17,6 +19,9 @@ class FindUserService implements FindUserPortIn {
|
||||
private final FindUserPortOut portOut;
|
||||
private final FileUrlPortIn fileUrlPortIn;
|
||||
|
||||
@Value("${path.upload.storage}")
|
||||
private String uploadStorageType;
|
||||
|
||||
@Override
|
||||
public Optional<FindUser> operate(FindUserCmd command) {
|
||||
return portOut
|
||||
@@ -29,14 +34,14 @@ class FindUserService implements FindUserPortIn {
|
||||
// 참조 URL 전달
|
||||
profileImg.setReferURL(
|
||||
fileUrlPortIn.getInline(
|
||||
profileImg.getType().getFileStorageType(),
|
||||
FileStorageType.valueOf(uploadStorageType),
|
||||
profileImg.getPath(),
|
||||
profileImg.getName()));
|
||||
|
||||
// attachment URL 전달
|
||||
profileImg.setAttachmentURL(
|
||||
fileUrlPortIn.getAttachment(
|
||||
profileImg.getType().getFileStorageType(), profileImg.getId()));
|
||||
FileStorageType.valueOf(uploadStorageType), profileImg.getId()));
|
||||
}
|
||||
|
||||
return Optional.of(findUser);
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
, all_status = #{allStatus}
|
||||
</if>
|
||||
<if test="targetType != null and targetType != ''">
|
||||
/* TODO 개별 상태값 변경 */
|
||||
<choose>
|
||||
<when test="targetType eq 'INCOME'">
|
||||
, income_status = #{targetStatus}
|
||||
|
||||
47
core/src/main/resources/mappers/file/UpdateFileMapper.xml
Normal file
47
core/src/main/resources/mappers/file/UpdateFileMapper.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="app.module.core.usecase.file.updateFile.adapters.persistence.UpdateFileMapper">
|
||||
|
||||
<select id="findDeleteFileList" resultType="app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto">
|
||||
SELECT file_length,
|
||||
id,
|
||||
name,
|
||||
origin_name,
|
||||
path,
|
||||
type,
|
||||
mapping_id
|
||||
FROM upload_file
|
||||
WHERE type = #{type} and mapping_id = #{id} and is_deleted = false
|
||||
<if test="fileMappingIds != null and fileMappingIds.size() > 0">
|
||||
and id NOT IN (
|
||||
<foreach collection="fileMappingIds" item="fileId" separator="," >
|
||||
#{fileId}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="deleteFile">
|
||||
UPDATE upload_file
|
||||
SET
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
WHERE type = #{type} and mapping_id = #{id} and is_deleted = false
|
||||
<if test="fileMappingIds != null and fileMappingIds.size() > 0">
|
||||
and id IN (
|
||||
<foreach collection="fileMappingIds" item="fileId" separator="," >
|
||||
#{fileId}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<update id="updateFile" >
|
||||
UPDATE upload_file
|
||||
SET mapping_id = #{mappingId},
|
||||
type = #{type},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper
|
||||
namespace="app.module.core.usecase.loggedinuser.save.adapter.persistence.LoggedInUserSaveMapper">
|
||||
|
||||
<insert id="insert" parameterType="app.module.core.config.adapters.persistence.entity.LoggedInUser">
|
||||
INSERT INTO logged_in_user
|
||||
(
|
||||
id,
|
||||
app_type,
|
||||
login_id,
|
||||
clientip,
|
||||
last_logged_in_at
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
nextval('logged_in_user_seq'),
|
||||
#{appType},
|
||||
#{id},
|
||||
#{clientIP},
|
||||
#{lastLoggedInAt}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="app.module.core.config.adapters.persistence.entity.LoggedInUser">
|
||||
UPDATE logged_in_user
|
||||
SET
|
||||
clientip = #{clientIP},
|
||||
last_logged_in_at = #{lastLoggedInAt}
|
||||
WHERE app_type = #{appType}
|
||||
AND login_id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -83,7 +83,8 @@ COMMENT ON COLUMN role.is_deleted IS '삭제 여부';
|
||||
CREATE SEQUENCE upload_file_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
|
||||
|
||||
CREATE TABLE upload_file (
|
||||
id bigint DEFAULT nextval('upload_file_seq') NOT NULL, -- 파일 ID (PK)
|
||||
id int8 DEFAULT nextval('upload_file_seq') NOT NULL, -- 파일 ID (PK)
|
||||
mapping_id int8, -- 파일 매핑 ID
|
||||
name varchar(255), -- 시스템 저장 파일명
|
||||
origin_name varchar(255), -- 원본 파일명
|
||||
path varchar(255), -- 파일 경로
|
||||
@@ -115,6 +116,7 @@ CREATE TABLE upload_file (
|
||||
COMMENT ON TABLE upload_file IS '업로드 파일 정보 테이블';
|
||||
|
||||
COMMENT ON COLUMN upload_file.id IS '파일 ID (PK)';
|
||||
COMMENT ON COLUMN upload_file.mapping_id IS '파일 매핑 ID';
|
||||
COMMENT ON COLUMN upload_file.name IS '시스템 저장 파일명';
|
||||
COMMENT ON COLUMN upload_file.origin_name IS '원본 파일명';
|
||||
COMMENT ON COLUMN upload_file.path IS '파일 경로';
|
||||
@@ -1865,37 +1867,6 @@ COMMENT ON COLUMN notice.is_deleted IS '삭제여부';
|
||||
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- TABLE : notice_has_upload_file
|
||||
-- DESC : 공지사항 파일 매핑 테이블
|
||||
-- ============================================
|
||||
CREATE TABLE notice_has_upload_file (
|
||||
upload_files_id bigint NOT NULL, -- 업로드 파일 ID (FK)
|
||||
notice_id varchar(255) NOT NULL, -- 공지사항 ID (FK)
|
||||
created_at timestamp(6), -- 생성일
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일
|
||||
updated_by varchar(255), -- 수정자
|
||||
deleted_at timestamp(6), -- 삭제일
|
||||
deleted_by varchar(255), -- 삭제자
|
||||
is_deleted boolean DEFAULT false NOT NULL -- 삭제 여부
|
||||
);
|
||||
|
||||
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__notice FOREIGN KEY (notice_id) REFERENCES notice(id);
|
||||
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__upload_file FOREIGN KEY (upload_files_id) REFERENCES upload_file(id);
|
||||
|
||||
COMMENT ON TABLE notice_has_upload_file IS '공지사항 파일 매핑 테이블';
|
||||
|
||||
COMMENT ON COLUMN notice_has_upload_file.upload_files_id IS '업로드 파일 ID';
|
||||
COMMENT ON COLUMN notice_has_upload_file.notice_id IS '공지사항 ID';
|
||||
COMMENT ON COLUMN notice_has_upload_file.created_at IS '생성일';
|
||||
COMMENT ON COLUMN notice_has_upload_file.created_by IS '생성자';
|
||||
COMMENT ON COLUMN notice_has_upload_file.updated_at IS '수정일';
|
||||
COMMENT ON COLUMN notice_has_upload_file.updated_by IS '수정자';
|
||||
COMMENT ON COLUMN notice_has_upload_file.deleted_at IS '삭제일';
|
||||
COMMENT ON COLUMN notice_has_upload_file.deleted_by IS '삭제자';
|
||||
COMMENT ON COLUMN notice_has_upload_file.is_deleted IS '삭제여부';
|
||||
|
||||
|
||||
|
||||
-- ============================================
|
||||
|
||||
Reference in New Issue
Block a user