中扬CRM客户关系管理系统
#
LSH
2023-12-04 4e3a145c822e37f3fa1af0f6ed7f78148fa9003f
src/main/java/com/zy/crm/system/controller/AppVersionController.java
@@ -9,8 +9,14 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
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;
@@ -213,4 +219,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();
        }
    }
}