Commit 129f9175ac365fed6c9a29ce2c15af27c7d36023

Authored by xingyu4j
1 parent 4286f169

feat: 优化语句

yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
... ... @@ -47,7 +47,6 @@ import java.time.LocalDateTime;
47 47 import java.util.*;
48 48  
49 49 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
50   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
51 50 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
52 51 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
53 52 import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
... ... @@ -233,24 +232,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
233 232 private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) {
234 233 if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) {
235 234 List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getId(), userId);
236   - contactList.forEach(item -> {
237   - contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
238   - reqVO.getOldOwnerPermissionLevel()), userId);
239   - });
  235 + contactList.forEach(item -> contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
  236 + reqVO.getOldOwnerPermissionLevel()), userId));
240 237 }
241 238 if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) {
242 239 List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getId(), userId);
243   - businessList.forEach(item -> {
244   - businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
245   - reqVO.getOldOwnerPermissionLevel()), userId);
246   - });
  240 + businessList.forEach(item -> businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
  241 + reqVO.getOldOwnerPermissionLevel()), userId));
247 242 }
248 243 if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) {
249 244 List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getId(), userId);
250   - contractList.forEach(item -> {
251   - contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
252   - reqVO.getOldOwnerPermissionLevel()), userId);
253   - });
  245 + contractList.forEach(item -> contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
  246 + reqVO.getOldOwnerPermissionLevel()), userId));
254 247 }
255 248 }
256 249  
... ...
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenController.java
... ... @@ -119,23 +119,14 @@ public class OAuth2OpenController {
119 119 grantType, scopes, redirectUri);
120 120  
121 121 // 2. 根据授权模式,获取访问令牌
122   - OAuth2AccessTokenDO accessTokenDO;
123   - switch (grantTypeEnum) {
124   - case AUTHORIZATION_CODE:
125   - accessTokenDO = oauth2GrantService.grantAuthorizationCodeForAccessToken(client.getClientId(), code, redirectUri, state);
126   - break;
127   - case PASSWORD:
128   - accessTokenDO = oauth2GrantService.grantPassword(username, password, client.getClientId(), scopes);
129   - break;
130   - case CLIENT_CREDENTIALS:
131   - accessTokenDO = oauth2GrantService.grantClientCredentials(client.getClientId(), scopes);
132   - break;
133   - case REFRESH_TOKEN:
134   - accessTokenDO = oauth2GrantService.grantRefreshToken(refreshToken, client.getClientId());
135   - break;
136   - default:
137   - throw new IllegalArgumentException("未知授权类型:" + grantType);
138   - }
  122 + OAuth2AccessTokenDO accessTokenDO = switch (grantTypeEnum) {
  123 + case AUTHORIZATION_CODE ->
  124 + oauth2GrantService.grantAuthorizationCodeForAccessToken(client.getClientId(), code, redirectUri, state);
  125 + case PASSWORD -> oauth2GrantService.grantPassword(username, password, client.getClientId(), scopes);
  126 + case CLIENT_CREDENTIALS -> oauth2GrantService.grantClientCredentials(client.getClientId(), scopes);
  127 + case REFRESH_TOKEN -> oauth2GrantService.grantRefreshToken(refreshToken, client.getClientId());
  128 + default -> throw new IllegalArgumentException("未知授权类型:" + grantType);
  129 + };
139 130 Assert.notNull(accessTokenDO, "访问令牌不能为空"); // 防御性检查
140 131 return success(OAuth2OpenConvert.INSTANCE.convert(accessTokenDO));
141 132 }
... ...