Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
wangming
/
kzy-oss
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6d311759
authored
Mar 13, 2020
by
wangming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wangming' into '105'
banner See merge request
!5
2 parents
0828de1a
7bb7d7fe
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
3 deletions
src/main/java/com/server/utils/FileStore.java
src/main/java/com/server/web/controller/CourseController.java
src/main/resources/mybatis/mapping/queryModel.xml
src/main/resources/servers/105/application.properties
src/main/java/com/server/utils/FileStore.java
View file @
6d31175
package
com
.
server
.
utils
;
import
com.qiniu.common.QiniuException
;
import
com.qiniu.common.Zone
;
import
com.qiniu.storage.Configuration
;
import
com.qiniu.storage.UploadManager
;
import
com.qiniu.util.Auth
;
import
com.server.utils.key.QiniuKey
;
import
com.server.utils.key.UploadUrlKey
;
import
org.slf4j.Logger
;
...
...
@@ -11,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.imageio.ImageIO
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* 本地文件存储
...
...
@@ -24,8 +30,22 @@ public class FileStore {
@Autowired
QiniuKey
qiniuKey
;
public
String
storeImage
(
String
path
,
MultipartFile
file
)
{
return
store
(
path
,
file
);
public
String
storeImage
(
String
path
,
MultipartFile
file
)
throws
IOException
{
String
accessKey
=
qiniuKey
.
getAccessKey
();
String
secretKey
=
qiniuKey
.
getSecretKey
();
String
bucket
=
qiniuKey
.
getBucket
();
String
fileName
=
file
.
getOriginalFilename
();
Auth
auth
=
Auth
.
create
(
accessKey
,
secretKey
);
String
upToken
=
auth
.
uploadToken
(
bucket
);
String
imageUrl
=
""
;
InputStream
input
=
file
.
getInputStream
();
imageUrl
=
uploadUrlKey
.
getBasePath
()+
String
.
valueOf
(
System
.
currentTimeMillis
())+
"."
+
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
);
//构造一个带指定Zone对象的配置类
Configuration
cfg
=
new
Configuration
(
Zone
.
zone1
());
//...其他参数参考类注释
UploadManager
uploadManager
=
new
UploadManager
(
cfg
);
uploadManager
.
put
(
input
,
imageUrl
,
upToken
,
null
,
null
);
return
imageUrl
;
}
public
String
getRealPath
(
String
path
)
{
...
...
src/main/java/com/server/web/controller/CourseController.java
View file @
6d31175
This diff is collapsed.
Click to expand it.
src/main/resources/mybatis/mapping/queryModel.xml
View file @
6d31175
...
...
@@ -124,4 +124,40 @@
ORDER BY t.id DESC
</select>
<select
id=
"queryCourseZb"
resultType=
"java.util.HashMap"
parameterType=
"java.util.HashMap"
>
SELECT
c.id,
c.course_name AS courseName,
c.is_up as isUp,
date_format(c.start_dt,'%Y-%m-%d %H:%i:%S') startDt,
date_format(c.end_dt,'%Y-%m-%d %H:%i:%S') endDt,
if(date_format(NOW(),'%Y-%m-%d %H:%i:%S')
<
date_format(c.start_dt,'%Y-%m-%d %H:%i:%S'),0,if(date_format(NOW(),'%Y-%m-%d %H:%i:%S')
>
date_format(c.end_dt,'%Y-%m-%d %H:%i:%S'),2,1)) status
FROM
t_kzy_course c
WHERE c.course_type=1
AND c.is_delete = 0
<if
test=
"courseName != null"
>
AND c.course_name LIKE #{courseName}
</if>
ORDER BY c.create_dt DESC
</select>
<select
id=
"queryCourseLb"
resultType=
"java.util.HashMap"
parameterType=
"java.util.HashMap"
>
SELECT
c.id,
c.course_name AS courseName,
date_format(c.create_dt,'%Y-%m-%d %H:%i:%S') createDt,
if(c.live_url is not null,1,2) liveStatus,
c.is_up AS isUp
FROM
t_kzy_course c
WHERE c.course_type=2
AND c.is_delete = 0
<if
test=
"courseName != null"
>
AND c.course_name LIKE #{courseName}
</if>
ORDER BY c.create_dt DESC
</select>
</mapper>
\ No newline at end of file
src/main/resources/servers/105/application.properties
View file @
6d31175
...
...
@@ -48,7 +48,7 @@ rest.api.charset=utf-8
#加密secret_key
rest.api.secretkey
=
FoK28EsYrxuiM3ohnAurFGm2uGAHyijL
#上传图片
upload.image.dir
=
/
data
/tempImages
upload.image.dir
=
/
alidata/server/kzy_oss
/tempImages
upload.image.base.path
=
tempImages/
#七牛云
qiniu.accessKey
=
tOdsZIdcGZB4A6B4X6XnhRj9PALEPIY4QRT7RduW
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment