use of lee.study.down.model.ResultInfo in project proxyee-down by monkeyWie.
the class HttpDownController method getTask.
@RequestMapping("/getTask")
public ResultInfo getTask(@RequestParam String id) throws Exception {
ResultInfo resultInfo = new ResultInfo();
HttpDownInfo httpDownInfo = ContentManager.DOWN.getDownInfo(id);
if (httpDownInfo != null) {
TaskInfo taskInfo = httpDownInfo.getTaskInfo();
Map<String, Object> data = new HashMap<>();
data.put("task", NewTaskForm.parse(httpDownInfo));
// 检查是否有相同大小的文件
List<HttpDownInfo> sameTasks = ContentManager.DOWN.getDownInfos().stream().filter(downInfo -> HttpDownStatus.WAIT != downInfo.getTaskInfo().getStatus() && HttpDownStatus.DONE != downInfo.getTaskInfo().getStatus() && downInfo.getTaskInfo().getTotalSize() == taskInfo.getTotalSize()).collect(Collectors.toList());
data.put("sameTasks", NewTaskForm.parse(sameTasks));
resultInfo.setData(data);
}
return resultInfo;
}
use of lee.study.down.model.ResultInfo in project proxyee-down by monkeyWie.
the class HttpDownController method checkUpdate.
@RequestMapping("/checkUpdate")
public ResultInfo checkUpdate() throws Exception {
ResultInfo resultInfo = new ResultInfo();
updateInfo = updateService.check(version);
if (updateInfo == null) {
resultInfo.setStatus(ResultStatus.BAD.getCode()).setMsg("已经是最新版本");
return resultInfo;
}
resultInfo.setData(updateInfo);
return resultInfo;
}
use of lee.study.down.model.ResultInfo in project proxyee-down by monkeyWie.
the class HttpDownController method getNewTask.
@RequestMapping("/getNewTask")
public ResultInfo getNewTask() throws Exception {
ResultInfo resultInfo = new ResultInfo();
TaskInfo taskInfo = ContentManager.DOWN.getWaitTask();
if (taskInfo != null) {
resultInfo.setData(taskInfo.getId());
}
return resultInfo;
}
use of lee.study.down.model.ResultInfo in project proxyee-down by monkeyWie.
the class HttpDownController method openTaskDir.
@RequestMapping("/openTaskDir")
public ResultInfo openTaskDir(@RequestParam String id) throws Exception {
ResultInfo resultInfo = new ResultInfo();
TaskInfo taskInfo = ContentManager.DOWN.getTaskInfo(id);
if (taskInfo != null) {
if (FileUtil.exists(taskInfo.getFilePath())) {
Desktop.getDesktop().open(new File(taskInfo.getFilePath()));
} else {
resultInfo.setStatus(ResultStatus.BAD.getCode()).setMsg("目录不存在");
}
} else {
resultInfo.setStatus(ResultStatus.BAD.getCode()).setMsg("任务不存在");
}
return resultInfo;
}
use of lee.study.down.model.ResultInfo in project proxyee-down by monkeyWie.
the class HttpDownController method setConfigInfo.
@RequestMapping("/setConfigInfo")
public ResultInfo setConfigInfo(@RequestBody ConfigForm configForm) {
ResultInfo resultInfo = new ResultInfo();
int beforePort = ContentManager.CONFIG.get().getProxyPort();
boolean beforeSecProxyEnable = ContentManager.CONFIG.get().isSecProxyEnable();
ProxyConfig beforeSecProxyConfig = ContentManager.CONFIG.get().getSecProxyConfig();
if (!configForm.isSecProxyEnable()) {
configForm.setSecProxyConfig(null);
}
ConfigInfo configInfo = configForm.convert();
ContentManager.CONFIG.set(configInfo);
ContentManager.CONFIG.save();
// 代理服务器需要重新启动
if (beforePort != configInfo.getProxyPort() || beforeSecProxyEnable != configInfo.isSecProxyEnable() || (configInfo.isSecProxyEnable() && !configInfo.getSecProxyConfig().equals(beforeSecProxyConfig))) {
new Thread(() -> {
HttpDownApplication.getProxyServer().close();
HttpDownApplication.getProxyServer().setProxyConfig(configInfo.getSecProxyConfig());
HttpDownApplication.getProxyServer().start(configInfo.getProxyPort());
}).start();
}
return resultInfo;
}
Aggregations