feat: 优化语句
This commit is contained in:
parent
4286f16974
commit
129f9175ac
|
@ -47,7 +47,6 @@ import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||||
|
@ -233,24 +232,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||||
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) {
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) {
|
||||||
List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getId(), userId);
|
List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getId(), userId);
|
||||||
contactList.forEach(item -> {
|
contactList.forEach(item -> contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
||||||
contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
reqVO.getOldOwnerPermissionLevel()), userId));
|
||||||
reqVO.getOldOwnerPermissionLevel()), userId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) {
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) {
|
||||||
List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getId(), userId);
|
List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getId(), userId);
|
||||||
businessList.forEach(item -> {
|
businessList.forEach(item -> businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
||||||
businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
reqVO.getOldOwnerPermissionLevel()), userId));
|
||||||
reqVO.getOldOwnerPermissionLevel()), userId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) {
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) {
|
||||||
List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getId(), userId);
|
List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getId(), userId);
|
||||||
contractList.forEach(item -> {
|
contractList.forEach(item -> contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
||||||
contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
reqVO.getOldOwnerPermissionLevel()), userId));
|
||||||
reqVO.getOldOwnerPermissionLevel()), userId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,23 +119,14 @@ public class OAuth2OpenController {
|
||||||
grantType, scopes, redirectUri);
|
grantType, scopes, redirectUri);
|
||||||
|
|
||||||
// 2. 根据授权模式,获取访问令牌
|
// 2. 根据授权模式,获取访问令牌
|
||||||
OAuth2AccessTokenDO accessTokenDO;
|
OAuth2AccessTokenDO accessTokenDO = switch (grantTypeEnum) {
|
||||||
switch (grantTypeEnum) {
|
case AUTHORIZATION_CODE ->
|
||||||
case AUTHORIZATION_CODE:
|
oauth2GrantService.grantAuthorizationCodeForAccessToken(client.getClientId(), code, redirectUri, state);
|
||||||
accessTokenDO = oauth2GrantService.grantAuthorizationCodeForAccessToken(client.getClientId(), code, redirectUri, state);
|
case PASSWORD -> oauth2GrantService.grantPassword(username, password, client.getClientId(), scopes);
|
||||||
break;
|
case CLIENT_CREDENTIALS -> oauth2GrantService.grantClientCredentials(client.getClientId(), scopes);
|
||||||
case PASSWORD:
|
case REFRESH_TOKEN -> oauth2GrantService.grantRefreshToken(refreshToken, client.getClientId());
|
||||||
accessTokenDO = oauth2GrantService.grantPassword(username, password, client.getClientId(), scopes);
|
default -> throw new IllegalArgumentException("未知授权类型:" + grantType);
|
||||||
break;
|
};
|
||||||
case CLIENT_CREDENTIALS:
|
|
||||||
accessTokenDO = oauth2GrantService.grantClientCredentials(client.getClientId(), scopes);
|
|
||||||
break;
|
|
||||||
case REFRESH_TOKEN:
|
|
||||||
accessTokenDO = oauth2GrantService.grantRefreshToken(refreshToken, client.getClientId());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("未知授权类型:" + grantType);
|
|
||||||
}
|
|
||||||
Assert.notNull(accessTokenDO, "访问令牌不能为空"); // 防御性检查
|
Assert.notNull(accessTokenDO, "访问令牌不能为空"); // 防御性检查
|
||||||
return success(OAuth2OpenConvert.INSTANCE.convert(accessTokenDO));
|
return success(OAuth2OpenConvert.INSTANCE.convert(accessTokenDO));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue