Commit d3f28b92a76af82d78977bd14650a13e9fc10f20
1 parent
9fbc953d
【代码优化】SYSTEM:认证令牌的操作,增加 @Transactional 注解
Showing
3 changed files
with
37 additions
and
35 deletions
pom.xml
| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | <!-- 各种 module 拓展 --> |
| 16 | 16 | <module>yudao-module-system</module> |
| 17 | 17 | <module>yudao-module-infra</module> |
| 18 | -<!-- <module>yudao-module-member</module>--> | |
| 18 | + <module>yudao-module-member</module> | |
| 19 | 19 | <!-- <module>yudao-module-bpm</module>--> |
| 20 | 20 | <!-- <module>yudao-module-report</module>--> |
| 21 | 21 | <!-- <module>yudao-module-mp</module>--> |
| 22 | -<!-- <module>yudao-module-pay</module>--> | |
| 23 | -<!-- <module>yudao-module-mall</module>--> | |
| 22 | + <module>yudao-module-pay</module> | |
| 23 | + <module>yudao-module-mall</module> | |
| 24 | 24 | <!-- <module>yudao-module-crm</module>--> |
| 25 | 25 | <!-- <module>yudao-module-erp</module>--> |
| 26 | 26 | <!-- <module>yudao-module-ai</module>--> | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImpl.java
| ... | ... | @@ -56,7 +56,7 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { |
| 56 | 56 | private AdminUserService adminUserService; |
| 57 | 57 | |
| 58 | 58 | @Override |
| 59 | - @Transactional | |
| 59 | + @Transactional(rollbackFor = Exception.class) | |
| 60 | 60 | public OAuth2AccessTokenDO createAccessToken(Long userId, Integer userType, String clientId, List<String> scopes) { |
| 61 | 61 | OAuth2ClientDO clientDO = oauth2ClientService.validOAuthClientFromCache(clientId); |
| 62 | 62 | // 创建刷新令牌 |
| ... | ... | @@ -66,6 +66,7 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | @Override |
| 69 | + @Transactional(rollbackFor = Exception.class) | |
| 69 | 70 | public OAuth2AccessTokenDO refreshAccessToken(String refreshToken, String clientId) { |
| 70 | 71 | // 查询访问令牌 |
| 71 | 72 | OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectByRefreshToken(refreshToken); |
| ... | ... | @@ -82,7 +83,7 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { |
| 82 | 83 | // 移除相关的访问令牌 |
| 83 | 84 | List<OAuth2AccessTokenDO> accessTokenDOs = oauth2AccessTokenMapper.selectListByRefreshToken(refreshToken); |
| 84 | 85 | if (CollUtil.isNotEmpty(accessTokenDOs)) { |
| 85 | - oauth2AccessTokenMapper.deleteBatchIds(convertSet(accessTokenDOs, OAuth2AccessTokenDO::getId)); | |
| 86 | + oauth2AccessTokenMapper.deleteByIds(convertSet(accessTokenDOs, OAuth2AccessTokenDO::getId)); | |
| 86 | 87 | oauth2AccessTokenRedisDAO.deleteList(convertSet(accessTokenDOs, OAuth2AccessTokenDO::getAccessToken)); |
| 87 | 88 | } |
| 88 | 89 | |
| ... | ... | @@ -126,6 +127,7 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { |
| 126 | 127 | } |
| 127 | 128 | |
| 128 | 129 | @Override |
| 130 | + @Transactional(rollbackFor = Exception.class) | |
| 129 | 131 | public OAuth2AccessTokenDO removeAccessToken(String accessToken) { |
| 130 | 132 | // 删除访问令牌 |
| 131 | 133 | OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(accessToken); | ... | ... |
yudao-server/pom.xml
| ... | ... | @@ -33,11 +33,11 @@ |
| 33 | 33 | </dependency> |
| 34 | 34 | |
| 35 | 35 | <!-- 会员中心。默认注释,保证编译速度 --> |
| 36 | -<!-- <dependency>--> | |
| 37 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 38 | -<!-- <artifactId>yudao-module-member-biz</artifactId>--> | |
| 39 | -<!-- <version>${revision}</version>--> | |
| 40 | -<!-- </dependency>--> | |
| 36 | + <dependency> | |
| 37 | + <groupId>cn.iocoder.boot</groupId> | |
| 38 | + <artifactId>yudao-module-member-biz</artifactId> | |
| 39 | + <version>${revision}</version> | |
| 40 | + </dependency> | |
| 41 | 41 | |
| 42 | 42 | <!-- 数据报表。默认注释,保证编译速度 --> |
| 43 | 43 | <!-- <dependency>--> |
| ... | ... | @@ -52,11 +52,11 @@ |
| 52 | 52 | <!-- <version>${revision}</version>--> |
| 53 | 53 | <!-- </dependency>--> |
| 54 | 54 | <!-- 支付服务。默认注释,保证编译速度 --> |
| 55 | -<!-- <dependency>--> | |
| 56 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 57 | -<!-- <artifactId>yudao-module-pay-biz</artifactId>--> | |
| 58 | -<!-- <version>${revision}</version>--> | |
| 59 | -<!-- </dependency>--> | |
| 55 | + <dependency> | |
| 56 | + <groupId>cn.iocoder.boot</groupId> | |
| 57 | + <artifactId>yudao-module-pay-biz</artifactId> | |
| 58 | + <version>${revision}</version> | |
| 59 | + </dependency> | |
| 60 | 60 | |
| 61 | 61 | <!-- 微信公众号模块。默认注释,保证编译速度 --> |
| 62 | 62 | <!-- <dependency>--> |
| ... | ... | @@ -66,26 +66,26 @@ |
| 66 | 66 | <!-- </dependency>--> |
| 67 | 67 | |
| 68 | 68 | <!-- 商城相关模块。默认注释,保证编译速度--> |
| 69 | -<!-- <dependency>--> | |
| 70 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 71 | -<!-- <artifactId>yudao-module-promotion-biz</artifactId>--> | |
| 72 | -<!-- <version>${revision}</version>--> | |
| 73 | -<!-- </dependency>--> | |
| 74 | -<!-- <dependency>--> | |
| 75 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 76 | -<!-- <artifactId>yudao-module-product-biz</artifactId>--> | |
| 77 | -<!-- <version>${revision}</version>--> | |
| 78 | -<!-- </dependency>--> | |
| 79 | -<!-- <dependency>--> | |
| 80 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 81 | -<!-- <artifactId>yudao-module-trade-biz</artifactId>--> | |
| 82 | -<!-- <version>${revision}</version>--> | |
| 83 | -<!-- </dependency>--> | |
| 84 | -<!-- <dependency>--> | |
| 85 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | |
| 86 | -<!-- <artifactId>yudao-module-statistics-biz</artifactId>--> | |
| 87 | -<!-- <version>${revision}</version>--> | |
| 88 | -<!-- </dependency>--> | |
| 69 | + <dependency> | |
| 70 | + <groupId>cn.iocoder.boot</groupId> | |
| 71 | + <artifactId>yudao-module-promotion-biz</artifactId> | |
| 72 | + <version>${revision}</version> | |
| 73 | + </dependency> | |
| 74 | + <dependency> | |
| 75 | + <groupId>cn.iocoder.boot</groupId> | |
| 76 | + <artifactId>yudao-module-product-biz</artifactId> | |
| 77 | + <version>${revision}</version> | |
| 78 | + </dependency> | |
| 79 | + <dependency> | |
| 80 | + <groupId>cn.iocoder.boot</groupId> | |
| 81 | + <artifactId>yudao-module-trade-biz</artifactId> | |
| 82 | + <version>${revision}</version> | |
| 83 | + </dependency> | |
| 84 | + <dependency> | |
| 85 | + <groupId>cn.iocoder.boot</groupId> | |
| 86 | + <artifactId>yudao-module-statistics-biz</artifactId> | |
| 87 | + <version>${revision}</version> | |
| 88 | + </dependency> | |
| 89 | 89 | |
| 90 | 90 | <!-- CRM 相关模块。默认注释,保证编译速度 --> |
| 91 | 91 | <!-- <dependency>--> | ... | ... |