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
7d01a27b
Commit
7d01a27b
authored
May 11, 2020
by
qwmqiuwenmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
149e8033
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletions
+72
-1
UploadController.java
...om/gic/haoban/manage/web/controller/UploadController.java
+67
-0
MaterialController.java
.../gic/haoban/manage/web/controller/MaterialController.java
+5
-1
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/UploadController.java
0 → 100644
View file @
7d01a27b
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
java.io.File
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.apache.commons.io.FileUtils
;
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
com.alibaba.fastjson.JSONObject
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.qcloud.BucketNameEnum
;
import
com.gic.qcloud.FileUploadUtil
;
@RestController
public
class
UploadController
extends
WebBaseController
{
private
static
Set
<
String
>
FILE_TYPE
=
new
HashSet
<>(
);
static
{
for
(
BucketNameEnum
value:
BucketNameEnum
.
values
()){
FILE_TYPE
.
add
(
value
.
getName
()
);
}
}
@RequestMapping
(
"/upload-file"
)
@ResponseBody
public
HaobanResponse
upload
(
@RequestParam
MultipartFile
file
,
@RequestParam
String
fileType
)
throws
Exception
{
if
(
file
==
null
||
file
.
isEmpty
()){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
String
name
=
file
.
getOriginalFilename
();
String
suffix
=
name
.
substring
(
name
.
lastIndexOf
(
"."
)
+
1
);
String
location
=
System
.
getProperty
(
"user.dir"
)+
"/data/tmp/"
;
//b
long
len
=
file
.
getSize
();
File
templateFile
=
new
File
(
location
+
name
);
FileUtils
.
copyInputStreamToFile
(
file
.
getInputStream
(),
templateFile
);
// 2.上传腾讯云
String
dayFilePath
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
DateUtil
.
FORMAT_DATETIME_14
)
);
String
key
=
"haoban/"
+
dayFilePath
+
"/"
+
name
;
fileType
=
FILE_TYPE
.
contains
(
fileType
)?
fileType:
BucketNameEnum
.
OTHER_90000
.
getName
();
String
url
=
FileUploadUtil
.
simpleUploadFileFromLocal
(
templateFile
,
key
,
fileType
);
if
(
templateFile
!=
null
){
templateFile
.
delete
();
}
JSONObject
res
=
new
JSONObject
(
);
res
.
put
(
"name"
,
name
);
res
.
put
(
"ext"
,
suffix
);
res
.
put
(
"size"
,
len
);
res
.
put
(
"key"
,
key
);
res
.
put
(
"url"
,
"https://"
+
url
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
res
);
}
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/MaterialController.java
View file @
7d01a27b
...
...
@@ -11,8 +11,10 @@ import org.springframework.web.bind.annotation.RestController;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.PageResult2
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.manage.api.dto.MaterialCategoryDTO
;
import
com.gic.haoban.manage.api.dto.MaterialDTO
;
import
com.gic.haoban.manage.api.service.MaterialApiService
;
...
...
@@ -31,7 +33,9 @@ public class MaterialController extends WebBaseController{
@RequestMapping
(
"/material-list"
)
public
HaobanResponse
materialList
(
String
wxEnterpriseId
,
String
keyword
,
String
categoryId
,
Integer
materialType
,
BasePageInfo
pageInfo
)
{
Page
<
MaterialDTO
>
page
=
materialApiService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryId
,
materialType
,
pageInfo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
page
);
//暂时转换
PageResult2
pageResult2
=
PageUtil
.
getPageInfo
(
page
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
pageResult2
);
}
/**
...
...
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