Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
84afede4
"vscode:/vscode.git/clone" did not exist on "ebdeb4c1423221434f1bc9035d23207e1a45d4be"
Commit
84afede4
authored
Aug 05, 2018
by
Menethil
Browse files
Merge remote-tracking branch 'origin/master'
parents
c480e78e
b268df0d
Changes
19
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminRegionController.java
View file @
84afede4
...
@@ -44,7 +44,7 @@ public class AdminRegionController {
...
@@ -44,7 +44,7 @@ public class AdminRegionController {
String
name
,
Integer
code
,
String
name
,
Integer
code
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"
add_time
"
)
String
sort
,
@Sort
(
accepts
={
"id"
})
@RequestParam
(
defaultValue
=
"
id
"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStorageController.java
View file @
84afede4
...
@@ -68,7 +68,7 @@ public class AdminStorageController {
...
@@ -68,7 +68,7 @@ public class AdminStorageController {
}
}
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
...
@@ -81,7 +81,7 @@ public class AdminStorageController {
...
@@ -81,7 +81,7 @@ public class AdminStorageController {
return
ResponseUtil
.
badArgumentValue
();
return
ResponseUtil
.
badArgumentValue
();
}
}
String
key
=
generateKey
(
originalFilename
);
String
key
=
generateKey
(
originalFilename
);
storageService
.
store
(
file
,
key
);
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
()
,
key
);
String
url
=
storageService
.
generateUrl
(
key
);
String
url
=
storageService
.
generateUrl
(
key
);
LitemallStorage
storageInfo
=
new
LitemallStorage
();
LitemallStorage
storageInfo
=
new
LitemallStorage
();
...
...
litemall-all/src/main/java/org/linlinjava/litemall/Application.java
View file @
84afede4
...
@@ -3,8 +3,6 @@ package org.linlinjava.litemall;
...
@@ -3,8 +3,6 @@ package org.linlinjava.litemall;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.web.support.SpringBootServletInitializer
;
@SpringBootApplication
(
scanBasePackages
=
{
@SpringBootApplication
(
scanBasePackages
=
{
"org.linlinjava.litemall"
,
"org.linlinjava.litemall"
,
...
@@ -13,12 +11,7 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
...
@@ -13,12 +11,7 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
"org.linlinjava.litemall.wx"
,
"org.linlinjava.litemall.wx"
,
"org.linlinjava.litemall.admin"
})
"org.linlinjava.litemall.admin"
})
@MapperScan
(
"org.linlinjava.litemall.db.dao"
)
@MapperScan
(
"org.linlinjava.litemall.db.dao"
)
public
class
Application
extends
SpringBootServletInitializer
{
public
class
Application
{
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
Application
.
class
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
.
run
(
Application
.
class
,
args
);
SpringApplication
.
run
(
Application
.
class
,
args
);
...
...
litemall-core/pom.xml
View file @
84afede4
...
@@ -18,31 +18,23 @@
...
@@ -18,31 +18,23 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.fasterxml.jackson.datatype
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
jackson-datatype-jsr310
</artifactId>
<artifactId>
spring-boot-starter-mail
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-context-support
</artifactId>
<artifactId>
spring-boot-starter-json
</artifactId>
<version>
RELEASE
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.sun.mail
</groupId>
<artifactId>
javax.mail
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.github.qcloudsms
</groupId>
<groupId>
com.github.qcloudsms
</groupId>
<artifactId>
qcloudsms
</artifactId>
<artifactId>
qcloudsms
</artifactId>
<version>
1.0.5
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.qcloud
</groupId>
<groupId>
com.qcloud
</groupId>
<artifactId>
cos_api
</artifactId>
<artifactId>
cos_api
</artifactId>
<version>
5.4.4
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<artifactId>
slf4j-log4j12
</artifactId>
<artifactId>
slf4j-log4j12
</artifactId>
...
@@ -54,7 +46,6 @@
...
@@ -54,7 +46,6 @@
<dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.5.0
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<artifactId>
commons-lang
</artifactId>
<artifactId>
commons-lang
</artifactId>
...
@@ -67,25 +58,13 @@
...
@@ -67,25 +58,13 @@
<groupId>
com.github.binarywang
</groupId>
<groupId>
com.github.binarywang
</groupId>
<artifactId>
weixin-java-miniapp
</artifactId>
<artifactId>
weixin-java-miniapp
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.linlinjava
</groupId>
<artifactId>
litemall-db
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
com.github.binarywang
</groupId>
<groupId>
com.github.binarywang
</groupId>
<artifactId>
weixin-java-pay
</artifactId>
<artifactId>
weixin-java-pay
</artifactId>
<version>
3.0.0
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<groupId>
org.linlinjava
</groupId>
<artifactId>
spring-test
</artifactId>
<artifactId>
litemall-db
</artifactId>
<version>
5.0.7.RELEASE
</version>
<scope>
compile
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeService.java
View file @
84afede4
...
@@ -7,9 +7,7 @@ import org.linlinjava.litemall.core.system.SystemConfig;
...
@@ -7,9 +7,7 @@ import org.linlinjava.litemall.core.system.SystemConfig;
import
org.linlinjava.litemall.db.domain.LitemallGroupon
;
import
org.linlinjava.litemall.db.domain.LitemallGroupon
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.*
;
...
@@ -65,9 +63,9 @@ public class QCodeService {
...
@@ -65,9 +63,9 @@ public class QCodeService {
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
//将商品图片,商品名字,商城名字画到模版图中
//将商品图片,商品名字,商城名字画到模版图中
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
,
SystemConfig
.
getMallName
());
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
,
SystemConfig
.
getMallName
());
MultipartFile
multipartFile
=
new
MockMultipartFile
(
file
.
getName
(),
file
.
getName
(),
"image/jpeg"
,
imageData
);
ByteArrayInputStream
inputStream2
=
new
ByteArrayInputStream
(
imageData
);
//存储分享图
//存储分享图
storageService
.
store
(
multipartFile
,
getKeyName
(
goodId
));
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
goodId
));
}
catch
(
WxErrorException
e
)
{
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/AliyunStorage.java
View file @
84afede4
...
@@ -6,8 +6,8 @@ import com.aliyun.oss.model.PutObjectRequest;
...
@@ -6,8 +6,8 @@ import com.aliyun.oss.model.PutObjectRequest;
import
com.aliyun.oss.model.PutObjectResult
;
import
com.aliyun.oss.model.PutObjectResult
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
...
@@ -74,14 +74,14 @@ public class AliyunStorage implements Storage {
...
@@ -74,14 +74,14 @@ public class AliyunStorage implements Storage {
* 阿里云OSS对象存储简单上传实现
* 阿里云OSS对象存储简单上传实现
*/
*/
@Override
@Override
public
void
store
(
MultipartFile
fil
e
,
String
keyName
)
{
public
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentTyp
e
,
String
keyName
)
{
try
{
try
{
// 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20M以下的文件使用该接口
// 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20M以下的文件使用该接口
ObjectMetadata
objectMetadata
=
new
ObjectMetadata
();
ObjectMetadata
objectMetadata
=
new
ObjectMetadata
();
objectMetadata
.
setContentLength
(
file
.
getSize
()
);
objectMetadata
.
setContentLength
(
contentLength
);
objectMetadata
.
setContentType
(
file
.
getC
ontentType
()
);
objectMetadata
.
setContentType
(
c
ontentType
);
// 对象键(Key)是对象在存储桶中的唯一标识。
// 对象键(Key)是对象在存储桶中的唯一标识。
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
keyName
,
file
.
getI
nputStream
()
,
objectMetadata
);
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
keyName
,
i
nputStream
,
objectMetadata
);
PutObjectResult
putObjectResult
=
getOSSClient
().
putObject
(
putObjectRequest
);
PutObjectResult
putObjectResult
=
getOSSClient
().
putObject
(
putObjectRequest
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/LocalStorage.java
View file @
84afede4
...
@@ -3,9 +3,9 @@ package org.linlinjava.litemall.core.storage;
...
@@ -3,9 +3,9 @@ package org.linlinjava.litemall.core.storage;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
...
@@ -47,9 +47,9 @@ public class LocalStorage implements Storage {
...
@@ -47,9 +47,9 @@ public class LocalStorage implements Storage {
}
}
@Override
@Override
public
void
store
(
MultipartFile
fil
e
,
String
keyName
)
{
public
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentTyp
e
,
String
keyName
)
{
try
{
try
{
Files
.
copy
(
file
.
getI
nputStream
()
,
rootLocation
.
resolve
(
keyName
),
StandardCopyOption
.
REPLACE_EXISTING
);
Files
.
copy
(
i
nputStream
,
rootLocation
.
resolve
(
keyName
),
StandardCopyOption
.
REPLACE_EXISTING
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"Failed to store file "
+
keyName
,
e
);
throw
new
RuntimeException
(
"Failed to store file "
+
keyName
,
e
);
}
}
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/Storage.java
View file @
84afede4
package
org.linlinjava.litemall.core.storage
;
package
org.linlinjava.litemall.core.storage
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.InputStream
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
...
@@ -13,10 +13,12 @@ public interface Storage {
...
@@ -13,10 +13,12 @@ public interface Storage {
/**
/**
* 存储一个文件对象
* 存储一个文件对象
* @param file SpringBoot MultipartFile文件对象
* @param inputStream 文件输入流
* @param contentLength 文件长度
* @param contentType 文件类型
* @param keyName 文件索引名
* @param keyName 文件索引名
*/
*/
void
store
(
MultipartFile
fil
e
,
String
keyName
);
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentTyp
e
,
String
keyName
);
Stream
<
Path
>
loadAll
();
Stream
<
Path
>
loadAll
();
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java
View file @
84afede4
...
@@ -3,6 +3,7 @@ package org.linlinjava.litemall.core.storage;
...
@@ -3,6 +3,7 @@ package org.linlinjava.litemall.core.storage;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.InputStream
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
...
@@ -31,12 +32,13 @@ public class StorageService {
...
@@ -31,12 +32,13 @@ public class StorageService {
/**
/**
* 存储一个文件对象
* 存储一个文件对象
*
* @param inputStream 文件输入流
* @param file SpringBoot MultipartFile文件对象
* @param contentLength 文件长度
* @param keyName 文件索引名
* @param contentType 文件类型
* @param keyName 文件索引名
*/
*/
public
void
store
(
MultipartFile
fil
e
,
String
keyName
)
{
public
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentTyp
e
,
String
keyName
)
{
storage
.
store
(
fil
e
,
keyName
);
storage
.
store
(
inputStream
,
contentLength
,
contentTyp
e
,
keyName
);
}
}
public
Stream
<
Path
>
loadAll
()
{
public
Stream
<
Path
>
loadAll
()
{
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/TencentStorage.java
View file @
84afede4
...
@@ -8,13 +8,10 @@ import com.qcloud.cos.model.ObjectMetadata;
...
@@ -8,13 +8,10 @@ import com.qcloud.cos.model.ObjectMetadata;
import
com.qcloud.cos.model.PutObjectRequest
;
import
com.qcloud.cos.model.PutObjectRequest
;
import
com.qcloud.cos.model.PutObjectResult
;
import
com.qcloud.cos.model.PutObjectResult
;
import
com.qcloud.cos.region.Region
;
import
com.qcloud.cos.region.Region
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
...
@@ -81,14 +78,14 @@ public class TencentStorage implements Storage {
...
@@ -81,14 +78,14 @@ public class TencentStorage implements Storage {
}
}
@Override
@Override
public
void
store
(
MultipartFile
fil
e
,
String
keyName
)
{
public
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentTyp
e
,
String
keyName
)
{
try
{
try
{
// 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20M以下的文件使用该接口
// 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20M以下的文件使用该接口
ObjectMetadata
objectMetadata
=
new
ObjectMetadata
();
ObjectMetadata
objectMetadata
=
new
ObjectMetadata
();
objectMetadata
.
setContentLength
(
file
.
getSize
()
);
objectMetadata
.
setContentLength
(
contentLength
);
objectMetadata
.
setContentType
(
file
.
getC
ontentType
()
);
objectMetadata
.
setContentType
(
c
ontentType
);
// 对象键(Key)是对象在存储桶中的唯一标识。例如,在对象的访问域名 `bucket1-1250000000.cos.ap-guangzhou.myqcloud.com/doc1/pic1.jpg` 中,对象键为 doc1/pic1.jpg, 详情参考 [对象键](https://cloud.tencent.com/document/product/436/13324)
// 对象键(Key)是对象在存储桶中的唯一标识。例如,在对象的访问域名 `bucket1-1250000000.cos.ap-guangzhou.myqcloud.com/doc1/pic1.jpg` 中,对象键为 doc1/pic1.jpg, 详情参考 [对象键](https://cloud.tencent.com/document/product/436/13324)
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
keyName
,
file
.
getI
nputStream
()
,
objectMetadata
);
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
keyName
,
i
nputStream
,
objectMetadata
);
PutObjectResult
putObjectResult
=
getCOSClient
().
putObject
(
putObjectRequest
);
PutObjectResult
putObjectResult
=
getCOSClient
().
putObject
(
putObjectRequest
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/util/YmlPropertyFactory.java
deleted
100644 → 0
View file @
c480e78e
package
org.linlinjava.litemall.core.util
;
import
org.springframework.boot.env.PropertySourcesLoader
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.EncodedResource
;
import
org.springframework.core.io.support.PropertySourceFactory
;
import
java.io.IOException
;
/**
* 某些情况下外部依赖导致 yaml 配置未能正确注入时,@PropertySource(value = {"classpath:application-wx.yaml"}, factory = YmlPropertyFactory.class) 手动注入配置文件
*/
public
class
YmlPropertyFactory
implements
PropertySourceFactory
{
@Override
public
PropertySource
<?>
createPropertySource
(
String
name
,
EncodedResource
resource
)
throws
IOException
{
return
name
!=
null
?
new
PropertySourcesLoader
().
load
(
resource
.
getResource
(),
name
,
null
)
:
new
PropertySourcesLoader
().
load
(
resource
.
getResource
(),
getNameForResource
(
resource
.
getResource
()),
null
);
}
private
static
String
getNameForResource
(
Resource
resource
)
{
String
name
=
resource
.
getDescription
();
if
(!
org
.
springframework
.
util
.
StringUtils
.
hasText
(
name
))
{
name
=
resource
.
getClass
().
getSimpleName
()
+
"@"
+
System
.
identityHashCode
(
resource
);
}
return
name
;
}
}
litemall-core/src/main/resources/application.yml
View file @
84afede4
spring
:
spring
:
profiles
:
profiles
:
active
:
core
active
:
core
, db
message
:
message
:
encoding
:
UTF-8
encoding
:
UTF-8
...
...
litemall-core/src/test/java/org/linlinjava/litemall/core/AliyunStorageTest.java
View file @
84afede4
...
@@ -11,6 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...
@@ -11,6 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.FileCopyUtils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -24,9 +25,8 @@ public class AliyunStorageTest {
...
@@ -24,9 +25,8 @@ public class AliyunStorageTest {
@Test
@Test
public
void
test
()
throws
IOException
{
public
void
test
()
throws
IOException
{
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
byte
[]
content
=
(
byte
[])
FileCopyUtils
.
copyToByteArray
(
new
FileInputStream
(
test
));
File
testFile
=
new
File
(
test
);
MockMultipartFile
mockMultipartFile
=
new
MockMultipartFile
(
"litemall.png"
,
"litemall.png"
,
"image/png"
,
content
);
aliyunStorage
.
store
(
new
FileInputStream
(
test
),
testFile
.
length
(),
"image/png"
,
"litemall.png"
);
aliyunStorage
.
store
(
mockMultipartFile
,
"litemall.png"
);
Resource
resource
=
aliyunStorage
.
loadAsResource
(
"litemall.png"
);
Resource
resource
=
aliyunStorage
.
loadAsResource
(
"litemall.png"
);
String
url
=
aliyunStorage
.
generateUrl
(
"litemall.png"
);
String
url
=
aliyunStorage
.
generateUrl
(
"litemall.png"
);
System
.
out
.
println
(
"test file "
+
test
);
System
.
out
.
println
(
"test file "
+
test
);
...
...
litemall-core/src/test/java/org/linlinjava/litemall/core/LocalStorageTest.java
View file @
84afede4
...
@@ -6,11 +6,9 @@ import org.linlinjava.litemall.core.storage.LocalStorage;
...
@@ -6,11 +6,9 @@ import org.linlinjava.litemall.core.storage.LocalStorage;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.util.FileCopyUtils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -24,9 +22,8 @@ public class LocalStorageTest {
...
@@ -24,9 +22,8 @@ public class LocalStorageTest {
@Test
@Test
public
void
test
()
throws
IOException
{
public
void
test
()
throws
IOException
{
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
byte
[]
content
=
(
byte
[])
FileCopyUtils
.
copyToByteArray
(
new
FileInputStream
(
test
));
File
testFile
=
new
File
(
test
);
MockMultipartFile
mockMultipartFile
=
new
MockMultipartFile
(
"litemall.png"
,
"litemall.png"
,
"image/jpeg"
,
content
);
localStorage
.
store
(
new
FileInputStream
(
test
),
testFile
.
length
(),
"image/png"
,
"litemall.png"
);
localStorage
.
store
(
mockMultipartFile
,
"litemall.png"
);
Resource
resource
=
localStorage
.
loadAsResource
(
"litemall.png"
);
Resource
resource
=
localStorage
.
loadAsResource
(
"litemall.png"
);
String
url
=
localStorage
.
generateUrl
(
"litemall.png"
);
String
url
=
localStorage
.
generateUrl
(
"litemall.png"
);
System
.
out
.
println
(
"test file "
+
test
);
System
.
out
.
println
(
"test file "
+
test
);
...
...
litemall-core/src/test/java/org/linlinjava/litemall/core/TencentStorageTest.java
View file @
84afede4
...
@@ -6,11 +6,10 @@ import org.linlinjava.litemall.core.storage.TencentStorage;
...
@@ -6,11 +6,10 @@ import org.linlinjava.litemall.core.storage.TencentStorage;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.util.FileCopyUtils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -24,9 +23,8 @@ public class TencentStorageTest {
...
@@ -24,9 +23,8 @@ public class TencentStorageTest {
@Test
@Test
public
void
test
()
throws
IOException
{
public
void
test
()
throws
IOException
{
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
String
test
=
getClass
().
getClassLoader
().
getResource
(
"litemall.png"
).
getFile
();
byte
[]
content
=
(
byte
[])
FileCopyUtils
.
copyToByteArray
(
new
FileInputStream
(
test
));
File
testFile
=
new
File
(
test
);
MockMultipartFile
mockMultipartFile
=
new
MockMultipartFile
(
"litemall.png"
,
"litemall.png"
,
"image/png"
,
content
);
tencentStorage
.
store
(
new
FileInputStream
(
test
),
testFile
.
length
(),
"image/png"
,
"litemall.png"
);
tencentStorage
.
store
(
mockMultipartFile
,
"litemall.png"
);
Resource
resource
=
tencentStorage
.
loadAsResource
(
"litemall.png"
);
Resource
resource
=
tencentStorage
.
loadAsResource
(
"litemall.png"
);
String
url
=
tencentStorage
.
generateUrl
(
"litemall.png"
);
String
url
=
tencentStorage
.
generateUrl
(
"litemall.png"
);
System
.
out
.
println
(
"test file "
+
test
);
System
.
out
.
println
(
"test file "
+
test
);
...
...
litemall-db/pom.xml
View file @
84afede4
...
@@ -12,6 +12,11 @@
...
@@ -12,6 +12,11 @@
<dependencies>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-json
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
...
@@ -32,11 +37,6 @@
...
@@ -32,11 +37,6 @@
<artifactId>
druid-spring-boot-starter
</artifactId>
<artifactId>
druid-spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
</dependencies>
</dependencies>
...
...
litemall-db/src/main/resources/application-db.yml
View file @
84afede4
...
@@ -22,5 +22,5 @@ spring:
...
@@ -22,5 +22,5 @@ spring:
test-on-return
:
false
test-on-return
:
false
test-while-idle
:
true
test-while-idle
:
true
time-between-eviction-runs-millis
:
60000
time-between-eviction-runs-millis
:
60000
filters
:
stat,wall
,log4j
filters
:
stat,wall
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java
View file @
84afede4
...
@@ -48,7 +48,7 @@ public class WxStorageController {
...
@@ -48,7 +48,7 @@ public class WxStorageController {
}
}
@PostMapping
(
"/upload"
)
@PostMapping
(
"/upload"
)
public
Object
upload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
public
Object
upload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
String
originalFilename
=
file
.
getOriginalFilename
();
String
originalFilename
=
file
.
getOriginalFilename
();
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
;
try
{
try
{
...
@@ -58,7 +58,7 @@ public class WxStorageController {
...
@@ -58,7 +58,7 @@ public class WxStorageController {
return
ResponseUtil
.
badArgumentValue
();
return
ResponseUtil
.
badArgumentValue
();
}
}
String
key
=
generateKey
(
originalFilename
);
String
key
=
generateKey
(
originalFilename
);
storageService
.
store
(
file
,
key
);
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
()
,
key
);
String
url
=
storageService
.
generateUrl
(
key
);
String
url
=
storageService
.
generateUrl
(
key
);
LitemallStorage
storageInfo
=
new
LitemallStorage
();
LitemallStorage
storageInfo
=
new
LitemallStorage
();
...
...
pom.xml
View file @
84afede4
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
1.5.12
.RELEASE
</version>
<version>
2.0.4
.RELEASE
</version>
<relativePath/>
<relativePath/>
</parent>
</parent>
...
@@ -55,12 +55,6 @@
...
@@ -55,12 +55,6 @@
<version>
${project.version}
</version>
<version>
${project.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.datatype
</groupId>
<artifactId>
jackson-datatype-jsr310
</artifactId>
<version>
2.9.5
</version>
</dependency>
<!-- Spring Boot Mybatis 依赖 -->
<!-- Spring Boot Mybatis 依赖 -->
<dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<groupId>
org.mybatis.spring.boot
</groupId>
...
@@ -85,7 +79,7 @@
...
@@ -85,7 +79,7 @@
<dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.
9
</version>
<version>
1.1.
10
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
@@ -99,6 +93,36 @@
...
@@ -99,6 +93,36 @@
<artifactId>
weixin-java-miniapp
</artifactId>
<artifactId>
weixin-java-miniapp
</artifactId>
<version>
3.1.0
</version>
<version>
3.1.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.github.qcloudsms
</groupId>
<artifactId>
qcloudsms
</artifactId>
<version>
1.0.5
</version>
</dependency>
<dependency>
<groupId>
com.qcloud
</groupId>
<artifactId>
cos_api
</artifactId>
<version>
5.4.4
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-json
</artifactId>
<version>
2.0.4.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-mail
</artifactId>
<version>
2.0.4.RELEASE
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
Write
Preview
Supports
Markdown
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