package org.dromara.system.sync;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.dromara.common.oss.core.OssClient;
|
import org.dromara.common.oss.factory.OssFactory;
|
import org.dromara.system.domain.SysOss;
|
import org.dromara.system.domain.properties.Boundary;
|
import org.dromara.system.domain.vo.SysOssVo;
|
import org.dromara.system.mapper.SysOssMapper;
|
import org.dromara.system.service.ISysOssService;
|
import org.dromara.system.uitil.HttpUtils;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import java.io.IOException;
|
import java.time.LocalDateTime;
|
import java.util.List;
|
import java.util.Objects;
|
|
@Slf4j
|
@Component
|
public class deleteSync {
|
|
private final ISysOssService ossService;
|
private final SysOssMapper ossMapper;
|
private final Boundary boundary;
|
|
public deleteSync(ISysOssService ossService, SysOssMapper ossMapper, Boundary boundary) {
|
this.ossService = ossService;
|
this.ossMapper = ossMapper;
|
this.boundary = boundary;
|
}
|
|
// @Scheduled(cron = "0 */10 * * * ?")
|
// public void remove() throws IOException {
|
// System.out.println("同步删除......");
|
// List<Long> ids = baseMapper.getWillDeleted(LocalDateTime.now().minusDays(1));
|
//
|
// if (ids.size() == 0) {
|
// return;
|
// }
|
// for (Long ossId : ids) {
|
// baseMapper.deleteById(ossId);
|
// HttpUtils.sendDeleteRequest(boundary.getVideo() + "/resource/synchronization/delete",
|
// String.valueOf(ossId));
|
// }
|
// }
|
|
@Scheduled(cron = "0 */10 * * * ?")
|
public void remove() throws IOException {
|
System.out.println("self delete......");
|
List<Long> ids = ossMapper.getWillDeleted(LocalDateTime.now().minusDays(1));
|
if (ids.size() == 0) {
|
return;
|
}
|
ossService.deleteByIds(ids);
|
}
|
}
|