This commit is contained in:
Yutousama 2021-08-17 07:42:04 +08:00
parent a0d77aee8f
commit 1a69a38cf8
4 changed files with 41 additions and 20 deletions

View File

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class ToolsApplication { public class ToolsApplication {
public static final String version="1.1.4"; public static final String version="1.1.5";
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("当前版本号:" + version); System.out.println("当前版本号:" + version);

View File

@ -6,8 +6,12 @@ import com.yutou.tools.ToolsApplication;
import com.yutou.tools.mybatis.dao.UKeyDao; import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKey; import com.yutou.tools.mybatis.model.UKey;
import com.yutou.tools.mybatis.model.UKeyExample; import com.yutou.tools.mybatis.model.UKeyExample;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.RedisTools; import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools; import com.yutou.tools.utils.Tools;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -122,6 +126,23 @@ public class tools {
} }
return RedisTools.get("request"); return RedisTools.get("request");
} }
@RequestMapping("/public/video.do")
public ResponseEntity<FileSystemResource> getVideo(){
return Tools.getFile(new File("Z:\\download\\anim\\鬼灭之刃\\[BeanSub&FZSD&LoliHouse] Kimetsu no Yaiba - 07 [WebRip 1080p HEVC-10bit AAC ASSx2]\\[BeanSub&FZSD&LoliHouse] Kimetsu no Yaiba - 07 [WebRip 1080p HEVC-10bit AAC ASSx2].mkv"));
}
//ffmpeg -i "[NC-Raws] 小林家的龙女仆S - 01 [B-Global][WEB-DL][2160p][AVC AAC][CHS_CHT_ENG_TH_SRT][MKV].mkv" -vn -an -map 0:2 sub2.srt
@RequestMapping("/public/sub.srt")
public ResponseEntity<FileSystemResource> getVideoSub(){
return Tools.getFile(new File("Z:\\download\\anim\\鬼灭之刃\\[BeanSub&FZSD&LoliHouse] Kimetsu no Yaiba - 07 [WebRip 1080p HEVC-10bit AAC ASSx2].SC.ass"));
}
@RequestMapping("/tools/server.do")
@ResponseBody
public String sendServer(String title,String msg){
Tools.sendServer(title,msg);
return "ok";
}
public int getUid(HttpServletRequest request) { public int getUid(HttpServletRequest request) {
String token = request.getParameter("token"); String token = request.getParameter("token");

View File

@ -265,7 +265,23 @@ public class Tools {
downloadInterface.onError(e); downloadInterface.onError(e);
} }
} }
public static ResponseEntity<FileSystemResource> getFile(File file,MediaType mediaType){
HttpHeaders headers = new HttpHeaders();
//headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
try {
headers.add("Content-Disposition", "attachment; filename=" + URLEncoder.encode(file.getName(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
headers.add("Content-Disposition", "attachment; filename=" + file.getName());
}
//headers.add("Pragma", "no-cache");
// headers.add("Expires", "0");
// headers.add("Last-Modified", new Date().toString());
// headers.add("ETag", String.valueOf(System.currentTimeMillis()));
headers.remove("Vary");
headers.remove("Connection");
headers.remove("Content-Disposition");
return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(mediaType).body(new FileSystemResource(file));
}
/** /**
* 构造给前端的文件 * 构造给前端的文件
* *
@ -273,18 +289,7 @@ public class Tools {
* @return 前端获取的文件 * @return 前端获取的文件
*/ */
public static ResponseEntity<FileSystemResource> getFile(File file) { public static ResponseEntity<FileSystemResource> getFile(File file) {
HttpHeaders headers = new HttpHeaders(); return getFile(file,MediaType.parseMediaType("application/octet-stream"));
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
try {
headers.add("Content-Disposition", "attachment; filename=" + URLEncoder.encode(file.getName(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
headers.add("Content-Disposition", "attachment; filename=" + file.getName());
}
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
headers.add("Last-Modified", new Date().toString());
headers.add("ETag", String.valueOf(System.currentTimeMillis()));
return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file));
} }
public static String getFileMD5(File file) { public static String getFileMD5(File file) {

View File

@ -19,14 +19,9 @@ class ToolsApplicationTests {
@Test @Test
void main(){ void main(){
List<String> list=Tools.getUrls("com.yutou.tools",null);
for (String aClass : list) {
System.out.println(aClass);
}
} }
@Test @Test
void ptest(){ void ptest(){
JSONObject json=new AuthManagerController().getUserAuth("3");
System.out.println(json.toJSONString());
} }
} }