Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
Project
Project
Details
Activity
Releases
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
姚本章
dm_project
Commits
a1813bf4
Commit
a1813bf4
authored
Jan 13, 2021
by
ysongq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
6b616132
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
97 additions
and
72 deletions
+97
-72
TestStr.java
...teway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
+10
-0
SMSUtils.java
jz-dm-common/src/main/java/com/jz/common/utils/SMSUtils.java
+1
-0
CompanyAuthController.java
...mall/moduls/controller/company/CompanyAuthController.java
+1
-1
ValidateCodeController.java
...ll/moduls/controller/customer/ValidateCodeController.java
+1
-1
DataGoodsApiController.java
.../mall/moduls/controller/goods/DataGoodsApiController.java
+0
-1
PictureController.java
...m/jz/manage/moduls/controller/file/PictureController.java
+8
-53
PictureService.java
...ain/java/com/jz/manage/moduls/service/PictureService.java
+4
-2
DataGoodsServiceImpl.java
...m/jz/manage/moduls/service/impl/DataGoodsServiceImpl.java
+1
-0
PictureServiceImpl.java
...com/jz/manage/moduls/service/impl/PictureServiceImpl.java
+71
-14
No files found.
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
0 → 100644
View file @
a1813bf4
package
com
.
jz
.
dm
.
gateway
.
orther
;
/**
* @ClassName:
* @Author: Carl
* @Date: 2021/1/13
* @Version:
*/
public
class
TestStr
{
}
jz-dm-common/src/main/java/com/jz/common/utils/SMSUtils.java
View file @
a1813bf4
...
@@ -9,6 +9,7 @@ import com.aliyuncs.http.MethodType;
...
@@ -9,6 +9,7 @@ import com.aliyuncs.http.MethodType;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.aliyuncs.profile.IClientProfile
;
/**
/**
* @ClassName: 短信发送工具类
* @ClassName: 短信发送工具类
* @Author: Carl
* @Author: Carl
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/company/CompanyAuthController.java
View file @
a1813bf4
package
com
.
jz
.
dm
.
mall
.
moduls
.
controller
.
company
;
package
com
.
jz
.
dm
.
mall
.
moduls
.
controller
.
company
;
import
com.aliyuncs.http.HttpRequest
;
import
com.jz.common.entity.Department
;
import
com.jz.common.entity.Department
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.mall.moduls.controller.company.bean.CompanyAddReq
;
import
com.jz.dm.mall.moduls.controller.company.bean.CompanyAddReq
;
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/ValidateCodeController.java
View file @
a1813bf4
package
com
.
jz
.
dm
.
mall
.
moduls
.
controller
.
customer
;
package
com
.
jz
.
dm
.
mall
.
moduls
.
controller
.
customer
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
...
@@ -7,7 +8,6 @@ import com.jz.common.utils.SMSUtils;
...
@@ -7,7 +8,6 @@ import com.jz.common.utils.SMSUtils;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.ValidateCodeUtils
;
import
com.jz.common.utils.ValidateCodeUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/goods/DataGoodsApiController.java
View file @
a1813bf4
...
@@ -9,7 +9,6 @@ import com.jz.dm.mall.moduls.entity.DataGoodsApi;
...
@@ -9,7 +9,6 @@ import com.jz.dm.mall.moduls.entity.DataGoodsApi;
import
com.jz.dm.mall.moduls.service.DataGoodsApiService
;
import
com.jz.dm.mall.moduls.service.DataGoodsApiService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
jz-dm-manage/src/main/java/com/jz/manage/moduls/controller/file/PictureController.java
View file @
a1813bf4
...
@@ -4,17 +4,15 @@ import com.jz.common.utils.Result;
...
@@ -4,17 +4,15 @@ import com.jz.common.utils.Result;
import
com.jz.manage.moduls.service.PictureService
;
import
com.jz.manage.moduls.service.PictureService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.net.ftp.FTPClient
;
import
org.apache.commons.net.ftp.FTPReply
;
import
org.apache.tomcat.util.http.fileupload.IOUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.misc.BASE64Encoder
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.io.InputStream
;
/** * @ClassName:
/** * @ClassName:
...
@@ -29,64 +27,21 @@ public class PictureController {
...
@@ -29,64 +27,21 @@ public class PictureController {
@Autowired
@Autowired
private
PictureService
pictureService
;
private
PictureService
pictureService
;
@PostMapping
(
"/uploadPicture"
)
@PostMapping
(
"/uploadPicture"
)
@ApiOperation
(
value
=
"图片上传"
)
@ApiOperation
(
value
=
"图片上传"
)
@ResponseBody
@ResponseBody
public
Result
uploadPicture
(
MultipartFile
file
)
{
public
Result
uploadPicture
(
MultipartFile
file
,
@RequestParam
(
name
=
"params"
)
String
params
)
{
// Map<String, Object> paramer = dataGoodsService.uploadPicture(file);
// Map<String, Object> paramer = dataGoodsService.uploadPicture(file);
Result
result
=
pictureService
.
uploadPicture
(
file
);
Result
result
=
pictureService
.
uploadPicture
(
file
,
params
);
return
result
;
return
result
;
}
}
@GetMapping
(
"/downloadPicture"
)
@GetMapping
(
"/downloadPicture"
)
@ApiOperation
(
value
=
"图片下载"
)
@ApiOperation
(
value
=
"图片下载"
)
public
Result
downloadPicture
(
@RequestParam
(
name
=
"url"
)
String
url
,
HttpServletResponse
response
)
{
public
Result
downloadPicture
(
@RequestParam
(
name
=
"url"
)
String
url
,
HttpServletResponse
response
)
{
Result
result
=
pictureService
.
downloadPicture
(
url
,
response
);
String
host
=
"192.168.1.141"
;
int
port
=
21
;
String
username
=
"ftpuser"
;
String
password
=
"9zDatacn"
;
FTPClient
ftp
=
new
FTPClient
();
String
remotePath
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"/"
)+
1
);
String
ftpUrl
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
try
{
int
reply
;
ftp
.
connect
(
host
,
port
);
// 登录
ftp
.
login
(
username
,
password
);
reply
=
ftp
.
getReplyCode
();
if
(!
FTPReply
.
isPositiveCompletion
(
reply
))
{
ftp
.
disconnect
();
}
ftp
.
enterLocalPassiveMode
();
// 到FTP服务器目录
ftp
.
changeWorkingDirectory
(
"/2021/1/12/"
);
InputStream
in
=
ftp
.
retrieveFileStream
(
ftpUrl
);
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
int
len
=
0
;
byte
[]
buffer
=
new
byte
[
1024
];
while
((
len
=
in
.
read
(
buffer
))
!=
-
1
)
{
outputStream
.
write
(
buffer
,
0
,
len
);
}
// byte[] bytes = sos.toByteArray();
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
".jpg"
);
IOUtils
.
copy
(
in
,
outputStream
);
in
.
close
();
outputStream
.
close
();
ftp
.
logout
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
ftp
.
isConnected
())
{
try
{
ftp
.
disconnect
();
}
catch
(
Exception
ioe
)
{
}
}
}
Result
result
=
new
Result
();
return
result
;
return
result
;
}
}
}
}
jz-dm-manage/src/main/java/com/jz/manage/moduls/service/PictureService.java
View file @
a1813bf4
...
@@ -3,6 +3,8 @@ package com.jz.manage.moduls.service;
...
@@ -3,6 +3,8 @@ package com.jz.manage.moduls.service;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* @ClassName:
* @ClassName:
* @Author: Carl
* @Author: Carl
...
@@ -15,12 +17,12 @@ public interface PictureService {
...
@@ -15,12 +17,12 @@ public interface PictureService {
* @param file
* @param file
* @return
* @return
*/
*/
Result
uploadPicture
(
MultipartFile
file
);
Result
uploadPicture
(
MultipartFile
file
,
String
params
);
/**
/**
* 图片下载
* 图片下载
* @param url
* @param url
* @return
* @return
*/
*/
Result
downloadPicture
(
String
url
);
Result
downloadPicture
(
String
url
,
HttpServletResponse
response
);
}
}
jz-dm-manage/src/main/java/com/jz/manage/moduls/service/impl/DataGoodsServiceImpl.java
View file @
a1813bf4
...
@@ -320,6 +320,7 @@ public class DataGoodsServiceImpl implements DataGoodsService {
...
@@ -320,6 +320,7 @@ public class DataGoodsServiceImpl implements DataGoodsService {
dataGoods
.
setAuditPerson
(
user
.
getUserId
()
+
""
);
dataGoods
.
setAuditPerson
(
user
.
getUserId
()
+
""
);
dataGoods
.
setDataType
(
dataApiUpReq
.
getApiType
());
dataGoods
.
setDataType
(
dataApiUpReq
.
getApiType
());
dataGoods
.
setUserId
(
user
.
getUserId
());
dataGoods
.
setUserId
(
user
.
getUserId
());
dataGoods
.
setDataPicture
(
dataApiUpReq
.
getDataPicture
());
dataGoods
.
setAuditStatus
(
"02"
);
dataGoods
.
setAuditStatus
(
"02"
);
dataGoods
.
setDataStatus
(
"02"
);
dataGoods
.
setDataStatus
(
"02"
);
dataGoods
.
setDelFlag
(
"N"
);
dataGoods
.
setDelFlag
(
"N"
);
...
...
jz-dm-manage/src/main/java/com/jz/manage/moduls/service/impl/PictureServiceImpl.java
View file @
a1813bf4
...
@@ -5,10 +5,18 @@ import com.jz.common.utils.RandomUtil;
...
@@ -5,10 +5,18 @@ import com.jz.common.utils.RandomUtil;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.manage.moduls.service.PictureService
;
import
com.jz.manage.moduls.service.PictureService
;
import
org.apache.commons.net.ftp.FTPClient
;
import
org.apache.commons.net.ftp.FTPReply
;
import
org.apache.tomcat.util.http.fileupload.IOUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
/**
* @ClassName:
* @ClassName:
...
@@ -18,6 +26,19 @@ import java.io.IOException;
...
@@ -18,6 +26,19 @@ import java.io.IOException;
*/
*/
@Service
(
"pictureService"
)
@Service
(
"pictureService"
)
public
class
PictureServiceImpl
implements
PictureService
{
public
class
PictureServiceImpl
implements
PictureService
{
@Value
(
"${ftp.url}"
)
private
String
ftpUrl
;
@Value
(
"${ftp.port}"
)
private
Integer
port
;
@Value
(
"${ftp.username}"
)
private
String
username
;
@Value
(
"${ftp.password}"
)
private
String
password
;
/**
/**
* 图片上传
* 图片上传
*
*
...
@@ -25,7 +46,7 @@ public class PictureServiceImpl implements PictureService {
...
@@ -25,7 +46,7 @@ public class PictureServiceImpl implements PictureService {
* @return
* @return
*/
*/
@Override
@Override
public
Result
uploadPicture
(
MultipartFile
file
)
{
public
Result
uploadPicture
(
MultipartFile
file
,
String
params
)
{
Result
result
=
new
Result
();
Result
result
=
new
Result
();
if
(
file
.
getSize
()
>
10240000
)
{
if
(
file
.
getSize
()
>
10240000
)
{
return
Result
.
of_error
(
"图片格式太大,不能超过10MB!"
);
return
Result
.
of_error
(
"图片格式太大,不能超过10MB!"
);
...
@@ -38,9 +59,15 @@ public class PictureServiceImpl implements PictureService {
...
@@ -38,9 +59,15 @@ public class PictureServiceImpl implements PictureService {
String
picture
=
RandomUtil
.
getStringRandom
(
16
)
+
extensionName
;
String
picture
=
RandomUtil
.
getStringRandom
(
16
)
+
extensionName
;
// 上传图片
// 上传图片
try
{
try
{
boolean
flag
=
FtpUtil
.
uploadFile
(
"192.168.1.141"
,
21
,
"ftpuser"
,
"9zDatacn"
,
"/"
,
"/2021/1/12"
,
picture
,
file
.
getInputStream
());
String
filePath
=
""
;
if
(
params
.
equals
(
"logo"
))
{
filePath
=
"/picture/logo"
;
}
else
if
(
params
.
equals
(
"businessLicense"
))
{
filePath
=
"/picture/businessLicense"
;
}
boolean
flag
=
FtpUtil
.
uploadFile
(
ftpUrl
,
port
,
username
,
password
,
"/"
,
filePath
,
picture
,
file
.
getInputStream
());
if
(
flag
)
{
if
(
flag
)
{
String
url
=
"/manage/downloadPicture
"
+
"/2021/1/12"
+
"/"
+
picture
;
String
url
=
"/manage/downloadPicture
?url="
+
filePath
+
"/"
+
picture
;
result
.
setData
(
url
);
result
.
setData
(
url
);
result
.
setMsg
(
"图片上传成功!"
);
result
.
setMsg
(
"图片上传成功!"
);
}
else
{
}
else
{
...
@@ -62,21 +89,51 @@ public class PictureServiceImpl implements PictureService {
...
@@ -62,21 +89,51 @@ public class PictureServiceImpl implements PictureService {
* @return
* @return
*/
*/
@Override
@Override
public
Result
downloadPicture
(
String
url
)
{
public
Result
downloadPicture
(
String
url
,
HttpServletResponse
response
)
{
String
ftpUrl
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
Result
result
=
new
Result
();
Result
result
=
new
Result
();
try
{
FTPClient
ftp
=
new
FTPClient
();
boolean
flag
=
FtpUtil
.
downloadFile
(
"192.168.1.141"
,
21
,
"ftpuser"
,
"9zDatacn"
,
"/2021/1/12/"
,
ftpUrl
,
""
);
String
catalog
=
url
.
substring
(
url
.
lastIndexOf
(
"="
)+
1
);
if
(
flag
)
{
String
remotePath
=
catalog
.
substring
(
0
,
catalog
.
lastIndexOf
(
"/"
)
+
1
);
result
.
setMsg
(
"下载成功!"
);
String
furl
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
}
else
{
String
suffix
=
catalog
.
substring
(
catalog
.
lastIndexOf
(
"."
));
result
.
setMsg
(
"下载失败!"
);
try
{
int
reply
;
ftp
.
connect
(
ftpUrl
,
port
);
// 登录
ftp
.
login
(
username
,
password
);
reply
=
ftp
.
getReplyCode
();
if
(!
FTPReply
.
isPositiveCompletion
(
reply
))
{
ftp
.
disconnect
();
}
ftp
.
enterLocalPassiveMode
();
// 到FTP服务器目录
ftp
.
changeWorkingDirectory
(
remotePath
);
InputStream
in
=
ftp
.
retrieveFileStream
(
furl
);
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
int
len
=
0
;
byte
[]
buffer
=
new
byte
[
1024
];
while
((
len
=
in
.
read
(
buffer
))
!=
-
1
)
{
outputStream
.
write
(
buffer
,
0
,
len
);
}
}
}
catch
(
Exception
e
)
{
// byte[] bytes = sos.toByteArray();
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
suffix
);
IOUtils
.
copy
(
in
,
outputStream
);
in
.
close
();
outputStream
.
close
();
ftp
.
logout
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
result
.
setMsg
(
"下载失败!"
);
}
finally
{
result
.
setCode
(
StatusCode
.
ERROR
);
if
(
ftp
.
isConnected
())
{
try
{
ftp
.
disconnect
();
}
catch
(
Exception
ioe
)
{
}
}
}
}
return
result
;
return
result
;
}
}
}
}
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