liujie
2026-03-16 8d2400e90e8490422bf033cf7f3cfca46c0290e8
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TVersionManagementController.java
@@ -10,6 +10,7 @@
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.model.TVersionManagement;
import com.stylefeng.guns.modular.system.service.ITVersionManagementService;
import com.stylefeng.guns.modular.system.util.COSUploadService;
import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -40,6 +41,9 @@
    
    @Autowired
    private PushMinistryOfTransportUtil pushMinistryOfTransportUtil;
    @Autowired
    private COSUploadService cosUploadService;
    
    @Value("${pushMinistryOfTransport}")
    private boolean pushMinistryOfTransport;
@@ -122,44 +126,44 @@
        Map<String, Object> m = new HashMap<>();
        //TODO 更换存储方式
        // QianYunTongConfig qianYunTongConfig1 = qianYunTongConfig.getQianYunTongConfig();
        try {
       //     String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(myfile.getOriginalFilename());
       //     String bucketName = qianYunTongConfig1.getBucketName();
       //     Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName);
       //     if (null == grjyTest) {
      //         //创建桶
      //         Boolean bucket = NCOSSUtil.createBucket(bucketName);
      //         if (!bucket) {
      //            throw new RuntimeException("创建存储桶失败");
      //         }
      //         //设置桶策略
      //         String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}";
      //         Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText);
      //         if (!bucketPolicy) {
      //            throw new RuntimeException("设置桶策略失败");
      //         }
       //     }
       //     //上传对象
       //     String key = "apk/" + pictureName;
       //     String object = NCOSSUtil.putObject(bucketName, key, myfile.getInputStream());
       //     if (null == object) {
      //         throw new RuntimeException("上传图片失败");
       //     }
        //     if("prod".equals(qianYunTongConfig.getActiveProfile())){
        //         m.put("imgUrl", "https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key);
        //     }else{
        //         m.put("imgUrl", "https://test-qncx.sitechcloud.com/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key);
        //     }
        } catch (Exception e) {
            e.printStackTrace();
        }
//        try {
//            String pictureName = OssUploadUtil.ossUpload(request, myfile);
//            m.put("imgUrl", pictureName);
//        }catch (Exception e){
//       //     String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(myfile.getOriginalFilename());
//       //     String bucketName = qianYunTongConfig1.getBucketName();
//       //     Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName);
//       //     if (null == grjyTest) {
//      //         //创建桶
//      //         Boolean bucket = NCOSSUtil.createBucket(bucketName);
//      //         if (!bucket) {
//      //            throw new RuntimeException("创建存储桶失败");
//      //         }
//      //         //设置桶策略
//      //         String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}";
//      //         Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText);
//      //         if (!bucketPolicy) {
//      //            throw new RuntimeException("设置桶策略失败");
//      //         }
//       //     }
//       //     //上传对象
//       //     String key = "apk/" + pictureName;
//       //     String object = NCOSSUtil.putObject(bucketName, key, myfile.getInputStream());
//       //     if (null == object) {
//      //         throw new RuntimeException("上传图片失败");
//       //     }
//        //     if("prod".equals(qianYunTongConfig.getActiveProfile())){
//        //         m.put("imgUrl", "https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key);
//        //     }else{
//        //         m.put("imgUrl", "https://test-qncx.sitechcloud.com/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key);
//        //     }
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        try {
            String pictureName = cosUploadService.uploadFile(myfile);
            m.put("imgUrl", pictureName);
        }catch (Exception e){
            e.printStackTrace();
        }
        return m;
    }