|
@@ -15,9 +15,7 @@ import com.caimei.service.auth.AuthProductService;
|
|
import com.caimei.service.auth.AuthService;
|
|
import com.caimei.service.auth.AuthService;
|
|
import com.caimei.service.auth.ShopService;
|
|
import com.caimei.service.auth.ShopService;
|
|
import com.caimei.service.auth.UploadService;
|
|
import com.caimei.service.auth.UploadService;
|
|
-import com.caimei.utils.Base64Util;
|
|
|
|
-import com.caimei.utils.ImageUtils;
|
|
|
|
-import com.caimei.utils.Md5Util;
|
|
|
|
|
|
+import com.caimei.utils.*;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -46,6 +44,7 @@ import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
+import org.springframework.util.Assert;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -54,6 +53,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.imageio.ImageIO;
|
|
import javax.imageio.ImageIO;
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.swing.*;
|
|
import javax.swing.*;
|
|
@@ -1449,4 +1449,100 @@ public class AuthServiceImpl implements AuthService {
|
|
public void savaDyCommand(Integer authId,String content){
|
|
public void savaDyCommand(Integer authId,String content){
|
|
authMapper.savaDyCommand(authId,content);
|
|
authMapper.savaDyCommand(authId,content);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据authId获取ossName
|
|
|
|
+ * @param videoID
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String getOssNameAuthId(Integer videoID){
|
|
|
|
+ return authMapper.getOssNameId(videoID);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据authId删除视频
|
|
|
|
+ * @param videoID
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteVideoByAuthId(Integer videoID){
|
|
|
|
+
|
|
|
|
+ authMapper.deleteVideoById(videoID);
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson downLoadChoseZip(String fileId,HttpServletResponse response){
|
|
|
|
+ if (fileId.contains(",")) {
|
|
|
|
+ String[] split = fileId.split(",");
|
|
|
|
+ ArrayList<ChallengeRoundVo> fileTreeVos = new ArrayList<>();
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ ChallengeRoundVo file = authMapper.getChallengeRoundInfo(Integer.valueOf(s));
|
|
|
|
+ fileTreeVos.add(file);
|
|
|
|
+ }
|
|
|
|
+ //有package则在服务器固定路径new file.mkdir
|
|
|
|
+ UUID uuid = UUID.randomUUID();
|
|
|
|
+ String zipPath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid;
|
|
|
|
+ String filePath = zipPath;
|
|
|
|
+ if ("dev".equals(active)) {
|
|
|
|
+ zipPath = "D:\\caimei-workSpace\\file\\" + uuid;
|
|
|
|
+ filePath = zipPath;
|
|
|
|
+ }
|
|
|
|
+ boolean mkdirs = new File(filePath).mkdirs();
|
|
|
|
+ Assert.isTrue(mkdirs, "文件夹创建失败");
|
|
|
|
+ for (ChallengeRoundVo challengeRoundVo : fileTreeVos) {
|
|
|
|
+ //普通文件直接下载到临时文件夹uuid下
|
|
|
|
+ String fileName = "";
|
|
|
|
+ if ("dev".equals(active)) {
|
|
|
|
+ fileName = zipPath + "\\"+challengeRoundVo.getId() ;
|
|
|
|
+ } else {
|
|
|
|
+ fileName = zipPath + "/"+challengeRoundVo.getId() ;
|
|
|
|
+ }
|
|
|
|
+ OSSUtils.downFileByFilePath("authFile/", challengeRoundVo.getOssName(), fileName);
|
|
|
|
+// else {
|
|
|
|
+// //文件夹在uuid文件夹下创建自己包名的文件夹
|
|
|
|
+// String param = fileTreeVo.getId() + "," + authUserId;
|
|
|
|
+// String myPath = "";
|
|
|
|
+// myPath = filePath + "/" + fileTreeVo.getFileName();
|
|
|
|
+// if ("dev".equals(active)) {
|
|
|
|
+// myPath = filePath + "\\" + fileTreeVo.getFileName();
|
|
|
|
+// }
|
|
|
|
+// boolean dirs = new File(myPath).mkdirs();
|
|
|
|
+// Assert.isTrue(dirs, "文件夹创建失败");
|
|
|
|
+// recursion(param, myPath);
|
|
|
|
+// }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //压缩
|
|
|
|
+ FileZipUtils.compress(zipPath, "", true);
|
|
|
|
+ String s = zipPath + ".zip";
|
|
|
|
+ String fileName = uuid + ".zip";
|
|
|
|
+ File file = new File(s);
|
|
|
|
+ try {
|
|
|
|
+ if (file.exists()) {
|
|
|
|
+ FileInputStream fileInputStream = new FileInputStream(file);
|
|
|
|
+ ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
+ // 设置下载文件的mineType,告诉浏览器下载文件类型
|
|
|
|
+// int i = fileName.lastIndexOf(".");
|
|
|
|
+// String substring = fileName.substring(i + 1, filePath.length());
|
|
|
|
+ response.setContentType("application/zip");
|
|
|
|
+ // 设置一个响应头,无论是否被浏览器解析,都下载
|
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
|
|
|
+ byte[] bytes = new byte[1024];
|
|
|
|
+ int len;
|
|
|
|
+ while ((len = fileInputStream.read(bytes)) != -1) {
|
|
|
|
+ outputStream.write(bytes, 0, len);
|
|
|
|
+ }
|
|
|
|
+ fileInputStream.close();
|
|
|
|
+ outputStream.close();
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ file.delete();
|
|
|
|
+ FileZipUtils.deleteFile(new File(zipPath));
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|