中扬CRM客户关系管理系统
LSH
2024-03-26 861efe8a7ddc3d52dddbcce83d3a43f476a7418c
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();
        }
    }
}