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
bf7c1eeb
Commit
bf7c1eeb
authored
Oct 24, 2019
by
dqjdda
Browse files
代码优化完成,去除大量idea警告,代码生成器优化等
parent
e3c3ebb1
Changes
146
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/resources/template/generator/admin/Repository.ftl
View file @
bf7c1eeb
...
@@ -8,16 +8,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
...
@@ -8,16 +8,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
*
@author $
{
author
}
*
@author $
{
author
}
*
@date $
{
date
}
*
@date $
{
date
}
*/
*/
public
interface $
{
className
}
Repository extends JpaRepository<$
{
className
}
, $
{
pkColumnType
}
>, JpaSpecificationExecutor
{
public
interface $
{
className
}
Repository extends JpaRepository<$
{
className
}
, $
{
pkColumnType
}
>, JpaSpecificationExecutor
<$
{
className
}
>
{
<#
if
columns
??>
<#
if
columns
??>
<#
list
columns
as
column
>
<#
list
columns
as
column
>
<#
if
column
.columnKey
=
'
UNI
'>
<#
if
column
.columnKey
=
'
UNI
'>
/
**
*
findBy
$
{
column
.capitalColumnName
}
*
@
param
$
{
column
.columnName
}
*
@
return
*
/
$
{
className
}
findBy
$
{
column
.capitalColumnName
}(
$
{
column
.columnType
}
$
{
column
.columnName
})
;
$
{
className
}
findBy
$
{
column
.capitalColumnName
}(
$
{
column
.columnType
}
$
{
column
.columnName
})
;
</#
if
>
</#
if
>
</#
list
>
</#
list
>
...
...
eladmin-system/src/main/resources/template/generator/admin/Service.ftl
View file @
bf7c1eeb
...
@@ -3,9 +3,6 @@ package ${package}.service;
...
@@ -3,9 +3,6 @@ package ${package}.service;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.CacheEvict;
import
org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Pageable;
import
java.util.Map;
import
java.util.Map;
import
java.util.List;
import
java.util.List;
...
@@ -14,53 +11,33 @@ import java.util.List;
...
@@ -14,53 +11,33 @@ import java.util.List;
*
@author $
{
author
}
*
@author $
{
author
}
*
@date $
{
date
}
*
@date $
{
date
}
*/
*/
//@
CacheConfig
(
cacheNames
=
"$
{
changeClassName
}
")
public
interface $
{
className
}
Service
{
public
interface $
{
className
}
Service
{
/
**
/
**
*
查询数据分页
*
查询数据分页
*
@
param
criteria
*
@
param
criteria
条件参数
*
@
param
pageable
*
@
param
pageable
分页参数
*
@
return
*
@
return
M
ap
<
S
tring
,
O
bject
>
*
/
*
/
//@
C
acheable
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
)
;
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
)
;
/
**
/
**
*
查询所有数据不分页
*
查询所有数据不分页
*
@
param
criteria
*
@
param
criteria
条件参数
*
@
return
*
@
return
L
ist
<$
{
className
}
DTO
>
*
/
*
/
//@
C
acheable
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
)
;
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
)
;
/
**
/
**
*
根据
ID
查询
*
根据
ID
查询
*
@
param
$
{
pkChangeColName
}
*
@
param
$
{
pkChangeColName
}
ID
*
@
return
*
@
return
$
{
className
}
DTO
*
/
*
/
//@
C
acheable
(
key
=
"#p0"
)
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
/
**
*
创建
*
@
param
resources
*
@
return
*
/
//@
C
acheEvict
(
allEntries
=
true
)
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
;
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
;
/
**
*
编辑
*
@
param
resources
*
/
//@
C
acheEvict
(
allEntries
=
true
)
void
update
(
$
{
className
}
resources
)
;
void
update
(
$
{
className
}
resources
)
;
/
**
*
删除
*
@
param
$
{
pkChangeColName
}
*
/
//@
C
acheEvict
(
allEntries
=
true
)
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
}
}
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl
View file @
bf7c1eeb
...
@@ -16,11 +16,9 @@ import ${package}.service.${className}Service;
...
@@ -16,11 +16,9 @@ import ${package}.service.${className}Service;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
$
{
package
}
.service.mapper.$
{
className
}
Mapper;
import
$
{
package
}
.service.mapper.$
{
className
}
Mapper;
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;
import
java.util.Optional;
<#
if
!auto && pkColumnType = 'Long'>
<#
if
!auto && pkColumnType = 'Long'>
import
cn.hutool.core.lang.Snowflake;
import
cn.hutool.core.lang.Snowflake;
import
cn.hutool.core.util.IdUtil;
import
cn.hutool.core.util.IdUtil;
...
@@ -28,6 +26,9 @@ import cn.hutool.core.util.IdUtil;
...
@@ -28,6 +26,9 @@ import cn.hutool.core.util.IdUtil;
<#
if
!auto && pkColumnType = 'String'>
<#
if
!auto && pkColumnType = 'String'>
import
cn.hutool.core.util.IdUtil;
import
cn.hutool.core.util.IdUtil;
</#
if
>
</#
if
>
import
org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.CacheEvict;
import
org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Page;
import
org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Pageable;
import
me.zhengjie.utils.PageUtil;
import
me.zhengjie.utils.PageUtil;
...
@@ -40,34 +41,42 @@ import java.util.Map;
...
@@ -40,34 +41,42 @@ import java.util.Map;
*
@date $
{
date
}
*
@date $
{
date
}
*/
*/
@
Service
@
Service
@
CacheConfig
(
cacheNames
=
"$
{
changeClassName
}
")
@
Transactional
(
propagation
=
Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@
Transactional
(
propagation
=
Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public
class $
{
className
}
ServiceImpl implements $
{
className
}
Service
{
public
class $
{
className
}
ServiceImpl implements $
{
className
}
Service
{
@
A
utowired
private
final
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
;
private
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
;
@
A
utowired
private
final
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
;
private
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
;
public
$
{
className
}
S
erviceImpl
(
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
,
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
)
{
this
.$
{
changeClassName
}
R
epository
=
$
{
changeClassName
}
R
epository
;
this
.$
{
changeClassName
}
M
apper
=
$
{
changeClassName
}
M
apper
;
}
@
O
verride
@
O
verride
@
C
acheable
public
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
public
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
P
age
<$
{
className
}
>
page
=
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
)
;
P
age
<$
{
className
}
>
page
=
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
)
;
return
P
ageUtil
.toPage
(
page
.map
(
$
{
changeClassName
}
M
apper
::
toDto
))
;
return
P
ageUtil
.toPage
(
page
.map
(
$
{
changeClassName
}
M
apper
::
toDto
))
;
}
}
@
O
verride
@
O
verride
@
C
acheable
public
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
){
public
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
){
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
)))
;
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
)))
;
}
}
@
O
verride
@
O
verride
@
C
acheable
(
key
=
"#p0"
)
public
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
public
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
O
ptional
<
$
{
className
}
>
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
$
{
pkChangeColName
})
;
$
{
className
}
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
$
{
pkChangeColName
})
.orElseGet
(
$
{
className
}::
new
)
;
V
alidationUtil
.isNull
(
$
{
changeClassName
},
"${className}"
,
"${pkChangeColName}"
,
$
{
pkChangeColName
})
;
V
alidationUtil
.isNull
(
$
{
changeClassName
}
.get
$
{
pkCapitalColName
}()
,
"${className}"
,
"${pkChangeColName}"
,
$
{
pkChangeColName
})
;
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
.get
()
)
;
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
})
;
}
}
@
O
verride
@
O
verride
@
C
acheEvict
(
allEntries
=
true
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
public
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
{
public
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
{
<#
if
!
auto
&&
pkColumnType
=
'
L
ong
'>
<#
if
!
auto
&&
pkColumnType
=
'
L
ong
'>
...
@@ -90,11 +99,11 @@ public class ${className}ServiceImpl implements ${className}Service {
...
@@ -90,11 +99,11 @@ public class ${className}ServiceImpl implements ${className}Service {
}
}
@
O
verride
@
O
verride
@
C
acheEvict
(
allEntries
=
true
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
public
void
update
(
$
{
className
}
resources
)
{
public
void
update
(
$
{
className
}
resources
)
{
O
ptional
<$
{
className
}
>
optional
$
{
className
}
=
$
{
changeClassName
}
R
epository
.findById
(
resources
.get
$
{
pkCapitalColName
}())
;
$
{
className
}
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
resources
.get
$
{
pkCapitalColName
}())
.orElseGet
(
$
{
className
}::
new
)
;
V
alidationUtil
.isNull
(
optional
$
{
className
},
"${className}"
,
"id"
,
resources
.get
$
{
pkCapitalColName
}())
;
V
alidationUtil
.isNull
(
$
{
changeClassName
}
.get
$
{
pkCapitalColName
}(),
"${className}"
,
"id"
,
resources
.get
$
{
pkCapitalColName
}())
;
$
{
className
}
$
{
changeClassName
}
=
optional
$
{
className
}
.get
()
;
<#
if
columns
??>
<#
if
columns
??>
<#
list
columns
as
column
>
<#
list
columns
as
column
>
<#
if
column
.columnKey
=
'
UNI
'>
<#
if
column
.columnKey
=
'
UNI
'>
...
@@ -113,6 +122,7 @@ public class ${className}ServiceImpl implements ${className}Service {
...
@@ -113,6 +122,7 @@ public class ${className}ServiceImpl implements ${className}Service {
}
}
@
O
verride
@
O
verride
@
C
acheEvict
(
allEntries
=
true
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
public
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
public
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
$
{
changeClassName
}
R
epository
.deleteById
(
$
{
pkChangeColName
})
;
$
{
changeClassName
}
R
epository
.deleteById
(
$
{
pkChangeColName
})
;
...
...
eladmin-system/src/test/java/me/zhengjie/EladminSystemApplicationTests.java
View file @
bf7c1eeb
...
@@ -13,6 +13,5 @@ public class EladminSystemApplicationTests {
...
@@ -13,6 +13,5 @@ public class EladminSystemApplicationTests {
public
void
contextLoads
()
{
public
void
contextLoads
()
{
}
}
}
}
eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java
View file @
bf7c1eeb
...
@@ -41,6 +41,9 @@ public class Picture implements Serializable {
...
@@ -41,6 +41,9 @@ public class Picture implements Serializable {
@Column
(
name
=
"create_time"
)
@Column
(
name
=
"create_time"
)
private
Timestamp
createTime
;
private
Timestamp
createTime
;
// 用于检测文件是否重复
private
String
md5Code
;
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Picture{"
+
return
"Picture{"
+
...
...
eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java
View file @
bf7c1eeb
...
@@ -9,4 +9,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
...
@@ -9,4 +9,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2018-12-27
* @date 2018-12-27
*/
*/
public
interface
PictureRepository
extends
JpaRepository
<
Picture
,
Long
>,
JpaSpecificationExecutor
<
Picture
>
{
public
interface
PictureRepository
extends
JpaRepository
<
Picture
,
Long
>,
JpaSpecificationExecutor
<
Picture
>
{
Picture
findByUrl
(
String
url
);
Picture
findByMd5Code
(
String
code
);
}
}
eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java
View file @
bf7c1eeb
...
@@ -9,7 +9,6 @@ import me.zhengjie.domain.vo.TradeVo;
...
@@ -9,7 +9,6 @@ import me.zhengjie.domain.vo.TradeVo;
import
me.zhengjie.service.AlipayService
;
import
me.zhengjie.service.AlipayService
;
import
me.zhengjie.utils.AliPayStatusEnum
;
import
me.zhengjie.utils.AliPayStatusEnum
;
import
me.zhengjie.utils.AlipayUtils
;
import
me.zhengjie.utils.AlipayUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -27,7 +26,7 @@ import java.util.Map;
...
@@ -27,7 +26,7 @@ import java.util.Map;
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/api/aliPay"
)
@RequestMapping
(
"/api/aliPay"
)
@Api
(
tags
=
"支付宝
支付
管理"
)
@Api
(
tags
=
"
工具:
支付宝管理"
)
public
class
AliPayController
{
public
class
AliPayController
{
private
final
AlipayUtils
alipayUtils
;
private
final
AlipayUtils
alipayUtils
;
...
@@ -45,6 +44,7 @@ public class AliPayController {
...
@@ -45,6 +44,7 @@ public class AliPayController {
}
}
@Log
(
"配置支付宝"
)
@Log
(
"配置支付宝"
)
@ApiOperation
(
"配置支付宝"
)
@PutMapping
@PutMapping
public
ResponseEntity
payConfig
(
@Validated
@RequestBody
AlipayConfig
alipayConfig
){
public
ResponseEntity
payConfig
(
@Validated
@RequestBody
AlipayConfig
alipayConfig
){
alipayConfig
.
setId
(
1L
);
alipayConfig
.
setId
(
1L
);
...
@@ -53,7 +53,7 @@ public class AliPayController {
...
@@ -53,7 +53,7 @@ public class AliPayController {
}
}
@Log
(
"支付宝PC网页支付"
)
@Log
(
"支付宝PC网页支付"
)
@ApiOperation
(
value
=
"PC网页支付"
)
@ApiOperation
(
"PC网页支付"
)
@PostMapping
(
value
=
"/toPayAsPC"
)
@PostMapping
(
value
=
"/toPayAsPC"
)
public
ResponseEntity
<
String
>
toPayAsPC
(
@Validated@RequestBody
TradeVo
trade
)
throws
Exception
{
public
ResponseEntity
<
String
>
toPayAsPC
(
@Validated@RequestBody
TradeVo
trade
)
throws
Exception
{
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
...
@@ -63,7 +63,7 @@ public class AliPayController {
...
@@ -63,7 +63,7 @@ public class AliPayController {
}
}
@Log
(
"支付宝手机网页支付"
)
@Log
(
"支付宝手机网页支付"
)
@ApiOperation
(
value
=
"手机网页支付"
)
@ApiOperation
(
"手机网页支付"
)
@PostMapping
(
value
=
"/toPayAsWeb"
)
@PostMapping
(
value
=
"/toPayAsWeb"
)
public
ResponseEntity
<
String
>
toPayAsWeb
(
@Validated
@RequestBody
TradeVo
trade
)
throws
Exception
{
public
ResponseEntity
<
String
>
toPayAsWeb
(
@Validated
@RequestBody
TradeVo
trade
)
throws
Exception
{
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
...
@@ -74,8 +74,8 @@ public class AliPayController {
...
@@ -74,8 +74,8 @@ public class AliPayController {
@ApiIgnore
@ApiIgnore
@GetMapping
(
"/return"
)
@GetMapping
(
"/return"
)
@ApiOperation
(
value
=
"支付之后跳转的链接"
)
@ApiOperation
(
"支付之后跳转的链接"
)
public
ResponseEntity
<
String
>
returnPage
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
public
ResponseEntity
<
String
>
returnPage
(
HttpServletRequest
request
,
HttpServletResponse
response
){
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
response
.
setContentType
(
"text/html;charset="
+
alipay
.
getCharset
());
response
.
setContentType
(
"text/html;charset="
+
alipay
.
getCharset
());
//内容验签,防止黑客篡改参数
//内容验签,防止黑客篡改参数
...
@@ -96,8 +96,8 @@ public class AliPayController {
...
@@ -96,8 +96,8 @@ public class AliPayController {
@ApiIgnore
@ApiIgnore
@RequestMapping
(
"/notify"
)
@RequestMapping
(
"/notify"
)
@ApiOperation
(
value
=
"支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理"
)
@ApiOperation
(
"支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理"
)
public
ResponseEntity
notify
(
HttpServletRequest
request
)
throws
Exception
{
public
ResponseEntity
notify
(
HttpServletRequest
request
){
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
Map
<
String
,
String
[]>
parameterMap
=
request
.
getParameterMap
();
Map
<
String
,
String
[]>
parameterMap
=
request
.
getParameterMap
();
//内容验签,防止黑客篡改参数
//内容验签,防止黑客篡改参数
...
@@ -111,9 +111,9 @@ public class AliPayController {
...
@@ -111,9 +111,9 @@ public class AliPayController {
//付款金额
//付款金额
String
totalAmount
=
new
String
(
request
.
getParameter
(
"total_amount"
).
getBytes
(
StandardCharsets
.
ISO_8859_1
),
StandardCharsets
.
UTF_8
);
String
totalAmount
=
new
String
(
request
.
getParameter
(
"total_amount"
).
getBytes
(
StandardCharsets
.
ISO_8859_1
),
StandardCharsets
.
UTF_8
);
//验证
//验证
//
if(tradeStatus.equals(AliPayStatusEnum.SUCCESS.getValue())||tradeStatus.equals(AliPayStatusEnum.FINISHED.getValue())){
if
(
tradeStatus
.
equals
(
AliPayStatusEnum
.
SUCCESS
.
getValue
())||
tradeStatus
.
equals
(
AliPayStatusEnum
.
FINISHED
.
getValue
())){
//
// 验证通过后应该根据业务需要处理订单
// 验证通过后应该根据业务需要处理订单
//
}
}
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
return
new
ResponseEntity
(
HttpStatus
.
BAD_REQUEST
);
return
new
ResponseEntity
(
HttpStatus
.
BAD_REQUEST
);
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java
View file @
bf7c1eeb
...
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
*/
*/
@RestController
@RestController
@RequestMapping
(
"api/email"
)
@RequestMapping
(
"api/email"
)
@Api
(
tags
=
"邮件管理"
)
@Api
(
tags
=
"
工具:
邮件管理"
)
public
class
EmailController
{
public
class
EmailController
{
private
final
EmailService
emailService
;
private
final
EmailService
emailService
;
...
@@ -34,7 +34,7 @@ public class EmailController {
...
@@ -34,7 +34,7 @@ public class EmailController {
@Log
(
"配置邮件"
)
@Log
(
"配置邮件"
)
@PutMapping
@PutMapping
@ApiOperation
(
value
=
"配置邮件"
)
@ApiOperation
(
"配置邮件"
)
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
EmailConfig
emailConfig
){
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
EmailConfig
emailConfig
){
emailService
.
update
(
emailConfig
,
emailService
.
find
());
emailService
.
update
(
emailConfig
,
emailService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
@@ -42,7 +42,7 @@ public class EmailController {
...
@@ -42,7 +42,7 @@ public class EmailController {
@Log
(
"发送邮件"
)
@Log
(
"发送邮件"
)
@PostMapping
@PostMapping
@ApiOperation
(
value
=
"发送邮件"
)
@ApiOperation
(
"发送邮件"
)
public
ResponseEntity
send
(
@Validated
@RequestBody
EmailVo
emailVo
)
throws
Exception
{
public
ResponseEntity
send
(
@Validated
@RequestBody
EmailVo
emailVo
)
throws
Exception
{
emailService
.
send
(
emailVo
,
emailService
.
find
());
emailService
.
send
(
emailVo
,
emailService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java
View file @
bf7c1eeb
...
@@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-09-05
* @date 2019-09-05
*/
*/
@Api
(
tags
=
"本地存储管理"
)
@Api
(
tags
=
"
工具:
本地存储管理"
)
@RestController
@RestController
@RequestMapping
(
"/api/localStorage"
)
@RequestMapping
(
"/api/localStorage"
)
public
class
LocalStorageController
{
public
class
LocalStorageController
{
...
@@ -28,21 +28,21 @@ public class LocalStorageController {
...
@@ -28,21 +28,21 @@ public class LocalStorageController {
this
.
localStorageService
=
localStorageService
;
this
.
localStorageService
=
localStorageService
;
}
}
@ApiOperation
(
value
=
"查询文件"
)
@ApiOperation
(
"查询文件"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_SELECT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_SELECT')"
)
public
ResponseEntity
getLocalStorages
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
getLocalStorages
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
localStorageService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
localStorageService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
@ApiOperation
(
value
=
"上传文件"
)
@ApiOperation
(
"上传文件"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_CREATE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_CREATE')"
)
public
ResponseEntity
create
(
@RequestParam
String
name
,
@RequestParam
(
"file"
)
MultipartFile
file
){
public
ResponseEntity
create
(
@RequestParam
String
name
,
@RequestParam
(
"file"
)
MultipartFile
file
){
return
new
ResponseEntity
<>(
localStorageService
.
create
(
name
,
file
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>(
localStorageService
.
create
(
name
,
file
),
HttpStatus
.
CREATED
);
}
}
@ApiOperation
(
value
=
"修改文件"
)
@ApiOperation
(
"修改文件"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT')"
)
public
ResponseEntity
update
(
@Validated
@RequestBody
LocalStorage
resources
){
public
ResponseEntity
update
(
@Validated
@RequestBody
LocalStorage
resources
){
...
@@ -50,7 +50,7 @@ public class LocalStorageController {
...
@@ -50,7 +50,7 @@ public class LocalStorageController {
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
}
@ApiOperation
(
value
=
"删除文件"
)
@ApiOperation
(
"删除文件"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_DELETE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
...
@@ -60,7 +60,7 @@ public class LocalStorageController {
...
@@ -60,7 +60,7 @@ public class LocalStorageController {
@Log
(
"多选删除"
)
@Log
(
"多选删除"
)
@DeleteMapping
@DeleteMapping
@ApiOperation
(
value
=
"多选删除"
)
@ApiOperation
(
"多选删除"
)
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
localStorageService
.
deleteAll
(
ids
);
localStorageService
.
deleteAll
(
ids
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java
View file @
bf7c1eeb
...
@@ -22,7 +22,7 @@ import java.util.Map;
...
@@ -22,7 +22,7 @@ import java.util.Map;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/api/pictures"
)
@RequestMapping
(
"/api/pictures"
)
@Api
(
tags
=
"免费图床管理"
)
@Api
(
tags
=
"
工具:
免费图床管理"
)
public
class
PictureController
{
public
class
PictureController
{
private
final
PictureService
pictureService
;
private
final
PictureService
pictureService
;
...
@@ -34,7 +34,7 @@ public class PictureController {
...
@@ -34,7 +34,7 @@ public class PictureController {
@Log
(
"查询图片"
)
@Log
(
"查询图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_SELECT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_SELECT')"
)
@GetMapping
@GetMapping
@ApiOperation
(
value
=
"查询图片"
)
@ApiOperation
(
"查询图片"
)
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
);
}
}
...
@@ -42,7 +42,7 @@ public class PictureController {
...
@@ -42,7 +42,7 @@ public class PictureController {
@Log
(
"上传图片"
)
@Log
(
"上传图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_UPLOAD')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_UPLOAD')"
)
@PostMapping
@PostMapping
@ApiOperation
(
value
=
"上传图片"
)
@ApiOperation
(
"上传图片"
)
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
);
...
@@ -54,7 +54,7 @@ public class PictureController {
...
@@ -54,7 +54,7 @@ public class PictureController {
}
}
@Log
(
"删除图片"
)
@Log
(
"删除图片"
)
@ApiOperation
(
value
=
"删除图片"
)
@ApiOperation
(
"删除图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
)
{
public
ResponseEntity
delete
(
@PathVariable
Long
id
)
{
...
@@ -63,7 +63,7 @@ public class PictureController {
...
@@ -63,7 +63,7 @@ public class PictureController {
}
}
@Log
(
"多选删除图片"
)
@Log
(
"多选删除图片"
)
@ApiOperation
(
value
=
"多选删除图片"
)
@ApiOperation
(
"多选删除图片"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_DELETE')"
)
@DeleteMapping
@DeleteMapping
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java
View file @
bf7c1eeb
...
@@ -24,8 +24,8 @@ import java.util.Map;
...
@@ -24,8 +24,8 @@ import java.util.Map;
*/
*/
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/qiNiuContent
"
)
@Api
(
tags
=
"七牛云存储管理"
)
@Api
(
tags
=
"
工具:
七牛云存储管理"
)
public
class
QiniuController
{
public
class
QiniuController
{
private
final
QiNiuService
qiNiuService
;
private
final
QiNiuService
qiNiuService
;
...
@@ -34,14 +34,14 @@ public class QiniuController {
...
@@ -34,14 +34,14 @@ public class QiniuController {
this
.
qiNiuService
=
qiNiuService
;
this
.
qiNiuService
=
qiNiuService
;
}
}
@GetMapping
(
value
=
"/
qiNiuC
onfig"
)
@GetMapping
(
value
=
"/
c
onfig"
)
public
ResponseEntity
get
(){
public
ResponseEntity
get
(){
return
new
ResponseEntity
<>(
qiNiuService
.
find
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
qiNiuService
.
find
(),
HttpStatus
.
OK
);
}
}
@Log
(
"配置七牛云存储"
)
@Log
(
"配置七牛云存储"
)
@ApiOperation
(
value
=
"配置七牛云存储"
)
@ApiOperation
(
"配置七牛云存储"
)
@PutMapping
(
value
=
"/
qiNiuC
onfig"
)
@PutMapping
(
value
=
"/
c
onfig"
)
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
QiniuConfig
qiniuConfig
){
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
QiniuConfig
qiniuConfig
){
qiNiuService
.
update
(
qiniuConfig
);
qiNiuService
.
update
(
qiniuConfig
);
qiNiuService
.
update
(
qiniuConfig
.
getType
());
qiNiuService
.
update
(
qiniuConfig
.
getType
());
...
@@ -49,15 +49,15 @@ public class QiniuController {
...
@@ -49,15 +49,15 @@ public class QiniuController {
}
}
@Log
(
"查询文件"
)
@Log
(
"查询文件"
)
@ApiOperation
(
value
=
"查询文件"
)
@ApiOperation
(
"查询文件"
)
@GetMapping
(
value
=
"/qiNiuContent"
)
@GetMapping
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
);
}
}
@Log
(
"上传文件"
)
@Log
(
"上传文件"
)
@ApiOperation
(
value
=
"上传文件"
)
@ApiOperation
(
"上传文件"
)
@PostMapping
(
value
=
"/qiNiuContent"
)
@PostMapping
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
<
String
,
Object
>
map
=
new
HashMap
<>(
3
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
3
);
...
@@ -68,16 +68,16 @@ public class QiniuController {
...
@@ -68,16 +68,16 @@ public class QiniuController {
}
}
@Log
(
"同步七牛云数据"
)
@Log
(
"同步七牛云数据"
)
@ApiOperation
(
value
=
"同步七牛云数据"
)
@ApiOperation
(
"同步七牛云数据"
)
@PostMapping
(
value
=
"/
qiNiuContent/
synchronize"
)
@PostMapping
(
value
=
"/synchronize"
)
public
ResponseEntity
synchronize
(){
public
ResponseEntity
synchronize
(){
qiNiuService
.
synchronize
(
qiNiuService
.
find
());
qiNiuService
.
synchronize
(
qiNiuService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
@Log
(
"下载文件"
)
@Log
(
"下载文件"
)
@ApiOperation
(
value
=
"下载文件"
)
@ApiOperation
(
"下载文件"
)
@GetMapping
(
value
=
"/
qiNiuContent/
download/{id}"
)
@GetMapping
(
value
=
"/download/{id}"
)
public
ResponseEntity
download
(
@PathVariable
Long
id
){
public
ResponseEntity
download
(
@PathVariable
Long
id
){
Map
<
String
,
Object
>
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
()));
...
@@ -85,16 +85,16 @@ public class QiniuController {
...
@@ -85,16 +85,16 @@ public class QiniuController {
}
}
@Log
(
"删除文件"
)
@Log
(
"删除文件"
)
@ApiOperation
(
value
=
"删除文件"
)
@ApiOperation
(
"删除文件"
)
@DeleteMapping
(
value
=
"/
qiNiuContent/
{id}"
)
@DeleteMapping
(
value
=
"/{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
(
"删除多张图片"
)
@Log
(
"删除多张图片"
)
@ApiOperation
(
value
=
"删除多张图片"
)
@ApiOperation
(
"删除多张图片"
)
@DeleteMapping
(
value
=
"/qiNiuContent"
)
@DeleteMapping
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
qiNiuService
.
deleteAll
(
ids
,
qiNiuService
.
find
());
qiNiuService
.
deleteAll
(
ids
,
qiNiuService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java
View file @
bf7c1eeb
...
@@ -7,10 +7,8 @@ import me.zhengjie.domain.vo.EmailVo;
...
@@ -7,10 +7,8 @@ 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.Qualifier
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
/**
/**
...
@@ -18,21 +16,21 @@ import org.springframework.web.bind.annotation.*;
...
@@ -18,21 +16,21 @@ import org.springframework.web.bind.annotation.*;
* @date 2018-12-26
* @date 2018-12-26
*/
*/
@RestController
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/code
"
)
@Api
(
tags
=
"验证码管理"
)
@Api
(
tags
=
"
工具:
验证码管理"
)
public
class
VerificationCodeController
{
public
class
VerificationCodeController
{
private
final
VerificationCodeService
verificationCodeService
;
private
final
VerificationCodeService
verificationCodeService
;
private
final
EmailService
emailService
;
private
final
EmailService
emailService
;
public
VerificationCodeController
(
VerificationCodeService
verificationCodeService
,
@Qualifier
(
"jwtUserDetailsService"
)
UserDetailsService
userDetailsService
,
EmailService
emailService
)
{
public
VerificationCodeController
(
VerificationCodeService
verificationCodeService
,
EmailService
emailService
)
{
this
.
verificationCodeService
=
verificationCodeService
;
this
.
verificationCodeService
=
verificationCodeService
;
this
.
emailService
=
emailService
;
this
.
emailService
=
emailService
;
}
}
@PostMapping
(
value
=
"/
code/
resetEmail"
)
@PostMapping
(
value
=
"/resetEmail"
)
@ApiOperation
(
value
=
"重置邮箱,发送验证码"
)
@ApiOperation
(
"重置邮箱,发送验证码"
)
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
);
...
@@ -40,8 +38,8 @@ public class VerificationCodeController {
...
@@ -40,8 +38,8 @@ public class VerificationCodeController {
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
@PostMapping
(
value
=
"/
code/
email/resetPass"
)
@PostMapping
(
value
=
"/email/resetPass"
)
@ApiOperation
(
value
=
"重置密码,发送验证码"
)
@ApiOperation
(
"重置密码,发送验证码"
)
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"
);
...
@@ -52,8 +50,8 @@ public class VerificationCodeController {
...
@@ -52,8 +50,8 @@ public class VerificationCodeController {
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
"/
code/
validated"
)
@GetMapping
(
value
=
"/validated"
)
@ApiOperation
(
value
=
"验证码验证"
)
@ApiOperation
(
"验证码验证"
)
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 @
bf7c1eeb
...
@@ -10,7 +10,6 @@ import org.springframework.cache.annotation.Cacheable;
...
@@ -10,7 +10,6 @@ import org.springframework.cache.annotation.Cacheable;
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-31
* @date 2018-12-31
*/
*/
@CacheConfig
(
cacheNames
=
"alipay"
)
public
interface
AlipayService
{
public
interface
AlipayService
{
/**
/**
...
@@ -35,7 +34,6 @@ public interface AlipayService {
...
@@ -35,7 +34,6 @@ public interface AlipayService {
* 查询配置
* 查询配置
* @return AlipayConfig
* @return AlipayConfig
*/
*/
@Cacheable
(
key
=
"'1'"
)
AlipayConfig
find
();
AlipayConfig
find
();
/**
/**
...
@@ -43,6 +41,5 @@ public interface AlipayService {
...
@@ -43,6 +41,5 @@ public interface AlipayService {
* @param alipayConfig 支付宝配置
* @param alipayConfig 支付宝配置
* @return AlipayConfig
* @return AlipayConfig
*/
*/
@CachePut
(
key
=
"'1'"
)
AlipayConfig
update
(
AlipayConfig
alipayConfig
);
AlipayConfig
update
(
AlipayConfig
alipayConfig
);
}
}
eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java
View file @
bf7c1eeb
...
@@ -2,16 +2,12 @@ package me.zhengjie.service;
...
@@ -2,16 +2,12 @@ package me.zhengjie.service;
import
me.zhengjie.domain.EmailConfig
;
import
me.zhengjie.domain.EmailConfig
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.domain.vo.EmailVo
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-26
* @date 2018-12-26
*/
*/
@CacheConfig
(
cacheNames
=
"email"
)
public
interface
EmailService
{
public
interface
EmailService
{
/**
/**
...
@@ -20,14 +16,12 @@ public interface EmailService {
...
@@ -20,14 +16,12 @@ public interface EmailService {
* @param old 旧的配置
* @param old 旧的配置
* @return EmailConfig
* @return EmailConfig
*/
*/
@CachePut
(
key
=
"'1'"
)
EmailConfig
update
(
EmailConfig
emailConfig
,
EmailConfig
old
);
EmailConfig
update
(
EmailConfig
emailConfig
,
EmailConfig
old
);
/**
/**
* 查询配置
* 查询配置
* @return EmailConfig 邮件配置
* @return EmailConfig 邮件配置
*/
*/
@Cacheable
(
key
=
"'1'"
)
EmailConfig
find
();
EmailConfig
find
();
/**
/**
...
...
eladmin-tools/src/main/java/me/zhengjie/service/LocalStorageService.java
View file @
bf7c1eeb
...
@@ -3,9 +3,6 @@ package me.zhengjie.service;
...
@@ -3,9 +3,6 @@ package me.zhengjie.service;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.domain.LocalStorage
;
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
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -13,61 +10,19 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -13,61 +10,19 @@ import org.springframework.web.multipart.MultipartFile;
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-09-05
* @date 2019-09-05
*/
*/
@CacheConfig
(
cacheNames
=
"localStorage"
)
public
interface
LocalStorageService
{
public
interface
LocalStorageService
{
/**
* queryAll 分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Object
*/
@Cacheable
Object
queryAll
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
);
/**
* queryAll 不分页
* @param criteria 条件参数
* @return Object
*/
@Cacheable
Object
queryAll
(
LocalStorageQueryCriteria
criteria
);
Object
queryAll
(
LocalStorageQueryCriteria
criteria
);
/**
* findById
* @param id
* @return LocalStorageDTO
*/
@Cacheable
(
key
=
"#p0"
)
LocalStorageDTO
findById
(
Long
id
);
LocalStorageDTO
findById
(
Long
id
);
/**
* create
* @param name 文件名称
* @param file 文件资源
* @return LocalStorageDTO
*/
@CacheEvict
(
allEntries
=
true
)
LocalStorageDTO
create
(
String
name
,
MultipartFile
file
);
LocalStorageDTO
create
(
String
name
,
MultipartFile
file
);
/**
* update
* @param resources 资源实体
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
LocalStorage
resources
);
void
update
(
LocalStorage
resources
);
/**
* delete
* @param id 文件ID
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
void
delete
(
Long
id
);
/**
* 多文件删除
* @param ids 文件数组
*/
@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 @
bf7c1eeb
...
@@ -2,55 +2,22 @@ package me.zhengjie.service;
...
@@ -2,55 +2,22 @@ package me.zhengjie.service;
import
me.zhengjie.domain.Picture
;
import
me.zhengjie.domain.Picture
;
import
me.zhengjie.service.dto.PictureQueryCriteria
;
import
me.zhengjie.service.dto.PictureQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-27
* @date 2018-12-27
*/
*/
@CacheConfig
(
cacheNames
=
"picture"
)
public
interface
PictureService
{
public
interface
PictureService
{
/**
* 查询图片
* @param criteria 条件参数
* @param pageable 分页参数
* @return Object
*/
@Cacheable
Object
queryAll
(
PictureQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
PictureQueryCriteria
criteria
,
Pageable
pageable
);
/**
* 上传图片
* @param file 文件
* @param username 用户名
* @return
*/
@CacheEvict
(
allEntries
=
true
)
Picture
upload
(
MultipartFile
file
,
String
username
);
Picture
upload
(
MultipartFile
file
,
String
username
);
/**
* 根据ID查询
* @param id 文件ID
* @return
*/
@Cacheable
(
key
=
"#p0"
)
Picture
findById
(
Long
id
);
Picture
findById
(
Long
id
);
/**
* 删除图片
* @param picture 图片实体
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Picture
picture
);
void
delete
(
Picture
picture
);
/**
* 删除图片
* @param ids 文件ID数组
*/
@CacheEvict
(
allEntries
=
true
)
void
deleteAll
(
Long
[]
ids
);
void
deleteAll
(
Long
[]
ids
);
}
}
eladmin-tools/src/main/java/me/zhengjie/service/QiNiuService.java
View file @
bf7c1eeb
...
@@ -3,66 +3,49 @@ package me.zhengjie.service;
...
@@ -3,66 +3,49 @@ package me.zhengjie.service;
import
me.zhengjie.domain.QiniuConfig
;
import
me.zhengjie.domain.QiniuConfig
;
import
me.zhengjie.domain.QiniuContent
;
import
me.zhengjie.domain.QiniuContent
;
import
me.zhengjie.service.dto.QiniuQueryCriteria
;
import
me.zhengjie.service.dto.QiniuQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-31
* @date 2018-12-31
*/
*/
@CacheConfig
(
cacheNames
=
"qiNiu"
)
public
interface
QiNiuService
{
public
interface
QiNiuService
{
/**
* 查询文件
* @param criteria 条件参数
* @param pageable 分页参数
* @return Object
*/
@Cacheable
Object
queryAll
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
QiniuQueryCriteria
criteria
,
Pageable
pageable
);
/**
/**
* 查配置
* 查配置
* @return Cacheable
* @return Cacheable
*/
*/
@Cacheable
(
cacheNames
=
"qiNiuConfig"
,
key
=
"'1'"
)
QiniuConfig
find
();
QiniuConfig
find
();
/**
/**
* 修改配置
* 修改配置
* @param qiniuConfig
* @param qiniuConfig
配置
* @return QiniuConfig
* @return QiniuConfig
*/
*/
@CachePut
(
cacheNames
=
"qiNiuConfig"
,
key
=
"'1'"
)
QiniuConfig
update
(
QiniuConfig
qiniuConfig
);
QiniuConfig
update
(
QiniuConfig
qiniuConfig
);
/**
/**
* 上传文件
* 上传文件
* @param file
* @param file
文件
* @param qiniuConfig
* @param qiniuConfig
配置
* @return QiniuContent
* @return QiniuContent
*/
*/
@CacheEvict
(
allEntries
=
true
)
QiniuContent
upload
(
MultipartFile
file
,
QiniuConfig
qiniuConfig
);
QiniuContent
upload
(
MultipartFile
file
,
QiniuConfig
qiniuConfig
);
/**
/**
* 查询文件
* 查询文件
* @param id
* @param id
文件ID
* @return QiniuContent
* @return QiniuContent
*/
*/
@Cacheable
(
key
=
"'content:'+#p0"
)
QiniuContent
findByContentId
(
Long
id
);
QiniuContent
findByContentId
(
Long
id
);
/**
/**
* 下载文件
* 下载文件
* @param content
* @param content
文件信息
* @param config
* @param config
配置
* @return String
* @return String
*/
*/
String
download
(
QiniuContent
content
,
QiniuConfig
config
);
String
download
(
QiniuContent
content
,
QiniuConfig
config
);
...
@@ -72,14 +55,12 @@ public interface QiNiuService {
...
@@ -72,14 +55,12 @@ public interface QiNiuService {
* @param content 文件
* @param content 文件
* @param config 配置
* @param config 配置
*/
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
QiniuContent
content
,
QiniuConfig
config
);
void
delete
(
QiniuContent
content
,
QiniuConfig
config
);
/**
/**
* 同步数据
* 同步数据
* @param config 配置
* @param config 配置
*/
*/
@CacheEvict
(
allEntries
=
true
)
void
synchronize
(
QiniuConfig
config
);
void
synchronize
(
QiniuConfig
config
);
/**
/**
...
@@ -87,13 +68,11 @@ public interface QiNiuService {
...
@@ -87,13 +68,11 @@ public interface QiNiuService {
* @param ids 文件ID数组
* @param ids 文件ID数组
* @param config 配置
* @param config 配置
*/
*/
@CacheEvict
(
allEntries
=
true
)
void
deleteAll
(
Long
[]
ids
,
QiniuConfig
config
);
void
deleteAll
(
Long
[]
ids
,
QiniuConfig
config
);
/**
/**
* 更新数据
* 更新数据
* @param type 类型
* @param type 类型
*/
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
String
type
);
void
update
(
String
type
);
}
}
eladmin-tools/src/main/java/me/zhengjie/service/impl/AlipayServiceImpl.java
View file @
bf7c1eeb
...
@@ -9,8 +9,9 @@ import me.zhengjie.domain.vo.TradeVo;
...
@@ -9,8 +9,9 @@ import me.zhengjie.domain.vo.TradeVo;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.repository.AlipayRepository
;
import
me.zhengjie.repository.AlipayRepository
;
import
me.zhengjie.service.AlipayService
;
import
me.zhengjie.service.AlipayService
;
import
me.zhengjie.utils.AlipayUtils
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
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
;
...
@@ -21,14 +22,15 @@ import java.util.Optional;
...
@@ -21,14 +22,15 @@ import java.util.Optional;
* @date 2018-12-31
* @date 2018-12-31
*/
*/
@Service
@Service
@CacheConfig
(
cacheNames
=
"alipay"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
AlipayServiceImpl
implements
AlipayService
{
public
class
AlipayServiceImpl
implements
AlipayService
{
@Autowired
private
final
AlipayRepository
alipayRepository
;
AlipayUtils
alipayUtils
;
@Autowired
public
AlipayServiceImpl
(
AlipayRepository
alipayRepository
)
{
private
AlipayRepository
alipayRepository
;
this
.
alipayRepository
=
alipayRepository
;
}
@Override
@Override
public
String
toPayAsPC
(
AlipayConfig
alipay
,
TradeVo
trade
)
throws
Exception
{
public
String
toPayAsPC
(
AlipayConfig
alipay
,
TradeVo
trade
)
throws
Exception
{
...
@@ -38,7 +40,7 @@ public class AlipayServiceImpl implements AlipayService {
...
@@ -38,7 +40,7 @@ public class AlipayServiceImpl implements AlipayService {
}
}
AlipayClient
alipayClient
=
new
DefaultAlipayClient
(
alipay
.
getGatewayUrl
(),
alipay
.
getAppID
(),
alipay
.
getPrivateKey
(),
alipay
.
getFormat
(),
alipay
.
getCharset
(),
alipay
.
getPublicKey
(),
alipay
.
getSignType
());
AlipayClient
alipayClient
=
new
DefaultAlipayClient
(
alipay
.
getGatewayUrl
(),
alipay
.
getAppID
(),
alipay
.
getPrivateKey
(),
alipay
.
getFormat
(),
alipay
.
getCharset
(),
alipay
.
getPublicKey
(),
alipay
.
getSignType
());
double
money
=
Double
.
parseDouble
(
trade
.
getTotalAmount
());
//
double money = Double.parseDouble(trade.getTotalAmount());
// 创建API对应的request(电脑网页版)
// 创建API对应的request(电脑网页版)
AlipayTradePagePayRequest
request
=
new
AlipayTradePagePayRequest
();
AlipayTradePagePayRequest
request
=
new
AlipayTradePagePayRequest
();
...
@@ -91,12 +93,14 @@ public class AlipayServiceImpl implements AlipayService {
...
@@ -91,12 +93,14 @@ public class AlipayServiceImpl implements AlipayService {
}
}
@Override
@Override
@Cacheable
(
key
=
"'1'"
)
public
AlipayConfig
find
()
{
public
AlipayConfig
find
()
{
Optional
<
AlipayConfig
>
alipayConfig
=
alipayRepository
.
findById
(
1L
);
Optional
<
AlipayConfig
>
alipayConfig
=
alipayRepository
.
findById
(
1L
);
return
alipayConfig
.
orElseGet
(
AlipayConfig:
:
new
);
return
alipayConfig
.
orElseGet
(
AlipayConfig:
:
new
);
}
}
@Override
@Override
@CachePut
(
key
=
"'1'"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
AlipayConfig
update
(
AlipayConfig
alipayConfig
)
{
public
AlipayConfig
update
(
AlipayConfig
alipayConfig
)
{
return
alipayRepository
.
save
(
alipayConfig
);
return
alipayRepository
.
save
(
alipayConfig
);
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java
View file @
bf7c1eeb
...
@@ -8,6 +8,9 @@ import me.zhengjie.exception.BadRequestException;
...
@@ -8,6 +8,9 @@ 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.EncryptUtils
;
import
me.zhengjie.utils.EncryptUtils
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
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
;
...
@@ -18,6 +21,7 @@ import java.util.Optional;
...
@@ -18,6 +21,7 @@ import java.util.Optional;
* @date 2018-12-26
* @date 2018-12-26
*/
*/
@Service
@Service
@CacheConfig
(
cacheNames
=
"email"
)
@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
{
...
@@ -28,6 +32,7 @@ public class EmailServiceImpl implements EmailService {
...
@@ -28,6 +32,7 @@ public class EmailServiceImpl implements EmailService {
}
}
@Override
@Override
@CachePut
(
key
=
"'1'"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
EmailConfig
update
(
EmailConfig
emailConfig
,
EmailConfig
old
)
{
public
EmailConfig
update
(
EmailConfig
emailConfig
,
EmailConfig
old
)
{
try
{
try
{
...
@@ -42,6 +47,7 @@ public class EmailServiceImpl implements EmailService {
...
@@ -42,6 +47,7 @@ public class EmailServiceImpl implements EmailService {
}
}
@Override
@Override
@Cacheable
(
key
=
"'1'"
)
public
EmailConfig
find
()
{
public
EmailConfig
find
()
{
Optional
<
EmailConfig
>
emailConfig
=
emailRepository
.
findById
(
1L
);
Optional
<
EmailConfig
>
emailConfig
=
emailRepository
.
findById
(
1L
);
return
emailConfig
.
orElseGet
(
EmailConfig:
:
new
);
return
emailConfig
.
orElseGet
(
EmailConfig:
:
new
);
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java
View file @
bf7c1eeb
package
me.zhengjie.service.impl
;
package
me.zhengjie.service.impl
;
import
cn.hutool.core.util.ObjectUtil
;
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
;
...
@@ -8,11 +10,13 @@ import me.zhengjie.service.dto.LocalStorageDTO;
...
@@ -8,11 +10,13 @@ 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.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
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
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -22,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -22,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
* @date 2019-09-05
* @date 2019-09-05
*/
*/
@Service
@Service
@CacheConfig
(
cacheNames
=
"localStorage"
)
@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
{
...
@@ -41,24 +46,28 @@ public class LocalStorageServiceImpl implements LocalStorageService {
...
@@ -41,24 +46,28 @@ public class LocalStorageServiceImpl implements LocalStorageService {
}
}
@Override
@Override
@Cacheable
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
);
return
PageUtil
.
toPage
(
page
.
map
(
localStorageMapper:
:
toDto
));
return
PageUtil
.
toPage
(
page
.
map
(
localStorageMapper:
:
toDto
));
}
}
@Override
@Override
@Cacheable
public
Object
queryAll
(
LocalStorageQueryCriteria
criteria
){
public
Object
queryAll
(
LocalStorageQueryCriteria
criteria
){
return
localStorageMapper
.
toDto
(
localStorageRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
return
localStorageMapper
.
toDto
(
localStorageRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
}
}
@Override
@Override
public
LocalStorageDTO
findById
(
Long
id
)
{
@Cacheable
(
key
=
"#p0"
)
Optional
<
LocalStorage
>
localStorage
=
localStorageRepository
.
findById
(
id
);
public
LocalStorageDTO
findById
(
Long
id
){
ValidationUtil
.
isNull
(
localStorage
,
"LocalStorage"
,
"id"
,
id
);
LocalStorage
localStorage
=
localStorageRepository
.
findById
(
id
).
orElseGet
(
LocalStorage:
:
new
);
return
localStorageMapper
.
toDto
(
localStorage
.
get
());
ValidationUtil
.
isNull
(
localStorage
.
getId
(),
"LocalStorage"
,
"id"
,
id
);
return
localStorageMapper
.
toDto
(
localStorage
);
}
}
@Override
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
LocalStorageDTO
create
(
String
name
,
MultipartFile
multipartFile
)
{
public
LocalStorageDTO
create
(
String
name
,
MultipartFile
multipartFile
)
{
FileUtil
.
checkSize
(
maxSize
,
multipartFile
.
getSize
());
FileUtil
.
checkSize
(
maxSize
,
multipartFile
.
getSize
());
...
@@ -67,6 +76,9 @@ public class LocalStorageServiceImpl implements LocalStorageService {
...
@@ -67,6 +76,9 @@ public class LocalStorageServiceImpl implements LocalStorageService {
// String type = FileUtil.getFileTypeByMimeType(suffix);
// String type = FileUtil.getFileTypeByMimeType(suffix);
String
type
=
FileUtil
.
getFileType
(
suffix
);
String
type
=
FileUtil
.
getFileType
(
suffix
);
File
file
=
FileUtil
.
upload
(
multipartFile
,
path
+
type
+
File
.
separator
);
File
file
=
FileUtil
.
upload
(
multipartFile
,
path
+
type
+
File
.
separator
);
if
(
ObjectUtil
.
isNull
(
file
)){
throw
new
BadRequestException
(
"上传失败"
);
}
try
{
try
{
name
=
StringUtils
.
isBlank
(
name
)
?
FileUtil
.
getFileNameNoEx
(
multipartFile
.
getOriginalFilename
())
:
name
;
name
=
StringUtils
.
isBlank
(
name
)
?
FileUtil
.
getFileNameNoEx
(
multipartFile
.
getOriginalFilename
())
:
name
;
LocalStorage
localStorage
=
new
LocalStorage
(
LocalStorage
localStorage
=
new
LocalStorage
(
...
@@ -86,28 +98,30 @@ public class LocalStorageServiceImpl implements LocalStorageService {
...
@@ -86,28 +98,30 @@ public class LocalStorageServiceImpl implements LocalStorageService {
}
}
@Override
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
LocalStorage
resources
)
{
public
void
update
(
LocalStorage
resources
)
{
Optional
<
LocalStorage
>
optionalLocalStorage
=
localStorageRepository
.
findById
(
resources
.
getId
());
LocalStorage
localStorage
=
localStorageRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
LocalStorage:
:
new
);
ValidationUtil
.
isNull
(
optionalLocalStorage
,
"LocalStorage"
,
"id"
,
resources
.
getId
());
ValidationUtil
.
isNull
(
localStorage
.
getId
(),
"LocalStorage"
,
"id"
,
resources
.
getId
());
LocalStorage
localStorage
=
optionalLocalStorage
.
get
();
localStorage
.
copy
(
resources
);
localStorage
.
copy
(
resources
);
localStorageRepository
.
save
(
localStorage
);
localStorageRepository
.
save
(
localStorage
);
}
}
@Override
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
public
void
delete
(
Long
id
)
{
LocalStorage
storage
=
localStorageRepository
.
findById
(
id
).
get
(
);
LocalStorage
storage
=
localStorageRepository
.
findById
(
id
).
orElseGet
(
LocalStorage:
:
new
);
FileUtil
.
del
(
storage
.
getPath
());
FileUtil
.
del
(
storage
.
getPath
());
localStorageRepository
.
delete
(
storage
);
localStorageRepository
.
delete
(
storage
);
}
}
@Override
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteAll
(
Long
[]
ids
)
{
public
void
deleteAll
(
Long
[]
ids
)
{
for
(
Long
id
:
ids
)
{
for
(
Long
id
:
ids
)
{
LocalStorage
storage
=
localStorageRepository
.
findById
(
id
).
get
(
);
LocalStorage
storage
=
localStorageRepository
.
findById
(
id
).
orElseGet
(
LocalStorage:
:
new
);
FileUtil
.
del
(
storage
.
getPath
());
FileUtil
.
del
(
storage
.
getPath
());
localStorageRepository
.
delete
(
storage
);
localStorageRepository
.
delete
(
storage
);
}
}
...
...
Prev
1
…
3
4
5
6
7
8
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