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
21f8b4eb
Commit
21f8b4eb
authored
May 24, 2020
by
ZhengJie
Browse files
[代码完善](v2.5): v2.5 beta 事务优化
close #362
parent
d9886066
Changes
22
Hide whitespace changes
Inline
Side-by-side
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
View file @
21f8b4eb
...
...
@@ -31,7 +31,6 @@ import org.aspectj.lang.reflect.MethodSignature;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -44,7 +43,6 @@ import java.util.*;
*/
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
LogServiceImpl
implements
LogService
{
private
final
LogRepository
logRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.java
View file @
21f8b4eb
...
...
@@ -30,7 +30,6 @@ import me.zhengjie.utils.ValidationUtil;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -42,7 +41,6 @@ import java.util.*;
*/
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
AppServiceImpl
implements
AppService
{
private
final
AppRepository
appRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DatabaseServiceImpl.java
View file @
21f8b4eb
...
...
@@ -32,7 +32,6 @@ import me.zhengjie.utils.ValidationUtil;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -45,7 +44,6 @@ import java.util.*;
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DatabaseServiceImpl
implements
DatabaseService
{
private
final
DatabaseRepository
databaseRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java
View file @
21f8b4eb
...
...
@@ -30,7 +30,6 @@ import me.zhengjie.utils.ValidationUtil;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -42,7 +41,6 @@ import java.util.*;
*/
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DeployHistoryServiceImpl
implements
DeployHistoryService
{
private
final
DeployHistoryRepository
deployhistoryRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java
View file @
21f8b4eb
...
...
@@ -42,9 +42,7 @@ import me.zhengjie.utils.*;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
...
...
@@ -56,7 +54,6 @@ import java.util.*;
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DeployServiceImpl
implements
DeployService
{
private
final
String
FILE_SEPARATOR
=
"/"
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java
View file @
21f8b4eb
...
...
@@ -30,7 +30,6 @@ import me.zhengjie.utils.ValidationUtil;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -42,7 +41,6 @@ import java.util.*;
*/
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
ServerDeployServiceImpl
implements
ServerDeployService
{
private
final
ServerDeployRepository
serverDeployRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java
View file @
21f8b4eb
...
...
@@ -31,7 +31,6 @@ import me.zhengjie.utils.ValidationUtil;
import
org.quartz.CronExpression
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -43,7 +42,6 @@ import java.util.*;
*/
@RequiredArgsConstructor
@Service
(
value
=
"quartzJobService"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
QuartzJobServiceImpl
implements
QuartzJobService
{
private
final
QuartzJobRepository
quartzJobRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java
View file @
21f8b4eb
...
...
@@ -26,8 +26,6 @@ import me.zhengjie.modules.system.service.dto.UserDto;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @author Zheng Jie
...
...
@@ -35,7 +33,6 @@ import org.springframework.transaction.annotation.Transactional;
*/
@RequiredArgsConstructor
@Service
(
"userDetailsService"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
UserDetailsServiceImpl
implements
UserDetailsService
{
private
final
UserService
userService
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java
View file @
21f8b4eb
...
...
@@ -36,7 +36,6 @@ import org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -51,7 +50,6 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"dept"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DeptServiceImpl
implements
DeptService
{
private
final
DeptRepository
deptRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java
View file @
21f8b4eb
...
...
@@ -33,7 +33,6 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -45,7 +44,6 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"dict"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DictDetailServiceImpl
implements
DictDetailService
{
private
final
DictRepository
dictRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java
View file @
21f8b4eb
...
...
@@ -26,11 +26,9 @@ import me.zhengjie.modules.system.service.DictService;
import
me.zhengjie.modules.system.service.dto.DictDto
;
import
me.zhengjie.modules.system.service.mapstruct.DictMapper
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -43,7 +41,6 @@ import java.util.*;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"dict"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DictServiceImpl
implements
DictService
{
private
final
DictRepository
dictRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobServiceImpl.java
View file @
21f8b4eb
...
...
@@ -32,7 +32,6 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -45,7 +44,6 @@ import java.util.*;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"job"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
JobServiceImpl
implements
JobService
{
private
final
JobRepository
jobRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
View file @
21f8b4eb
...
...
@@ -37,7 +37,6 @@ import org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -51,7 +50,6 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"menu"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
MenuServiceImpl
implements
MenuService
{
private
final
MenuRepository
menuRepository
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java
View file @
21f8b4eb
...
...
@@ -39,7 +39,6 @@ import org.springframework.data.domain.Sort;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -53,7 +52,6 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"role"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
RoleServiceImpl
implements
RoleService
{
private
final
RoleRepository
roleRepository
;
...
...
@@ -80,6 +78,7 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@Transactional
@Cacheable
(
key
=
"'id:' + #p0"
)
public
RoleDto
findById
(
long
id
)
{
Role
role
=
roleRepository
.
findById
(
id
).
orElseGet
(
Role:
:
new
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
21f8b4eb
...
...
@@ -33,7 +33,6 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -49,7 +48,6 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"user"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
UserServiceImpl
implements
UserService
{
private
final
UserRepository
userRepository
;
...
...
@@ -70,6 +68,7 @@ public class UserServiceImpl implements UserService {
}
@Override
@Transactional
@Cacheable
(
key
=
"'id:' + #p0"
)
public
UserDto
findById
(
long
id
)
{
User
user
=
userRepository
.
findById
(
id
).
orElseGet
(
User:
:
new
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java
View file @
21f8b4eb
...
...
@@ -28,7 +28,6 @@ import me.zhengjie.modules.system.service.VerifyService;
import
me.zhengjie.utils.RedisUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Collections
;
...
...
@@ -38,7 +37,6 @@ import java.util.Collections;
*/
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
VerifyServiceImpl
implements
VerifyService
{
@Value
(
"${code.expiration}"
)
...
...
eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl
View file @
21f8b4eb
...
...
@@ -34,7 +34,6 @@ import ${package}.service.dto.${className}Dto;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
$
{
package
}
.service.mapstruct.$
{
className
}
Mapper;
import
org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional;
<#
if
!auto && pkColumnType = 'Long'>
import
cn.hutool.core.lang.Snowflake;
...
...
@@ -62,7 +61,6 @@ import java.util.LinkedHashMap;
**/
@
Service
@
RequiredArgsConstructor
@
Transactional
(
propagation
=
Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public
class $
{
className
}
ServiceImpl implements $
{
className
}
Service
{
private
final
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
;
...
...
@@ -80,6 +78,7 @@ public class ${className}ServiceImpl implements ${className}Service {
}
@
O
verride
@
T
ransactional
public
$
{
className
}
D
to
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
$
{
className
}
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
$
{
pkChangeColName
})
.orElseGet
(
$
{
className
}::
new
)
;
V
alidationUtil
.isNull
(
$
{
changeClassName
}
.get
$
{
pkCapitalColName
}(),
"${className}"
,
"${pkChangeColName}"
,
$
{
pkChangeColName
})
;
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/AliPayServiceImpl.java
View file @
21f8b4eb
...
...
@@ -29,7 +29,6 @@ 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.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Optional
;
...
...
@@ -40,7 +39,6 @@ import java.util.Optional;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"alipay"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
AliPayServiceImpl
implements
AliPayService
{
private
final
AliPayRepository
alipayRepository
;
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java
View file @
21f8b4eb
...
...
@@ -28,7 +28,6 @@ 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.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Optional
;
...
...
@@ -39,7 +38,6 @@ import java.util.Optional;
@Service
@RequiredArgsConstructor
@CacheConfig
(
cacheNames
=
"email"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
EmailServiceImpl
implements
EmailService
{
private
final
EmailRepository
emailRepository
;
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java
View file @
21f8b4eb
...
...
@@ -27,7 +27,6 @@ import me.zhengjie.utils.*;
import
me.zhengjie.repository.LocalStorageRepository
;
import
me.zhengjie.service.LocalStorageService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -46,7 +45,6 @@ import javax.servlet.http.HttpServletResponse;
*/
@Service
@RequiredArgsConstructor
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
LocalStorageServiceImpl
implements
LocalStorageService
{
private
final
LocalStorageRepository
localStorageRepository
;
...
...
Prev
1
2
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