Commit 8a280679 by 徐高华

获取cos桶

parent be0e80ec
...@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.controller; ...@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.controller;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.AccountService;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.common.anno.IgnoreLogin; import com.gic.haoban.common.anno.IgnoreLogin;
import com.gic.haoban.common.utils.HaobanResponse; import com.gic.haoban.common.utils.HaobanResponse;
...@@ -9,6 +10,7 @@ import com.gic.haoban.common.utils.UploadUtils; ...@@ -9,6 +10,7 @@ import com.gic.haoban.common.utils.UploadUtils;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.thirdparty.api.service.QQCloudPicService; import com.gic.thirdparty.api.service.QQCloudPicService;
import com.gic.thirdparty.cloudfile.CloudFileUtil; import com.gic.thirdparty.cloudfile.CloudFileUtil;
import com.gic.thirdparty.cloudfile.CmeUtil;
import com.gic.thirdparty.cloudfile.enums.CloudFileBusinessOptEnum; import com.gic.thirdparty.cloudfile.enums.CloudFileBusinessOptEnum;
import com.gic.thirdparty.cloudfile.enums.CloudFileTypeEnum; import com.gic.thirdparty.cloudfile.enums.CloudFileTypeEnum;
import com.gic.thirdparty.cloudfile.pojo.CloudFileInfo; import com.gic.thirdparty.cloudfile.pojo.CloudFileInfo;
...@@ -17,6 +19,8 @@ import org.apache.commons.lang.StringUtils; ...@@ -17,6 +19,8 @@ import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
...@@ -30,10 +34,57 @@ import java.util.*; ...@@ -30,10 +34,57 @@ import java.util.*;
public class UploadController extends WebBaseController { public class UploadController extends WebBaseController {
private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(UploadController.class); private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(UploadController.class);
@Autowired @Autowired
private QQCloudPicService qqCloudPicService; private AccountService accountService;
@Autowired @Autowired
private EnterpriseService enterpriseService ; private EnterpriseService enterpriseService ;
/**
* 获取桶名称
* @param fileType 文件后缀 mp4、jpg....
* @param fileFlag 视频类型 3为cme临时资源 - 此字段保持原来业务
* @param tempFlag 是否临时文件,1是0否
* @return
*/
@RequestMapping("get-bucket")
@ResponseBody
public RestResponse<CloudFileInfo> getBucket(String fileType,String enterpriseId, @RequestParam(required = false)Integer fileFlag , String businessType , @RequestParam(required = false) int tempFlag) {
CloudFileBusinessOptEnum businessOptEnum = null ;
// 天
Long timeOut = null ;
if(StringUtils.isBlank(businessType)) {
businessType = "material_content" ;
}
// 内容中心
if("material_content".equals(businessType)) {
//存储空间余额校验
if (!accountService.storageFeeCheck(enterpriseId)){
return RestResponse.failure("-1", "存储余额不足,暂不支持图片/视频上传,请充值");
}
businessOptEnum = CloudFileBusinessOptEnum.MATERIAL_CONTENT ;
}else if("haoban".equals(businessType)) {
// 好办
if(tempFlag==0) {
businessOptEnum = CloudFileBusinessOptEnum.HAOBAN_COMMON ;
}else {
businessOptEnum = CloudFileBusinessOptEnum.COMMON ;
timeOut = 7L ;
}
}
CloudFileTypeEnum cloudFileTypeEnum = CloudFileTypeEnum.getFileTypeByExtension(fileType);
CloudFileInfo cloudFileInfo = null;
//cme上传视频走 temp存储桶只存一天有效期
if (fileFlag != null && fileFlag == 3) {
cloudFileInfo = CloudFileUtil.getPreUploadTempFileInfo(fileType, cloudFileTypeEnum, CmeUtil.CME_TEMP_COS, CloudFileBusinessOptEnum.MATERIAL_CONTENT, 1L);
}else {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
cloudFileInfo = CloudFileUtil.getPreUploadTempFileInfo(fileType, cloudFileTypeEnum, enterpriseDTO.getFactoryCode(), businessOptEnum,timeOut);
}
if (cloudFileInfo == null){
return RestResponse.failure("-1", "获取桶名称失败");
}
return RestResponse.successResult(cloudFileInfo);
}
@RequestMapping("upload-img") @RequestMapping("upload-img")
@IgnoreLogin @IgnoreLogin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment