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
Eladmin
Commits
f0211db0
"...src/main/git@ustchcs.com:gujinli1118/eladmin.git" did not exist on "905c8c649c3af675275200db5443e49cc13f6a6b"
Commit
f0211db0
authored
Oct 24, 2019
by
dqjdda
Browse files
优化代码
parent
a8230bbd
Changes
58
Hide whitespace changes
Inline
Side-by-side
eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java
View file @
f0211db0
package
me.zhengjie.rest
;
package
me.zhengjie.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.domain.Picture
;
import
me.zhengjie.domain.Picture
;
import
me.zhengjie.service.PictureService
;
import
me.zhengjie.service.PictureService
;
import
me.zhengjie.service.dto.PictureQueryCriteria
;
import
me.zhengjie.service.dto.PictureQueryCriteria
;
import
me.zhengjie.utils.SecurityUtils
;
import
me.zhengjie.utils.SecurityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
...
@@ -20,28 +21,28 @@ import java.util.Map;
...
@@ -20,28 +21,28 @@ import java.util.Map;
* @date 2018/09/20 14:13:32
* @date 2018/09/20 14:13:32
*/
*/
@RestController
@RestController
@RequestMapping
(
"/api"
)
@RequestMapping
(
"/api/pictures"
)
@Api
(
tags
=
"免费图床管理"
)
public
class
PictureController
{
public
class
PictureController
{
@Autowired
private
final
PictureService
pictureService
;
private
PictureService
pictureService
;
public
PictureController
(
PictureService
pictureService
)
{
this
.
pictureService
=
pictureService
;
}
@Log
(
"查询图片"
)
@Log
(
"查询图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_SELECT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_SELECT')"
)
@GetMapping
(
value
=
"/pictures"
)
@GetMapping
@ApiOperation
(
value
=
"查询图片"
)
public
ResponseEntity
getRoles
(
PictureQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
getRoles
(
PictureQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
pictureService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
pictureService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
/**
* 上传图片
* @param file
* @return
* @throws Exception
*/
@Log
(
"上传图片"
)
@Log
(
"上传图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_UPLOAD')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_UPLOAD')"
)
@PostMapping
(
value
=
"/pictures"
)
@PostMapping
@ApiOperation
(
value
=
"上传图片"
)
public
ResponseEntity
upload
(
@RequestParam
MultipartFile
file
){
public
ResponseEntity
upload
(
@RequestParam
MultipartFile
file
){
String
userName
=
SecurityUtils
.
getUsername
();
String
userName
=
SecurityUtils
.
getUsername
();
Picture
picture
=
pictureService
.
upload
(
file
,
userName
);
Picture
picture
=
pictureService
.
upload
(
file
,
userName
);
...
@@ -49,30 +50,22 @@ public class PictureController {
...
@@ -49,30 +50,22 @@ public class PictureController {
map
.
put
(
"errno"
,
0
);
map
.
put
(
"errno"
,
0
);
map
.
put
(
"id"
,
picture
.
getId
());
map
.
put
(
"id"
,
picture
.
getId
());
map
.
put
(
"data"
,
new
String
[]{
picture
.
getUrl
()});
map
.
put
(
"data"
,
new
String
[]{
picture
.
getUrl
()});
return
new
ResponseEntity
(
map
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
map
,
HttpStatus
.
OK
);
}
}
/**
* 删除图片
* @param id
* @return
*/
@Log
(
"删除图片"
)
@Log
(
"删除图片"
)
@ApiOperation
(
value
=
"删除图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@DeleteMapping
(
value
=
"/
pictures/
{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
)
{
public
ResponseEntity
delete
(
@PathVariable
Long
id
)
{
pictureService
.
delete
(
pictureService
.
findById
(
id
));
pictureService
.
delete
(
pictureService
.
findById
(
id
));
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
/**
@Log
(
"多选删除图片"
)
* 删除多张图片
@ApiOperation
(
value
=
"多选删除图片"
)
* @param ids
* @return
*/
@Log
(
"删除图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@DeleteMapping
(
value
=
"/pictures"
)
@DeleteMapping
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
pictureService
.
deleteAll
(
ids
);
pictureService
.
deleteAll
(
ids
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java
View file @
f0211db0
package
me.zhengjie.rest
;
package
me.zhengjie.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.domain.QiniuConfig
;
import
me.zhengjie.domain.QiniuConfig
;
import
me.zhengjie.domain.QiniuContent
;
import
me.zhengjie.domain.QiniuContent
;
import
me.zhengjie.service.QiNiuService
;
import
me.zhengjie.service.QiNiuService
;
import
me.zhengjie.service.dto.QiniuQueryCriteria
;
import
me.zhengjie.service.dto.QiniuQueryCriteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
...
@@ -24,17 +25,22 @@ import java.util.Map;
...
@@ -24,17 +25,22 @@ import java.util.Map;
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"api"
)
@Api
(
tags
=
"七牛云存储管理"
)
public
class
QiniuController
{
public
class
QiniuController
{
@Autowired
private
final
QiNiuService
qiNiuService
;
private
QiNiuService
qiNiuService
;
public
QiniuController
(
QiNiuService
qiNiuService
)
{
this
.
qiNiuService
=
qiNiuService
;
}
@GetMapping
(
value
=
"/qiNiuConfig"
)
@GetMapping
(
value
=
"/qiNiuConfig"
)
public
ResponseEntity
get
(){
public
ResponseEntity
get
(){
return
new
ResponseEntity
(
qiNiuService
.
find
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
qiNiuService
.
find
(),
HttpStatus
.
OK
);
}
}
@Log
(
"配置七牛云存储"
)
@Log
(
"配置七牛云存储"
)
@ApiOperation
(
value
=
"配置七牛云存储"
)
@PutMapping
(
value
=
"/qiNiuConfig"
)
@PutMapping
(
value
=
"/qiNiuConfig"
)
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
QiniuConfig
qiniuConfig
){
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
QiniuConfig
qiniuConfig
){
qiNiuService
.
update
(
qiniuConfig
);
qiNiuService
.
update
(
qiniuConfig
);
...
@@ -43,72 +49,51 @@ public class QiniuController {
...
@@ -43,72 +49,51 @@ public class QiniuController {
}
}
@Log
(
"查询文件"
)
@Log
(
"查询文件"
)
@ApiOperation
(
value
=
"查询文件"
)
@GetMapping
(
value
=
"/qiNiuContent"
)
@GetMapping
(
value
=
"/qiNiuContent"
)
public
ResponseEntity
getRoles
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
getRoles
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
qiNiuService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
qiNiuService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
/**
* 上传文件到七牛云
* @param file
* @return
*/
@Log
(
"上传文件"
)
@Log
(
"上传文件"
)
@ApiOperation
(
value
=
"上传文件"
)
@PostMapping
(
value
=
"/qiNiuContent"
)
@PostMapping
(
value
=
"/qiNiuContent"
)
public
ResponseEntity
upload
(
@RequestParam
MultipartFile
file
){
public
ResponseEntity
upload
(
@RequestParam
MultipartFile
file
){
QiniuContent
qiniuContent
=
qiNiuService
.
upload
(
file
,
qiNiuService
.
find
());
QiniuContent
qiniuContent
=
qiNiuService
.
upload
(
file
,
qiNiuService
.
find
());
Map
map
=
new
HashMap
(
3
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>
(
3
);
map
.
put
(
"id"
,
qiniuContent
.
getId
());
map
.
put
(
"id"
,
qiniuContent
.
getId
());
map
.
put
(
"errno"
,
0
);
map
.
put
(
"errno"
,
0
);
map
.
put
(
"data"
,
new
String
[]{
qiniuContent
.
getUrl
()});
map
.
put
(
"data"
,
new
String
[]{
qiniuContent
.
getUrl
()});
return
new
ResponseEntity
(
map
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
map
,
HttpStatus
.
OK
);
}
}
/**
* 同步七牛云数据到数据库
* @return
*/
@Log
(
"同步七牛云数据"
)
@Log
(
"同步七牛云数据"
)
@ApiOperation
(
value
=
"同步七牛云数据"
)
@PostMapping
(
value
=
"/qiNiuContent/synchronize"
)
@PostMapping
(
value
=
"/qiNiuContent/synchronize"
)
public
ResponseEntity
synchronize
(){
public
ResponseEntity
synchronize
(){
log
.
warn
(
"REST request to synchronize qiNiu : {}"
);
qiNiuService
.
synchronize
(
qiNiuService
.
find
());
qiNiuService
.
synchronize
(
qiNiuService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
/**
* 下载七牛云文件
* @param id
* @return
* @throws Exception
*/
@Log
(
"下载文件"
)
@Log
(
"下载文件"
)
@ApiOperation
(
value
=
"下载文件"
)
@GetMapping
(
value
=
"/qiNiuContent/download/{id}"
)
@GetMapping
(
value
=
"/qiNiuContent/download/{id}"
)
public
ResponseEntity
download
(
@PathVariable
Long
id
){
public
ResponseEntity
download
(
@PathVariable
Long
id
){
Map
map
=
new
HashMap
(
1
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>
(
1
);
map
.
put
(
"url"
,
qiNiuService
.
download
(
qiNiuService
.
findByContentId
(
id
),
qiNiuService
.
find
()));
map
.
put
(
"url"
,
qiNiuService
.
download
(
qiNiuService
.
findByContentId
(
id
),
qiNiuService
.
find
()));
return
new
ResponseEntity
(
map
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
map
,
HttpStatus
.
OK
);
}
}
/**
* 删除七牛云文件
* @param id
* @return
* @throws Exception
*/
@Log
(
"删除文件"
)
@Log
(
"删除文件"
)
@ApiOperation
(
value
=
"删除文件"
)
@DeleteMapping
(
value
=
"/qiNiuContent/{id}"
)
@DeleteMapping
(
value
=
"/qiNiuContent/{id}"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
qiNiuService
.
delete
(
qiNiuService
.
findByContentId
(
id
),
qiNiuService
.
find
());
qiNiuService
.
delete
(
qiNiuService
.
findByContentId
(
id
),
qiNiuService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
/**
@Log
(
"删除多张图片"
)
* 删除多张图片
@ApiOperation
(
value
=
"删除多张图片"
)
* @param ids
* @return
*/
@Log
(
"删除图片"
)
@DeleteMapping
(
value
=
"/qiNiuContent"
)
@DeleteMapping
(
value
=
"/qiNiuContent"
)
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
qiNiuService
.
deleteAll
(
ids
,
qiNiuService
.
find
());
qiNiuService
.
deleteAll
(
ids
,
qiNiuService
.
find
());
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java
View file @
f0211db0
package
me.zhengjie.rest
;
package
me.zhengjie.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.domain.VerificationCode
;
import
me.zhengjie.domain.VerificationCode
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.service.EmailService
;
import
me.zhengjie.service.EmailService
;
import
me.zhengjie.service.VerificationCodeService
;
import
me.zhengjie.service.VerificationCodeService
;
import
me.zhengjie.utils.ElAdminConstant
;
import
me.zhengjie.utils.ElAdminConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
...
@@ -18,19 +19,20 @@ import org.springframework.web.bind.annotation.*;
...
@@ -18,19 +19,20 @@ import org.springframework.web.bind.annotation.*;
*/
*/
@RestController
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"api"
)
@Api
(
tags
=
"验证码管理"
)
public
class
VerificationCodeController
{
public
class
VerificationCodeController
{
@Autowired
private
final
VerificationCodeService
verificationCodeService
;
private
VerificationCodeService
verificationCodeService
;
@Autowired
private
final
EmailService
emailService
;
@Qualifier
(
"jwtUserDetailsService"
)
private
UserDetailsService
userDetailsService
;
@Autowired
public
VerificationCodeController
(
VerificationCodeService
verificationCodeService
,
@Qualifier
(
"jwtUserDetailsService"
)
UserDetailsService
userDetailsService
,
EmailService
emailService
)
{
private
EmailService
emailService
;
this
.
verificationCodeService
=
verificationCodeService
;
this
.
emailService
=
emailService
;
}
@PostMapping
(
value
=
"/code/resetEmail"
)
@PostMapping
(
value
=
"/code/resetEmail"
)
@ApiOperation
(
value
=
"重置邮箱,发送验证码"
)
public
ResponseEntity
resetEmail
(
@RequestBody
VerificationCode
code
)
throws
Exception
{
public
ResponseEntity
resetEmail
(
@RequestBody
VerificationCode
code
)
throws
Exception
{
code
.
setScenes
(
ElAdminConstant
.
RESET_MAIL
);
code
.
setScenes
(
ElAdminConstant
.
RESET_MAIL
);
EmailVo
emailVo
=
verificationCodeService
.
sendEmail
(
code
);
EmailVo
emailVo
=
verificationCodeService
.
sendEmail
(
code
);
...
@@ -39,6 +41,7 @@ public class VerificationCodeController {
...
@@ -39,6 +41,7 @@ public class VerificationCodeController {
}
}
@PostMapping
(
value
=
"/code/email/resetPass"
)
@PostMapping
(
value
=
"/code/email/resetPass"
)
@ApiOperation
(
value
=
"重置密码,发送验证码"
)
public
ResponseEntity
resetPass
(
@RequestParam
String
email
)
throws
Exception
{
public
ResponseEntity
resetPass
(
@RequestParam
String
email
)
throws
Exception
{
VerificationCode
code
=
new
VerificationCode
();
VerificationCode
code
=
new
VerificationCode
();
code
.
setType
(
"email"
);
code
.
setType
(
"email"
);
...
@@ -50,6 +53,7 @@ public class VerificationCodeController {
...
@@ -50,6 +53,7 @@ public class VerificationCodeController {
}
}
@GetMapping
(
value
=
"/code/validated"
)
@GetMapping
(
value
=
"/code/validated"
)
@ApiOperation
(
value
=
"验证码验证"
)
public
ResponseEntity
validated
(
VerificationCode
code
){
public
ResponseEntity
validated
(
VerificationCode
code
){
verificationCodeService
.
validated
(
code
);
verificationCodeService
.
validated
(
code
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-tools/src/main/java/me/zhengjie/service/AlipayService.java
View file @
f0211db0
...
@@ -15,33 +15,33 @@ public interface AlipayService {
...
@@ -15,33 +15,33 @@ public interface AlipayService {
/**
/**
* 处理来自PC的交易请求
* 处理来自PC的交易请求
* @param alipay
* @param alipay
支付宝配置
* @param trade
* @param trade
交易详情
* @return
* @return
String
* @throws Exception
* @throws Exception
异常
*/
*/
String
toPayAsPC
(
AlipayConfig
alipay
,
TradeVo
trade
)
throws
Exception
;
String
toPayAsPC
(
AlipayConfig
alipay
,
TradeVo
trade
)
throws
Exception
;
/**
/**
* 处理来自手机网页的交易请求
* 处理来自手机网页的交易请求
* @param alipay
* @param alipay
支付宝配置
* @param trade
* @param trade
交易详情
* @return
* @return
String
* @throws Exception
* @throws Exception
异常
*/
*/
String
toPayAsWeb
(
AlipayConfig
alipay
,
TradeVo
trade
)
throws
Exception
;
String
toPayAsWeb
(
AlipayConfig
alipay
,
TradeVo
trade
)
throws
Exception
;
/**
/**
* 查询配置
* 查询配置
* @return
* @return
AlipayConfig
*/
*/
@Cacheable
(
key
=
"'1'"
)
@Cacheable
(
key
=
"'1'"
)
AlipayConfig
find
();
AlipayConfig
find
();
/**
/**
* 更新配置
* 更新配置
* @param alipayConfig
* @param alipayConfig
支付宝配置
* @return
* @return
AlipayConfig
*/
*/
@CachePut
(
key
=
"'1'"
)
@CachePut
(
key
=
"'1'"
)
AlipayConfig
update
(
AlipayConfig
alipayConfig
);
AlipayConfig
update
(
AlipayConfig
alipayConfig
);
...
...
eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java
View file @
f0211db0
...
@@ -16,24 +16,24 @@ public interface EmailService {
...
@@ -16,24 +16,24 @@ public interface EmailService {
/**
/**
* 更新邮件配置
* 更新邮件配置
* @param emailConfig
* @param emailConfig
邮件配置
* @param old
* @param old
旧的配置
* @return
* @return
EmailConfig
*/
*/
@CachePut
(
key
=
"'1'"
)
@CachePut
(
key
=
"'1'"
)
EmailConfig
update
(
EmailConfig
emailConfig
,
EmailConfig
old
);
EmailConfig
update
(
EmailConfig
emailConfig
,
EmailConfig
old
);
/**
/**
* 查询配置
* 查询配置
* @return
* @return
EmailConfig 邮件配置
*/
*/
@Cacheable
(
key
=
"'1'"
)
@Cacheable
(
key
=
"'1'"
)
EmailConfig
find
();
EmailConfig
find
();
/**
/**
* 发送邮件
* 发送邮件
* @param emailVo
* @param emailVo
邮件发送的内容
* @param emailConfig
* @param emailConfig
邮件配置
* @throws Exception
* @throws Exception
*/
*/
@Async
@Async
...
...
eladmin-tools/src/main/java/me/zhengjie/service/LocalStorageService.java
View file @
f0211db0
...
@@ -18,52 +18,56 @@ public interface LocalStorageService {
...
@@ -18,52 +18,56 @@ public interface LocalStorageService {
/**
/**
* queryAll 分页
* queryAll 分页
* @param criteria
* @param criteria
条件参数
* @param pageable
* @param pageable
分页参数
* @return
* @return
Object
*/
*/
@Cacheable
@Cacheable
Object
queryAll
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
);
/**
/**
* queryAll 不分页
* queryAll 不分页
* @param criteria
* @param criteria
条件参数
* @return
* @return
Object
*/
*/
@Cacheable
@Cacheable
public
Object
queryAll
(
LocalStorageQueryCriteria
criteria
);
Object
queryAll
(
LocalStorageQueryCriteria
criteria
);
/**
/**
* findById
* findById
* @param id
* @param id
* @return
* @return
LocalStorageDTO
*/
*/
@Cacheable
(
key
=
"#p0"
)
@Cacheable
(
key
=
"#p0"
)
LocalStorageDTO
findById
(
Long
id
);
LocalStorageDTO
findById
(
Long
id
);
/**
/**
* create
* create
* @param name
* @param name
文件名称
* @param file
* @param file
文件资源
* @return
* @return
LocalStorageDTO
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
LocalStorageDTO
create
(
String
name
,
MultipartFile
file
);
LocalStorageDTO
create
(
String
name
,
MultipartFile
file
);
/**
/**
* update
* update
* @param resources
* @param resources
资源实体
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
update
(
LocalStorage
resources
);
void
update
(
LocalStorage
resources
);
/**
/**
* delete
* delete
* @param id
* @param id
文件ID
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
void
delete
(
Long
id
);
/**
* 多文件删除
* @param ids 文件数组
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
deleteAll
(
Long
[]
ids
);
void
deleteAll
(
Long
[]
ids
);
}
}
\ No newline at end of file
eladmin-tools/src/main/java/me/zhengjie/service/PictureService.java
View file @
f0211db0
...
@@ -16,17 +16,17 @@ public interface PictureService {
...
@@ -16,17 +16,17 @@ public interface PictureService {
/**
/**
* 查询图片
* 查询图片
* @param criteria
* @param criteria
条件参数
* @param pageable
* @param pageable
分页参数
* @return
* @return
Object
*/
*/
@Cacheable
@Cacheable
Object
queryAll
(
PictureQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
PictureQueryCriteria
criteria
,
Pageable
pageable
);
/**
/**
* 上传图片
* 上传图片
* @param file
* @param file
文件
* @param username
* @param username
用户名
* @return
* @return
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
...
@@ -34,7 +34,7 @@ public interface PictureService {
...
@@ -34,7 +34,7 @@ public interface PictureService {
/**
/**
* 根据ID查询
* 根据ID查询
* @param id
* @param id
文件ID
* @return
* @return
*/
*/
@Cacheable
(
key
=
"#p0"
)
@Cacheable
(
key
=
"#p0"
)
...
@@ -42,14 +42,14 @@ public interface PictureService {
...
@@ -42,14 +42,14 @@ public interface PictureService {
/**
/**
* 删除图片
* 删除图片
* @param picture
* @param picture
图片实体
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Picture
picture
);
void
delete
(
Picture
picture
);
/**
/**
* 删除图片
* 删除图片
* @param ids
* @param ids
文件ID数组
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
deleteAll
(
Long
[]
ids
);
void
deleteAll
(
Long
[]
ids
);
...
...
eladmin-tools/src/main/java/me/zhengjie/service/QiNiuService.java
View file @
f0211db0
...
@@ -20,16 +20,16 @@ public interface QiNiuService {
...
@@ -20,16 +20,16 @@ public interface QiNiuService {
/**
/**
* 查询文件
* 查询文件
* @param criteria
* @param criteria
条件参数
* @param pageable
* @param pageable
分页参数
* @return
* @return
Object
*/
*/
@Cacheable
@Cacheable
Object
queryAll
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
);
/**
/**
* 查配置
* 查配置
* @return
* @return
Cacheable
*/
*/
@Cacheable
(
cacheNames
=
"qiNiuConfig"
,
key
=
"'1'"
)
@Cacheable
(
cacheNames
=
"qiNiuConfig"
,
key
=
"'1'"
)
QiniuConfig
find
();
QiniuConfig
find
();
...
@@ -37,7 +37,7 @@ public interface QiNiuService {
...
@@ -37,7 +37,7 @@ public interface QiNiuService {
/**
/**
* 修改配置
* 修改配置
* @param qiniuConfig
* @param qiniuConfig
* @return
* @return
QiniuConfig
*/
*/
@CachePut
(
cacheNames
=
"qiNiuConfig"
,
key
=
"'1'"
)
@CachePut
(
cacheNames
=
"qiNiuConfig"
,
key
=
"'1'"
)
QiniuConfig
update
(
QiniuConfig
qiniuConfig
);
QiniuConfig
update
(
QiniuConfig
qiniuConfig
);
...
@@ -46,7 +46,7 @@ public interface QiNiuService {
...
@@ -46,7 +46,7 @@ public interface QiNiuService {
* 上传文件
* 上传文件
* @param file
* @param file
* @param qiniuConfig
* @param qiniuConfig
* @return
* @return
QiniuContent
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
QiniuContent
upload
(
MultipartFile
file
,
QiniuConfig
qiniuConfig
);
QiniuContent
upload
(
MultipartFile
file
,
QiniuConfig
qiniuConfig
);
...
@@ -54,7 +54,7 @@ public interface QiNiuService {
...
@@ -54,7 +54,7 @@ public interface QiNiuService {
/**
/**
* 查询文件
* 查询文件
* @param id
* @param id
* @return
* @return
QiniuContent
*/
*/
@Cacheable
(
key
=
"'content:'+#p0"
)
@Cacheable
(
key
=
"'content:'+#p0"
)
QiniuContent
findByContentId
(
Long
id
);
QiniuContent
findByContentId
(
Long
id
);
...
@@ -63,34 +63,37 @@ public interface QiNiuService {
...
@@ -63,34 +63,37 @@ public interface QiNiuService {
* 下载文件
* 下载文件
* @param content
* @param content
* @param config
* @param config
* @return
* @return
String
*/
*/
String
download
(
QiniuContent
content
,
QiniuConfig
config
);
String
download
(
QiniuContent
content
,
QiniuConfig
config
);
/**
/**
* 删除文件
* 删除文件
* @param content
* @param content 文件
* @param config
* @param config 配置
* @return
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
delete
(
QiniuContent
content
,
QiniuConfig
config
);
void
delete
(
QiniuContent
content
,
QiniuConfig
config
);
/**
/**
* 同步数据
* 同步数据
* @param config
* @param config
配置
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
synchronize
(
QiniuConfig
config
);
void
synchronize
(
QiniuConfig
config
);
/**
/**
* 删除文件
* 删除文件
* @param ids
* @param ids
文件ID数组
* @param config
* @param config
配置
*/
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
deleteAll
(
Long
[]
ids
,
QiniuConfig
config
);
void
deleteAll
(
Long
[]
ids
,
QiniuConfig
config
);
/**
* 更新数据
* @param type 类型
*/
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
update
(
String
type
);
void
update
(
String
type
);
}
}
eladmin-tools/src/main/java/me/zhengjie/service/VerificationCodeService.java
View file @
f0211db0
...
@@ -11,13 +11,14 @@ public interface VerificationCodeService {
...
@@ -11,13 +11,14 @@ public interface VerificationCodeService {
/**
/**
* 发送邮件验证码
* 发送邮件验证码
* @param code
* @param code 验证码
* @return EmailVo
*/
*/
EmailVo
sendEmail
(
VerificationCode
code
);
EmailVo
sendEmail
(
VerificationCode
code
);
/**
/**
* 验证
* 验证
* @param code
* @param code
验证码
*/
*/
void
validated
(
VerificationCode
code
);
void
validated
(
VerificationCode
code
);
}
}
eladmin-tools/src/main/java/me/zhengjie/service/impl/AlipayServiceImpl.java
View file @
f0211db0
...
@@ -40,19 +40,13 @@ public class AlipayServiceImpl implements AlipayService {
...
@@ -40,19 +40,13 @@ public class AlipayServiceImpl implements AlipayService {
double
money
=
Double
.
parseDouble
(
trade
.
getTotalAmount
());
double
money
=
Double
.
parseDouble
(
trade
.
getTotalAmount
());
/**
// 创建API对应的request(电脑网页版)
* 创建API对应的request(电脑网页版)
*/
AlipayTradePagePayRequest
request
=
new
AlipayTradePagePayRequest
();
AlipayTradePagePayRequest
request
=
new
AlipayTradePagePayRequest
();
/**
// 订单完成后返回的页面和异步通知地址
* 订单完成后返回的页面和异步通知地址
*/
request
.
setReturnUrl
(
alipay
.
getReturnUrl
());
request
.
setReturnUrl
(
alipay
.
getReturnUrl
());
request
.
setNotifyUrl
(
alipay
.
getNotifyUrl
());
request
.
setNotifyUrl
(
alipay
.
getNotifyUrl
());
/**
// 填充订单参数
* 填充订单参数
*/
request
.
setBizContent
(
"{"
+
request
.
setBizContent
(
"{"
+
" \"out_trade_no\":\""
+
trade
.
getOutTradeNo
()+
"\","
+
" \"out_trade_no\":\""
+
trade
.
getOutTradeNo
()+
"\","
+
" \"product_code\":\"FAST_INSTANT_TRADE_PAY\","
+
" \"product_code\":\"FAST_INSTANT_TRADE_PAY\","
+
...
@@ -63,10 +57,7 @@ public class AlipayServiceImpl implements AlipayService {
...
@@ -63,10 +57,7 @@ public class AlipayServiceImpl implements AlipayService {
" \"sys_service_provider_id\":\""
+
alipay
.
getSysServiceProviderId
()+
"\""
+
" \"sys_service_provider_id\":\""
+
alipay
.
getSysServiceProviderId
()+
"\""
+
" }"
+
" }"
+
" }"
);
//填充业务参数
" }"
);
//填充业务参数
/**
// 调用SDK生成表单, 通过GET方式,口可以获取url
* 调用SDK生成表单
* 通过GET方式,口可以获取url
*/
return
alipayClient
.
pageExecute
(
request
,
"GET"
).
getBody
();
return
alipayClient
.
pageExecute
(
request
,
"GET"
).
getBody
();
}
}
...
@@ -82,20 +73,10 @@ public class AlipayServiceImpl implements AlipayService {
...
@@ -82,20 +73,10 @@ public class AlipayServiceImpl implements AlipayService {
if
(
money
<=
0
||
money
>=
5000
){
if
(
money
<=
0
||
money
>=
5000
){
throw
new
BadRequestException
(
"测试金额过大"
);
throw
new
BadRequestException
(
"测试金额过大"
);
}
}
// 创建API对应的request(手机网页版)
/**
* 创建API对应的request(手机网页版)
*/
AlipayTradeWapPayRequest
request
=
new
AlipayTradeWapPayRequest
();
AlipayTradeWapPayRequest
request
=
new
AlipayTradeWapPayRequest
();
/**
* 订单完成后返回的页面和异步通知地址
*/
request
.
setReturnUrl
(
alipay
.
getReturnUrl
());
request
.
setReturnUrl
(
alipay
.
getReturnUrl
());
request
.
setNotifyUrl
(
alipay
.
getNotifyUrl
());
request
.
setNotifyUrl
(
alipay
.
getNotifyUrl
());
/**
* 填充订单参数
*/
request
.
setBizContent
(
"{"
+
request
.
setBizContent
(
"{"
+
" \"out_trade_no\":\""
+
trade
.
getOutTradeNo
()+
"\","
+
" \"out_trade_no\":\""
+
trade
.
getOutTradeNo
()+
"\","
+
" \"product_code\":\"FAST_INSTANT_TRADE_PAY\","
+
" \"product_code\":\"FAST_INSTANT_TRADE_PAY\","
+
...
@@ -106,21 +87,13 @@ public class AlipayServiceImpl implements AlipayService {
...
@@ -106,21 +87,13 @@ public class AlipayServiceImpl implements AlipayService {
" \"sys_service_provider_id\":\""
+
alipay
.
getSysServiceProviderId
()+
"\""
+
" \"sys_service_provider_id\":\""
+
alipay
.
getSysServiceProviderId
()+
"\""
+
" }"
+
" }"
+
" }"
);
//填充业务参数
" }"
);
//填充业务参数
/**
* 调用SDK生成表单
* 通过GET方式,口可以获取url
*/
return
alipayClient
.
pageExecute
(
request
,
"GET"
).
getBody
();
return
alipayClient
.
pageExecute
(
request
,
"GET"
).
getBody
();
}
}
@Override
@Override
public
AlipayConfig
find
()
{
public
AlipayConfig
find
()
{
Optional
<
AlipayConfig
>
alipayConfig
=
alipayRepository
.
findById
(
1L
);
Optional
<
AlipayConfig
>
alipayConfig
=
alipayRepository
.
findById
(
1L
);
if
(
alipayConfig
.
isPresent
()){
return
alipayConfig
.
orElseGet
(
AlipayConfig:
:
new
);
return
alipayConfig
.
get
();
}
else
{
return
new
AlipayConfig
();
}
}
}
@Override
@Override
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java
View file @
f0211db0
...
@@ -2,15 +2,12 @@ package me.zhengjie.service.impl;
...
@@ -2,15 +2,12 @@ package me.zhengjie.service.impl;
import
cn.hutool.extra.mail.Mail
;
import
cn.hutool.extra.mail.Mail
;
import
cn.hutool.extra.mail.MailAccount
;
import
cn.hutool.extra.mail.MailAccount
;
import
cn.hutool.extra.mail.MailUtil
;
import
me.zhengjie.domain.EmailConfig
;
import
me.zhengjie.domain.EmailConfig
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.repository.EmailRepository
;
import
me.zhengjie.repository.EmailRepository
;
import
me.zhengjie.service.EmailService
;
import
me.zhengjie.service.EmailService
;
import
me.zhengjie.utils.ElAdminConstant
;
import
me.zhengjie.utils.EncryptUtils
;
import
me.zhengjie.utils.EncryptUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -24,8 +21,11 @@ import java.util.Optional;
...
@@ -24,8 +21,11 @@ import java.util.Optional;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
EmailServiceImpl
implements
EmailService
{
public
class
EmailServiceImpl
implements
EmailService
{
@Autowired
private
final
EmailRepository
emailRepository
;
private
EmailRepository
emailRepository
;
public
EmailServiceImpl
(
EmailRepository
emailRepository
)
{
this
.
emailRepository
=
emailRepository
;
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -44,11 +44,7 @@ public class EmailServiceImpl implements EmailService {
...
@@ -44,11 +44,7 @@ public class EmailServiceImpl implements EmailService {
@Override
@Override
public
EmailConfig
find
()
{
public
EmailConfig
find
()
{
Optional
<
EmailConfig
>
emailConfig
=
emailRepository
.
findById
(
1L
);
Optional
<
EmailConfig
>
emailConfig
=
emailRepository
.
findById
(
1L
);
if
(
emailConfig
.
isPresent
()){
return
emailConfig
.
orElseGet
(
EmailConfig:
:
new
);
return
emailConfig
.
get
();
}
else
{
return
new
EmailConfig
();
}
}
}
@Override
@Override
...
@@ -57,9 +53,7 @@ public class EmailServiceImpl implements EmailService {
...
@@ -57,9 +53,7 @@ public class EmailServiceImpl implements EmailService {
if
(
emailConfig
==
null
){
if
(
emailConfig
==
null
){
throw
new
BadRequestException
(
"请先配置,再操作"
);
throw
new
BadRequestException
(
"请先配置,再操作"
);
}
}
/**
// 封装
* 封装
*/
MailAccount
account
=
new
MailAccount
();
MailAccount
account
=
new
MailAccount
();
account
.
setHost
(
emailConfig
.
getHost
());
account
.
setHost
(
emailConfig
.
getHost
());
account
.
setPort
(
Integer
.
parseInt
(
emailConfig
.
getPort
()));
account
.
setPort
(
Integer
.
parseInt
(
emailConfig
.
getPort
()));
...
@@ -71,15 +65,14 @@ public class EmailServiceImpl implements EmailService {
...
@@ -71,15 +65,14 @@ public class EmailServiceImpl implements EmailService {
throw
new
BadRequestException
(
e
.
getMessage
());
throw
new
BadRequestException
(
e
.
getMessage
());
}
}
account
.
setFrom
(
emailConfig
.
getUser
()+
"<"
+
emailConfig
.
getFromUser
()+
">"
);
account
.
setFrom
(
emailConfig
.
getUser
()+
"<"
+
emailConfig
.
getFromUser
()+
">"
);
//ssl方式发送
//
ssl方式发送
account
.
setSslEnable
(
true
);
account
.
setSslEnable
(
true
);
String
content
=
emailVo
.
getContent
();
String
content
=
emailVo
.
getContent
();
/**
// 发送
* 发送
*/
try
{
try
{
int
size
=
emailVo
.
getTos
().
size
();
Mail
.
create
(
account
)
Mail
.
create
(
account
)
.
setTos
(
emailVo
.
getTos
().
toArray
(
new
String
[
emailVo
.
getTos
().
size
()
]))
.
setTos
(
emailVo
.
getTos
().
toArray
(
new
String
[
size
]))
.
setTitle
(
emailVo
.
getSubject
())
.
setTitle
(
emailVo
.
getSubject
())
.
setContent
(
content
)
.
setContent
(
content
)
.
setHtml
(
true
)
.
setHtml
(
true
)
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java
View file @
f0211db0
package
me.zhengjie.service.impl
;
package
me.zhengjie.service.impl
;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.utils.*
;
import
me.zhengjie.utils.*
;
import
me.zhengjie.repository.LocalStorageRepository
;
import
me.zhengjie.repository.LocalStorageRepository
;
import
me.zhengjie.service.LocalStorageService
;
import
me.zhengjie.service.LocalStorageService
;
import
me.zhengjie.service.dto.LocalStorageDTO
;
import
me.zhengjie.service.dto.LocalStorageDTO
;
import
me.zhengjie.service.dto.LocalStorageQueryCriteria
;
import
me.zhengjie.service.dto.LocalStorageQueryCriteria
;
import
me.zhengjie.service.mapper.LocalStorageMapper
;
import
me.zhengjie.service.mapper.LocalStorageMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Optional
;
import
java.util.Optional
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
...
@@ -28,11 +25,9 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -28,11 +25,9 @@ import org.springframework.web.multipart.MultipartFile;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
LocalStorageServiceImpl
implements
LocalStorageService
{
public
class
LocalStorageServiceImpl
implements
LocalStorageService
{
@Autowired
private
final
LocalStorageRepository
localStorageRepository
;
private
LocalStorageRepository
localStorageRepository
;
@Autowired
private
final
LocalStorageMapper
localStorageMapper
;
private
LocalStorageMapper
localStorageMapper
;
@Value
(
"${file.path}"
)
@Value
(
"${file.path}"
)
private
String
path
;
private
String
path
;
...
@@ -40,6 +35,11 @@ public class LocalStorageServiceImpl implements LocalStorageService {
...
@@ -40,6 +35,11 @@ public class LocalStorageServiceImpl implements LocalStorageService {
@Value
(
"${file.maxSize}"
)
@Value
(
"${file.maxSize}"
)
private
long
maxSize
;
private
long
maxSize
;
public
LocalStorageServiceImpl
(
LocalStorageRepository
localStorageRepository
,
LocalStorageMapper
localStorageMapper
)
{
this
.
localStorageRepository
=
localStorageRepository
;
this
.
localStorageMapper
=
localStorageMapper
;
}
@Override
@Override
public
Object
queryAll
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
){
public
Object
queryAll
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
){
Page
<
LocalStorage
>
page
=
localStorageRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
);
Page
<
LocalStorage
>
page
=
localStorageRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
);
...
@@ -85,11 +85,6 @@ public class LocalStorageServiceImpl implements LocalStorageService {
...
@@ -85,11 +85,6 @@ public class LocalStorageServiceImpl implements LocalStorageService {
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
File
file
=
new
File
(
"C:\\Users\\Jie\\Pictures\\Saved Pictures\\demo1.jpg"
);
System
.
out
.
println
(
FileUtil
.
getType
(
file
));
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
LocalStorage
resources
)
{
public
void
update
(
LocalStorage
resources
)
{
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java
View file @
f0211db0
...
@@ -30,14 +30,17 @@ import java.util.Optional;
...
@@ -30,14 +30,17 @@ import java.util.Optional;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
PictureServiceImpl
implements
PictureService
{
public
class
PictureServiceImpl
implements
PictureService
{
@Autowired
private
final
PictureRepository
pictureRepository
;
private
PictureRepository
pictureRepository
;
p
ublic
static
final
String
SUCCESS
=
"success"
;
p
rivate
static
final
String
SUCCESS
=
"success"
;
p
ublic
static
final
String
CODE
=
"code"
;
p
rivate
static
final
String
CODE
=
"code"
;
public
static
final
String
MSG
=
"message"
;
private
static
final
String
MSG
=
"message"
;
public
PictureServiceImpl
(
PictureRepository
pictureRepository
)
{
this
.
pictureRepository
=
pictureRepository
;
}
@Override
@Override
public
Object
queryAll
(
PictureQueryCriteria
criteria
,
Pageable
pageable
){
public
Object
queryAll
(
PictureQueryCriteria
criteria
,
Pageable
pageable
){
...
@@ -60,7 +63,7 @@ public class PictureServiceImpl implements PictureService {
...
@@ -60,7 +63,7 @@ public class PictureServiceImpl implements PictureService {
}
}
//转成实体类
//转成实体类
picture
=
JSON
.
parseObject
(
jsonObject
.
get
(
"data"
).
toString
(),
Picture
.
class
);
picture
=
JSON
.
parseObject
(
jsonObject
.
get
(
"data"
).
toString
(),
Picture
.
class
);
picture
.
setSize
(
FileUtil
.
getSize
(
Integer
.
valueOf
(
picture
.
getSize
())));
picture
.
setSize
(
FileUtil
.
getSize
(
Integer
.
parseInt
(
picture
.
getSize
())));
picture
.
setUsername
(
username
);
picture
.
setUsername
(
username
);
picture
.
setFilename
(
FileUtil
.
getFileNameNoEx
(
multipartFile
.
getOriginalFilename
())+
"."
+
FileUtil
.
getExtensionName
(
multipartFile
.
getOriginalFilename
()));
picture
.
setFilename
(
FileUtil
.
getFileNameNoEx
(
multipartFile
.
getOriginalFilename
())+
"."
+
FileUtil
.
getExtensionName
(
multipartFile
.
getOriginalFilename
()));
pictureRepository
.
save
(
picture
);
pictureRepository
.
save
(
picture
);
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java
View file @
f0211db0
...
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Propagation;
...
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
/**
/**
...
@@ -39,17 +40,18 @@ import java.util.Optional;
...
@@ -39,17 +40,18 @@ import java.util.Optional;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
QiNiuServiceImpl
implements
QiNiuService
{
public
class
QiNiuServiceImpl
implements
QiNiuService
{
@Autowired
private
final
QiNiuConfigRepository
qiNiuConfigRepository
;
private
QiNiuConfigRepository
qiNiuConfigRepository
;
@Autowired
private
final
QiniuContentRepository
qiniuContentRepository
;
private
QiniuContentRepository
qiniuContentRepository
;
public
QiNiuServiceImpl
(
QiNiuConfigRepository
qiNiuConfigRepository
,
QiniuContentRepository
qiniuContentRepository
)
{
this
.
qiNiuConfigRepository
=
qiNiuConfigRepository
;
this
.
qiniuContentRepository
=
qiniuContentRepository
;
}
@Value
(
"${qiniu.max-size}"
)
@Value
(
"${qiniu.max-size}"
)
private
Long
maxSize
;
private
Long
maxSize
;
private
final
String
TYPE
=
"公开"
;
@Override
@Override
public
Object
queryAll
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
){
public
Object
queryAll
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
){
return
PageUtil
.
toPage
(
qiniuContentRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
));
return
PageUtil
.
toPage
(
qiniuContentRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
));
...
@@ -58,11 +60,7 @@ public class QiNiuServiceImpl implements QiNiuService {
...
@@ -58,11 +60,7 @@ public class QiNiuServiceImpl implements QiNiuService {
@Override
@Override
public
QiniuConfig
find
()
{
public
QiniuConfig
find
()
{
Optional
<
QiniuConfig
>
qiniuConfig
=
qiNiuConfigRepository
.
findById
(
1L
);
Optional
<
QiniuConfig
>
qiniuConfig
=
qiNiuConfigRepository
.
findById
(
1L
);
if
(
qiniuConfig
.
isPresent
()){
return
qiniuConfig
.
orElseGet
(
QiniuConfig:
:
new
);
return
qiniuConfig
.
get
();
}
else
{
return
new
QiniuConfig
();
}
}
}
@Override
@Override
...
@@ -82,9 +80,7 @@ public class QiNiuServiceImpl implements QiNiuService {
...
@@ -82,9 +80,7 @@ public class QiNiuServiceImpl implements QiNiuService {
if
(
qiniuConfig
.
getId
()
==
null
){
if
(
qiniuConfig
.
getId
()
==
null
){
throw
new
BadRequestException
(
"请先添加相应配置,再操作"
);
throw
new
BadRequestException
(
"请先添加相应配置,再操作"
);
}
}
/**
// 构造一个带指定Zone对象的配置类
* 构造一个带指定Zone对象的配置类
*/
Configuration
cfg
=
new
Configuration
(
QiNiuUtil
.
getRegion
(
qiniuConfig
.
getZone
()));
Configuration
cfg
=
new
Configuration
(
QiNiuUtil
.
getRegion
(
qiniuConfig
.
getZone
()));
UploadManager
uploadManager
=
new
UploadManager
(
cfg
);
UploadManager
uploadManager
=
new
UploadManager
(
cfg
);
Auth
auth
=
Auth
.
create
(
qiniuConfig
.
getAccessKey
(),
qiniuConfig
.
getSecretKey
());
Auth
auth
=
Auth
.
create
(
qiniuConfig
.
getAccessKey
(),
qiniuConfig
.
getSecretKey
());
...
@@ -122,13 +118,12 @@ public class QiNiuServiceImpl implements QiNiuService {
...
@@ -122,13 +118,12 @@ public class QiNiuServiceImpl implements QiNiuService {
@Override
@Override
public
String
download
(
QiniuContent
content
,
QiniuConfig
config
){
public
String
download
(
QiniuContent
content
,
QiniuConfig
config
){
String
finalUrl
=
null
;
String
finalUrl
=
null
;
String
TYPE
=
"公开"
;
if
(
TYPE
.
equals
(
content
.
getType
())){
if
(
TYPE
.
equals
(
content
.
getType
())){
finalUrl
=
content
.
getUrl
();
finalUrl
=
content
.
getUrl
();
}
else
{
}
else
{
Auth
auth
=
Auth
.
create
(
config
.
getAccessKey
(),
config
.
getSecretKey
());
Auth
auth
=
Auth
.
create
(
config
.
getAccessKey
(),
config
.
getSecretKey
());
/**
// 1小时,可以自定义链接过期时间
* 1小时,可以自定义链接过期时间
*/
long
expireInSeconds
=
3600
;
long
expireInSeconds
=
3600
;
finalUrl
=
auth
.
privateDownloadUrl
(
content
.
getUrl
(),
expireInSeconds
);
finalUrl
=
auth
.
privateDownloadUrl
(
content
.
getUrl
(),
expireInSeconds
);
}
}
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/VerificationCodeServiceImpl.java
View file @
f0211db0
...
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
...
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
/**
/**
...
@@ -45,12 +46,12 @@ public class VerificationCodeServiceImpl implements VerificationCodeService {
...
@@ -45,12 +46,12 @@ public class VerificationCodeServiceImpl implements VerificationCodeService {
if
(
verificationCode
==
null
){
if
(
verificationCode
==
null
){
code
.
setCode
(
RandomUtil
.
randomNumbers
(
6
));
code
.
setCode
(
RandomUtil
.
randomNumbers
(
6
));
content
=
template
.
render
(
Dict
.
create
().
set
(
"code"
,
code
.
getCode
()));
content
=
template
.
render
(
Dict
.
create
().
set
(
"code"
,
code
.
getCode
()));
emailVo
=
new
EmailVo
(
Arrays
.
as
List
(
code
.
getValue
()),
"eladmin后台管理系统"
,
content
);
emailVo
=
new
EmailVo
(
Collections
.
singleton
List
(
code
.
getValue
()),
"eladmin后台管理系统"
,
content
);
timedDestruction
(
verificationCodeRepository
.
save
(
code
));
timedDestruction
(
verificationCodeRepository
.
save
(
code
));
// 存在就再次发送原来的验证码
// 存在就再次发送原来的验证码
}
else
{
}
else
{
content
=
template
.
render
(
Dict
.
create
().
set
(
"code"
,
verificationCode
.
getCode
()));
content
=
template
.
render
(
Dict
.
create
().
set
(
"code"
,
verificationCode
.
getCode
()));
emailVo
=
new
EmailVo
(
Arrays
.
as
List
(
verificationCode
.
getValue
()),
"eladmin后台管理系统"
,
content
);
emailVo
=
new
EmailVo
(
Collections
.
singleton
List
(
verificationCode
.
getValue
()),
"eladmin后台管理系统"
,
content
);
}
}
return
emailVo
;
return
emailVo
;
}
}
...
@@ -68,7 +69,7 @@ public class VerificationCodeServiceImpl implements VerificationCodeService {
...
@@ -68,7 +69,7 @@ public class VerificationCodeServiceImpl implements VerificationCodeService {
/**
/**
* 定时任务,指定分钟后改变验证码状态
* 定时任务,指定分钟后改变验证码状态
* @param verifyCode
* @param verifyCode
验证码
*/
*/
private
void
timedDestruction
(
VerificationCode
verifyCode
)
{
private
void
timedDestruction
(
VerificationCode
verifyCode
)
{
//以下示例为程序调用结束继续运行
//以下示例为程序调用结束继续运行
...
...
eladmin-tools/src/main/java/me/zhengjie/utils/AliPayStatusEnum.java
View file @
f0211db0
...
@@ -27,11 +27,9 @@ public enum AliPayStatusEnum {
...
@@ -27,11 +27,9 @@ public enum AliPayStatusEnum {
*/
*/
CLOSED
(
"交易关闭"
,
"TRADE_CLOSED"
);
CLOSED
(
"交易关闭"
,
"TRADE_CLOSED"
);
private
String
name
;
private
String
value
;
private
String
value
;
AliPayStatusEnum
(
String
name
,
String
value
)
{
AliPayStatusEnum
(
String
name
,
String
value
)
{
this
.
name
=
name
;
this
.
value
=
value
;
this
.
value
=
value
;
}
}
...
...
eladmin-tools/src/main/java/me/zhengjie/utils/AlipayUtils.java
View file @
f0211db0
...
@@ -22,7 +22,6 @@ public class AlipayUtils {
...
@@ -22,7 +22,6 @@ public class AlipayUtils {
/**
/**
* 生成订单号
* 生成订单号
* @return
*/
*/
public
String
getOrderCode
()
{
public
String
getOrderCode
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
@@ -35,24 +34,19 @@ public class AlipayUtils {
...
@@ -35,24 +34,19 @@ public class AlipayUtils {
String
[]
split1
=
s
.
split
(
" "
);
String
[]
split1
=
s
.
split
(
" "
);
String
s1
=
split1
[
0
]
+
split1
[
1
];
String
s1
=
split1
[
0
]
+
split1
[
1
];
String
[]
split2
=
s1
.
split
(
":"
);
String
[]
split2
=
s1
.
split
(
":"
);
String
s2
=
split2
[
0
]
+
split2
[
1
]
+
split2
[
2
]
+
a
;
return
split2
[
0
]
+
split2
[
1
]
+
split2
[
2
]
+
a
;
return
s2
;
}
}
/**
/**
* 校验签名
* 校验签名
* @param request
* @return
*/
*/
public
boolean
rsaCheck
(
HttpServletRequest
request
,
AlipayConfig
alipay
){
public
boolean
rsaCheck
(
HttpServletRequest
request
,
AlipayConfig
alipay
){
/**
// 获取支付宝POST过来反馈信息
* 获取支付宝POST过来反馈信息
*/
Map
<
String
,
String
>
params
=
new
HashMap
<>(
1
);
Map
<
String
,
String
>
params
=
new
HashMap
<>(
1
);
Map
requestParams
=
request
.
getParameterMap
();
Map
requestParams
=
request
.
getParameterMap
();
for
(
Iterator
iter
=
requestParams
.
keySet
()
.
iterator
();
iter
.
hasNext
();
)
{
for
(
Object
o
:
requestParams
.
keySet
())
{
String
name
=
(
String
)
iter
.
next
()
;
String
name
=
(
String
)
o
;
String
[]
values
=
(
String
[])
requestParams
.
get
(
name
);
String
[]
values
=
(
String
[])
requestParams
.
get
(
name
);
String
valueStr
=
""
;
String
valueStr
=
""
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
...
@@ -63,11 +57,10 @@ public class AlipayUtils {
...
@@ -63,11 +57,10 @@ public class AlipayUtils {
}
}
try
{
try
{
boolean
verifyResult
=
AlipaySignature
.
rsaCheckV1
(
params
,
return
AlipaySignature
.
rsaCheckV1
(
params
,
alipay
.
getPublicKey
(),
alipay
.
getPublicKey
(),
alipay
.
getCharset
(),
alipay
.
getCharset
(),
alipay
.
getSignType
());
alipay
.
getSignType
());
return
verifyResult
;
}
catch
(
AlipayApiException
e
)
{
}
catch
(
AlipayApiException
e
)
{
return
false
;
return
false
;
}
}
...
...
eladmin-tools/src/main/java/me/zhengjie/utils/QiNiuUtil.java
View file @
f0211db0
...
@@ -11,18 +11,16 @@ import java.util.Date;
...
@@ -11,18 +11,16 @@ import java.util.Date;
*/
*/
public
class
QiNiuUtil
{
public
class
QiNiuUtil
{
p
ublic
static
final
String
HUAD
=
"华东"
;
p
rivate
static
final
String
HUAD
=
"华东"
;
p
ublic
static
final
String
HUAB
=
"华北"
;
p
rivate
static
final
String
HUAB
=
"华北"
;
p
ublic
static
final
String
HUAN
=
"华南"
;
p
rivate
static
final
String
HUAN
=
"华南"
;
p
ublic
static
final
String
BEIM
=
"北美"
;
p
rivate
static
final
String
BEIM
=
"北美"
;
/**
/**
* 得到机房的对应关系
* 得到机房的对应关系
* @param zone
* @return
*/
*/
public
static
Region
getRegion
(
String
zone
){
public
static
Region
getRegion
(
String
zone
){
...
@@ -42,17 +40,13 @@ public class QiNiuUtil {
...
@@ -42,17 +40,13 @@ public class QiNiuUtil {
/**
/**
* 默认不指定key的情况下,以文件内容的hash值作为文件名
* 默认不指定key的情况下,以文件内容的hash值作为文件名
* @param file
* @return
*/
*/
public
static
String
getKey
(
String
file
){
public
static
String
getKey
(
String
file
){
StringBuffer
key
=
new
StringBuffer
(
FileUtil
.
getFileNameNoEx
(
file
));
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
Date
date
=
new
Date
();
Date
date
=
new
Date
();
key
.
append
(
"-"
);
return
FileUtil
.
getFileNameNoEx
(
file
)
+
"-"
+
key
.
append
(
sdf
.
format
(
date
));
sdf
.
format
(
date
)
+
key
.
append
(
"."
);
"."
+
key
.
append
(
FileUtil
.
getExtensionName
(
file
));
FileUtil
.
getExtensionName
(
file
);
return
key
.
toString
();
}
}
}
}
Prev
1
2
3
Next
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