From fbc70017e087f5ff0a3e21790cdd75ec2067e0d9 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期一, 04 十二月 2023 13:21:12 +0800 Subject: [PATCH] # --- src/main/java/com/zy/crm/system/controller/AppVersionController.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 57 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/zy/crm/system/controller/AppVersionController.java b/src/main/java/com/zy/crm/system/controller/AppVersionController.java index 9cf7eb6..8427f99 100644 --- a/src/main/java/com/zy/crm/system/controller/AppVersionController.java +++ b/src/main/java/com/zy/crm/system/controller/AppVersionController.java @@ -9,8 +9,15 @@ import com.core.common.Cools; import com.core.common.DateUtils; import com.core.common.R; +import com.zy.crm.common.service.OssService; +import com.zy.crm.common.utils.FileSaveExampleUtil; import com.zy.crm.common.web.BaseController; +import com.zy.crm.manager.entity.Plan; +import com.zy.crm.manager.entity.PlanType; +import com.zy.crm.manager.entity.PlanUrl; +import com.zy.crm.manager.entity.PriQuote; import com.zy.crm.system.entity.AppVersion; +import com.zy.crm.system.entity.User; import com.zy.crm.system.service.AppVersionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; @@ -28,6 +35,8 @@ @Autowired private AppVersionService appVersionService; + @Autowired + private OssService ossService; @RequestMapping(value = "/appVersion/{id}/auth") @ManagerAuth @@ -47,7 +56,8 @@ excludeTrash(param); convert(param, wrapper); allLike(AppVersion.class, param.keySet(), wrapper, condition); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} +// if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} + wrapper.orderBy("id", false); return R.ok(appVersionService.selectPage(new Page<>(curr, limit), wrapper)); } @@ -62,6 +72,9 @@ if (latestApp.getVersion().equals(version)) { return R.error("宸叉槸鏈�鏂扮増鏈�"); } + + String download = ossService.download(latestApp.getPath()); + latestApp.setUrl(download); return R.ok("鏈夋柊鐗堟湰锛岄渶瑕佹洿鏂�").add(latestApp); } @@ -213,4 +226,47 @@ response.setStatus(404); } } + + @RequestMapping(value = "/appVersion/downloadApp/url/view/file/auth") + @ManagerAuth + public R viewFile(@RequestParam("appId") String appId){ + List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>(); + if (Cools.isEmpty(appId)){ + return R.ok(fileDTOS); + } + Long id = Long.parseLong(appId); + AppVersion appVersion = appVersionService.selectById(id); + if (Cools.isEmpty(appVersion.getPath())){ + return R.ok(fileDTOS); + } + try{ + FileSaveExampleUtil.FileDTO fileDTO = new FileSaveExampleUtil.FileDTO(appVersion.getPath(),appVersion.getFileSize(),appVersion.getUrl()); + fileDTO.setUserName(appVersion.getUserName()); + fileDTOS.add(fileDTO); + return R.ok(fileDTOS); + }catch (Exception e){ + return R.error(); + } + } + + @RequestMapping(value = "/appVersion/downloadApp/url/insert/file/auth") + @ManagerAuth + public R insertFilePriQuote(@RequestParam("appId") String appId, @RequestParam("filename") String filename, + @RequestParam("filesize") Long filesize) { + try { + String[] split = appId.split("-"); + Long id = Long.parseLong(split[1]); + AppVersion appVersion = appVersionService.selectById(id); + appVersion.setPath(filename); + appVersion.setFileSize(filesize); + appVersion.setUserName(getUser().getNickname()); + String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename; + appVersion.setUrl(url); + appVersionService.updateById(appVersion); + return R.ok(); + } catch (Exception e) { + System.out.println(e); + return R.error(); + } + } } -- Gitblit v1.9.1