Browse Source

add HasAddDeviceException

MIke 2 years ago
parent
commit
d991531802

+ 19 - 0
Common/Exceptions/HasAddDeviceException.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Globalization;
+using WingInterfaceLibrary.Enum;
+using JsonRpcLite.Services;
+
+namespace WingDeviceService.Common
+{
+    /// <summary>
+    /// 设备不存在
+    /// </summary>
+    public class HasAddDeviceException : RpcException
+    {
+        public HasAddDeviceException():base((int)CustomerRpcCode.HasAddedDevice,"The device has been Added" , null)
+        {
+            
+        }   
+    }
+
+}

+ 18 - 0
Common/Exceptions/NoExistDeviceException.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Globalization;
+using WingInterfaceLibrary.Enum;
+using JsonRpcLite.Services;
+
+namespace WingDeviceService.Common
+{
+    /// <summary>
+    /// 设备不存在
+    /// </summary>
+    public class NoExistDeviceException : RpcException
+    {
+        public  NoExistDeviceException() : base((int)CustomerRpcCode.NoExistDevice, "Device does not exist", null)
+        {
+          
+        }
+    }
+}

+ 4 - 3
Service/DeviceService.cs

@@ -144,7 +144,7 @@ namespace WingDeviceService.Service
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(request.DeviceCode);
             if (deviceDb == null || deviceDb.DeviceCode != request.DeviceCode)
             {
-                throw new RpcException(1001, "DeviceInfo not exist error", "DeviceInfo not exist error");
+               throw new NoExistDeviceException();
             }
             //根据机构编号查询机构名称
             var organizationName = "";
@@ -198,7 +198,7 @@ namespace WingDeviceService.Service
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(request.ShortCode);
             if (deviceDb == null || deviceDb.ShortCode != request.ShortCode)
             {
-                throw new RpcException(1001, "DeviceInfo not exist error", "DeviceInfo not exist error");
+                throw new NoExistDeviceException();
             }
             return await MapToExtendDTO(deviceDb);
         }
@@ -399,7 +399,8 @@ namespace WingDeviceService.Service
             }
             if (userInfoDO.BindDevices != null && userInfoDO.BindDevices.Contains(deviceDb.DeviceCode))
             {
-                throw new RpcException(20046, "Device already bound", "Device already bound");
+
+                throw new HasAddDeviceException();
             }
             try
             {

+ 2 - 2
WingDeviceService.csproj

@@ -7,8 +7,8 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="WingInterfaceLibrary" Version="*" />
-    <PackageReference Include="WingServerCommon" Version="*" />
+    <PackageReference Include="WingInterfaceLibrary" Version="1.0.6.3" />
+    <PackageReference Include="WingServerCommon" Version="1.0.0.26" />
   </ItemGroup>