| | |
| | | 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; |
| | |
| | | @Component |
| | | public class deleteSync { |
| | | |
| | | private final SysOssMapper baseMapper; |
| | | private final ISysOssService ossService; |
| | | private final SysOssMapper ossMapper; |
| | | private final Boundary boundary; |
| | | |
| | | public deleteSync(SysOssMapper baseMapper, Boundary boundary) { |
| | | this.baseMapper = baseMapper; |
| | | 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<SysOssVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysOss>() |
| | | .le(SysOss::getCreateTime, LocalDateTime.now().minusDays(1))); |
| | | |
| | | if (list.size() == 0) { |
| | | System.out.println("self delete......"); |
| | | List<Long> ids = ossMapper.getWillDeleted(LocalDateTime.now().minusDays(1)); |
| | | if (ids.size() == 0) { |
| | | return; |
| | | } |
| | | for (SysOssVo vo : list) { |
| | | baseMapper.deleteById(vo.getOssId()); |
| | | HttpUtils.sendDeleteRequest(boundary.getVideo() + "/resource/synchronization/delete", |
| | | String.valueOf(vo.getOssId())); |
| | | } |
| | | ossService.deleteByIds(ids); |
| | | } |
| | | |
| | | } |