|
@@ -18,7 +18,6 @@ using WingInterfaceLibrary.DTO.User;
|
|
|
using WingInterfaceLibrary.DTO.Management;
|
|
|
using WingServerCommon.Config;
|
|
|
using WingDeviceService.Common;
|
|
|
-using WingInterfaceLibrary.Enum.RpcExceptionEnum;
|
|
|
using WingInterfaceLibrary.Request.User;
|
|
|
using WingInterfaceLibrary.Enum;
|
|
|
using WingInterfaceLibrary.DTO.Organization;
|
|
@@ -684,32 +683,32 @@ namespace WingDeviceService.Service
|
|
|
var userCode = await ValidateTokenAsync(request.Token);
|
|
|
if (string.IsNullOrEmpty(shortCode))
|
|
|
{
|
|
|
- throw new RpcException((int)DeviceErrorCodeEnum.UniqueCodeIsEmpty, "Unique code is empty", "Unique code is empty");
|
|
|
+ throw new CustomerRpcCodeException(CustomerRpcCode.UniqueCodeIsEmpty);
|
|
|
}
|
|
|
var device = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(shortCode);
|
|
|
if (device == null)
|
|
|
{
|
|
|
- throw new RpcException((int)DeviceErrorCodeEnum.DeviceNotExist, "Device not exist", "Device not exist");
|
|
|
+ throw new NoExistDeviceException();
|
|
|
}
|
|
|
var oldOrg = await _organizationDBService.GetOrganizationDetailAsync(new GetOrganizationDBRequest { OrganizationCode = device.OrganizationCode });
|
|
|
if (oldOrg == null || string.IsNullOrWhiteSpace(oldOrg.OrganizationCode))
|
|
|
{
|
|
|
- throw new RpcException((int)DeviceErrorCodeEnum.OrganizationNotExist, "Not exist device's organization ", "Not exist device's organization ");
|
|
|
+ throw new CustomerRpcCodeException(CustomerRpcCode.OrganizationNotExist);
|
|
|
}
|
|
|
//用户
|
|
|
var userDTO = await _userServiceProxy.FindUserByCodeAsync(userCode);
|
|
|
if (userDTO == null)
|
|
|
{
|
|
|
- throw new RpcException(1007, "user not exist", "user not exist");
|
|
|
+ throw new CustomerRpcCodeException(CustomerRpcCode.UserNotExistError);
|
|
|
}
|
|
|
if (!userDTO.IsDirector)
|
|
|
{
|
|
|
- throw new RpcException((int)DeviceErrorCodeEnum.NotOrgAdmin, "user not organization admin", "user not organization admin");
|
|
|
+ throw new CustomerRpcCodeException(CustomerRpcCode.NotOrgAdmin);
|
|
|
}
|
|
|
var org = await _organizationDBService.GetOrganizationDetailAsync(new GetOrganizationDBRequest { OrganizationCode = userDTO.OrganizationCode });
|
|
|
if (org == null || string.IsNullOrWhiteSpace(org.OrganizationCode))
|
|
|
{
|
|
|
- throw new RpcException((int)DeviceErrorCodeEnum.OrganizationNotExist, "Not exist user's organization ", "Not exist user's organization ");
|
|
|
+ throw new CustomerRpcCodeException(CustomerRpcCode.OrganizationNotExist);
|
|
|
}
|
|
|
#endregion
|
|
|
try
|