Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	front/src/main/java/app/module/front/usecase/daily/expense/adapters/persistence/DailyExpenseDao.java
#	front/src/main/java/app/module/front/usecase/daily/expense/adapters/persistence/DailyExpenseMapper.java
#	front/src/main/java/app/module/front/usecase/daily/income/adapters/persistence/DailyIncomeDao.java
This commit is contained in:
김현주
2025-07-08 17:40:11 +09:00
71 changed files with 11064 additions and 70 deletions

View File

@@ -1,6 +1,9 @@
package app.module.core.config.application.util;
import app.module.core.usecase.file.getFile.adapters.persistence.GetFileMapper;
import app.module.core.usecase.file.getFile.ports.application.domain.GetFile;
import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector;
import app.module.core.usecase.file.updateFile.adapters.persistence.UpdateFileMapper;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSchException;
@@ -18,6 +21,8 @@ import java.nio.file.Paths;
public class SftpFileDeleteUtil {
private final SftpConnector sftpConnector;
private final GetFileMapper getFileMapper;
private final UpdateFileMapper updateFileMapper;
@Value("${path.upload.sftp.public}")
private String publicPath;
@@ -64,6 +69,47 @@ public class SftpFileDeleteUtil {
}
}
public void deleteRealFile(Long deleteFileId) throws JSchException, SftpException {
GetFile deleteFile = getFileMapper.findById(deleteFileId).orElseThrow();
updateFileMapper.deleteReceiptFile(deleteFileId,CommonUtil.getLoginUsername());
if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) {
log.error("Invalid file information: {}", deleteFile);
throw new IllegalArgumentException("Invalid file information");
}
// 경로 검증 및 생성
String filePath = constructSafeFilePath(deleteFile.getPath(), deleteFile.getName());
log.info("Attempting to delete file from SFTP: {}", filePath);
// SFTP 연결 확인 및 재연결
if (!sftpConnector.isConnected()) {
log.warn("SFTP connection lost, attempting to reconnect");
sftpConnector.connect();
}
ChannelSftp channelSftp = sftpConnector.getChannelSftp();
if (channelSftp == null) {
log.error("SFTP channel is not initialized");
throw new SftpException(ChannelSftp.SSH_FX_NO_CONNECTION, "SFTP channel is not initialized");
}
// 파일 삭제
try {
channelSftp.stat(filePath); // 파일 존재 여부 확인
channelSftp.rm(filePath);
log.info("File deleted successfully from SFTP: {}", filePath);
} catch (SftpException e) {
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
log.warn("File does not exist on SFTP: {}", filePath);
} else {
log.error("Failed to delete file from SFTP: {}, error: {}", filePath, e.getMessage(), e);
throw e;
}
}
}
/**
* 경로 조작 방지를 위해 안전한 파일 경로 생성
*/

View File

@@ -3,6 +3,7 @@ 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 org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -10,5 +11,6 @@ import java.util.List;
public interface UpdateFileMapper {
List<UploadFileDto> findDeleteFileList(UpdateUploadFileParam uploadFile);
void deleteFile(UpdateUploadFileParam uploadFile);
void deleteReceiptFile(@Param("fileId") Long fileId,@Param("deletedUserId") String deletedUserId);
void updateFile(UploadFileDto uploadFile);
}

View File

@@ -16,7 +16,7 @@
type,
file_length,
ocr,
daily_record_seq,
mapping_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
) VALUES(
#{id},

View File

@@ -36,6 +36,15 @@
</if>
</update>
<update id="deleteReceiptFile">
UPDATE upload_file
SET deleted_by = #{deletedUserId},
deleted_at = now(),
is_deleted = true
WHERE is_deleted = false
and id = #{fileId}
</update>
<update id="updateFile" >
UPDATE upload_file
SET mapping_id = #{mappingId},

View File

@@ -1904,4 +1904,26 @@ COMMENT ON COLUMN address.updated_at IS '수정일';
COMMENT ON COLUMN address.updated_by IS '수정자';
COMMENT ON COLUMN address.deleted_at IS '삭제일';
COMMENT ON COLUMN address.deleted_by IS '삭제자';
COMMENT ON COLUMN address.is_deleted IS '삭제여부';
COMMENT ON COLUMN address.is_deleted IS '삭제여부';
-- ============================================
-- TABLE : sms_auto_send
-- DESC : 문자 자동 발송 활성화 테이블
-- ============================================
CREATE TABLE sms_auto_status (
active boolean NOT null,
message text,
send_phone varchar(255),
updated_at timestamp(6),
updated_by varchar(255)
);
COMMENT ON TABLE sms_auto_status IS '문자 자동 발송 활성화 테이블';
COMMENT ON COLUMN sms_auto_status.active IS '자동 발송 기능 ON/OFF 여부';
COMMENT ON COLUMN sms_auto_status.message IS '메세지';
COMMENT ON COLUMN sms_auto_status.send_phone IS '발송번호';
COMMENT ON COLUMN sms_auto_status.updated_at IS '수정일';
COMMENT ON COLUMN sms_auto_status.updated_by IS '수정자';