package com.ruoyi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.util.unit.DataSize;
import javax.servlet.MultipartConfigElement;
/**
* 启动程序
*
* @author ruoyi
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan("com.ruoyi.file2.web.dao,com.ruoyi.file3.dao,com.ruoyi.file3.log.dao,com.ruoyi.file3.storage.local.LocalStorageProcessor")
@EnableAsync
public class RuoYiApplication
{
public static void main(String[] args)
{
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ VR项目启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
/**
* 文件上传配置
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//单个文件最大
factory.setMaxFileSize(DataSize.parse("1000MB")); //KB,MB
/// 设置总上传数据总大小
factory.setMaxRequestSize(DataSize.parse("1000MB"));
return factory.createMultipartConfig();
}
}
@RestController
@RequestMapping("/videoInfoRecords/videoInfoRecords")
@EnableScheduling
public class VideoInfoRecordsController extends BaseController {
@Autowired
private IVideoInfoRecordsService videoInfoRecordsService;
/**
* 时长超过三十秒,该条观看记录结束
*/
@Scheduled(cron = "*/1 * * * * ?") //每个1秒进行查询
public void updateWatchVideoStatus() {
VideoInfoRecords videoInfoRecords = new VideoInfoRecords();
videoInfoRecords.setStatus("未退出");
List<VideoInfoRecords> list = videoInfoRecordsService.selectVideoInfoRecordsList(videoInfoRecords);
for (VideoInfoRecords infoRecords : list) {
//如果更新时间大于时间30S,则更改状态
Date updateTime = infoRecords.getUpdateTime();
long diffTime = System.currentTimeMillis() - updateTime.getTime(); //获得是毫秒间隔
if(diffTime>30000){
infoRecords.getId();
infoRecords.setStatus("已退出");
videoInfoRecordsService.updateVideoInfoRecords(infoRecords);
}
}
}
03-31
8961
03-05
255