Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
4dfbd405
Commit
4dfbd405
authored
Jul 04, 2024
by
徐高华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/xgh/0704上线' into 'master'
获取cos桶 See merge request
!1993
parents
d7e3456b
396293f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
2 deletions
+53
-2
UploadController.java
...om/gic/haoban/manage/web/controller/UploadController.java
+53
-2
No files found.
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/UploadController.java
View file @
4dfbd405
...
...
@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.controller;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
import
com.gic.enterprise.api.service.AccountService
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.haoban.common.anno.IgnoreLogin
;
import
com.gic.haoban.common.utils.HaobanResponse
;
...
...
@@ -9,6 +10,7 @@ import com.gic.haoban.common.utils.UploadUtils;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.thirdparty.api.service.QQCloudPicService
;
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.CloudFileTypeEnum
;
import
com.gic.thirdparty.cloudfile.pojo.CloudFileInfo
;
...
...
@@ -17,6 +19,8 @@ import org.apache.commons.lang.StringUtils;
import
org.apache.logging.log4j.LogManager
;
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
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
...
...
@@ -30,10 +34,57 @@ import java.util.*;
public
class
UploadController
extends
WebBaseController
{
private
static
org
.
apache
.
logging
.
log4j
.
Logger
logger
=
LogManager
.
getLogger
(
UploadController
.
class
);
@Autowired
private
QQCloudPicService
qqCloudPic
Service
;
private
AccountService
account
Service
;
@Autowired
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
(
defaultValue
=
"0"
)
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"
)
@IgnoreLogin
...
...
@@ -120,7 +171,7 @@ public class UploadController extends WebBaseController {
if
(
name
.
contains
(
"."
))
{
name
=
name
.
substring
(
name
.
lastIndexOf
(
"."
)+
1
)
;
}
CloudFileInfo
uploadInfo
=
CloudFileUtil
.
uploadTempFile
(
file
,
name
,
type
,
factoryCode
,
CloudFileBusinessOptEnum
.
COMMON
,
7
*
24
L
)
;
CloudFileInfo
uploadInfo
=
CloudFileUtil
.
uploadTempFile
(
file
,
name
,
type
,
factoryCode
,
CloudFileBusinessOptEnum
.
COMMON
,
7L
)
;
if
(
uploadInfo
!=
null
)
{
map
.
put
(
"qcloudImageUrl"
,
uploadInfo
.
getOrgFileUrl
());
map
.
put
(
"imageFiledCode"
,
"imageFiledCode"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment