Commit 9697a22d by jinxin

FactoryCode处理

parent 169853ab
......@@ -4,11 +4,12 @@ import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.AuthorizedUser;
import com.gic.commons.util.DateUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.utils.statistics.UploadUtils;
import com.gic.qcloud.BucketNameEnum;
import com.gic.qcloud.FileUploadUtil;
import com.gic.thirdparty.cloudfile.CloudFileUtil;
import com.gic.thirdparty.cloudfile.enums.CloudFileBusinessOptEnum;
import com.gic.thirdparty.cloudfile.enums.CloudFileTypeEnum;
......@@ -17,6 +18,7 @@ import com.gic.web.common.utils.SessionContextUtils;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -41,6 +43,9 @@ public class UploadController extends WebBaseController {
}
}
@Autowired
private EnterpriseService enterpriseService;
@RequestMapping("/upload-file")
@ResponseBody
public HaobanResponse upload(@RequestParam MultipartFile file, @RequestParam String fileType) throws Exception {
......@@ -49,6 +54,10 @@ public class UploadController extends WebBaseController {
}
//获取登录人信息
final AuthorizedUser au = SessionContextUtils.getLoginUser();
EnterpriseDTO enterprise = this.enterpriseService.getEnterpriseById(au.getEnterpriseId());
if (null == enterprise) {
return resultResponse(HaoBanErrCode.ERR_OTHER, "商户不存在");
}
logger.info("登录人信息:{}", JSONObject.toJSONString(au));
String name = file.getOriginalFilename();
// 未加密前文件名称
......@@ -82,7 +91,7 @@ public class UploadController extends WebBaseController {
} else if (UploadUtils.isVedio(suffix)) {
cloudFileTypeEnum = CloudFileTypeEnum.VIDEO;
}
CloudFileInfo cloudFileInfo = CloudFileUtil.uploadFile(new FileInputStream(templateFile), suffix, cloudFileTypeEnum,au.getEnterpriseDTO().getFactoryCode(), CloudFileBusinessOptEnum.HAOBAN_COMMON);
CloudFileInfo cloudFileInfo = CloudFileUtil.uploadFile(new FileInputStream(templateFile), suffix, cloudFileTypeEnum, enterprise.getFactoryCode(), CloudFileBusinessOptEnum.HAOBAN_COMMON);
if (templateFile != null) {
templateFile.delete();
}
......
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