게시글 정보가 없는 파일 삭제 스케쥴러 생성
This commit is contained in:
parent
fde1520377
commit
f8ebcbd1be
@ -124,6 +124,10 @@ public interface localbordMapper {
|
|||||||
|
|
||||||
void deleteGoodOrBadByBoardId(MapDto map);
|
void deleteGoodOrBadByBoardId(MapDto map);
|
||||||
|
|
||||||
|
List<FileVo> selectFilesBoardIndexIsNull();
|
||||||
|
|
||||||
|
int deleteTrashFileData(FileVo vo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -497,8 +498,49 @@ public class localbordService {
|
|||||||
return ApiResponse.ok(resultMap);
|
return ApiResponse.ok(resultMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 에디터 업로드 이미지 게시글 번호 업데이트
|
||||||
|
*
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public int insertUploadEditorImageInfo(MapDto map) {
|
public int insertUploadEditorImageInfo(MapDto map) {
|
||||||
return boardMapper.insertUploadEditorImageInfo(map);
|
return boardMapper.insertUploadEditorImageInfo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 게시글 정보가 없는 파일 조회
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<FileVo> selectFilesBoardIndexIsNull() {
|
||||||
|
return boardMapper.selectFilesBoardIndexIsNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 파일 data 제거
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int deleteTrashFileData(FileVo vo) {
|
||||||
|
return boardMapper.deleteTrashFileData(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Garbage File Collector
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 2 * * *", zone = "Asia/Seoul")
|
||||||
|
public void deleteTrashFiles() {
|
||||||
|
List<FileVo> list = this.selectFilesBoardIndexIsNull();
|
||||||
|
|
||||||
|
for(FileVo file : list) {
|
||||||
|
String fileName = file.getCMNFLENAM();
|
||||||
|
if(!fileName.contains(file.getCMNFLEEXT())) fileName = fileName + file.getCMNFLEEXT();
|
||||||
|
|
||||||
|
boolean deleteResult = fileService.removeBoardFile(fileName);
|
||||||
|
if(deleteResult) this.deleteTrashFileData(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -414,4 +414,30 @@
|
|||||||
MEMBERSEQ = ${userId}
|
MEMBERSEQ = ${userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 게시글 정보가 없는 파일 조회-->
|
||||||
|
<select id="selectFilesBoardIndexIsNull" resultType="io.company.localhost.vo.FileVo">
|
||||||
|
SELECT
|
||||||
|
CMNFLESEQ,
|
||||||
|
CMNBRDSEQ,
|
||||||
|
CMNFLENAM,
|
||||||
|
CMNFLEORG,
|
||||||
|
CMNFLEPAT,
|
||||||
|
CMNFLEEXT,
|
||||||
|
CMNFLESIZ,
|
||||||
|
CMNFLETYP
|
||||||
|
FROM
|
||||||
|
COMMONFIL
|
||||||
|
WHERE
|
||||||
|
CMNBRDSEQ IS NULL
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 파일 데이터 삭제 -->
|
||||||
|
<delete id="deleteTrashFileData">
|
||||||
|
DELETE FROM
|
||||||
|
COMMONFIL
|
||||||
|
WHERE
|
||||||
|
CMNFLESEQ = #{CMNFLESEQ}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user