ntminer 5 years ago
parent
commit
67da58d24e

+ 1 - 1
src/AppModels/MinerStudio/Vms/GpuNamesViewModel.cs

@@ -59,7 +59,7 @@ namespace NTMiner.MinerStudio.Vms {
         }
 
         public void Query() {
-            RpcRoot.OfficialServer.GpuNameService.QueryGpuNamesAsync((response, e) => {
+            RpcRoot.OfficialServer.GpuNameService.GetGpuNamesAsync((response, e) => {
                 if (response.IsSuccess()) {
                     this.GpuNames = response.Data.OrderBy(a => a.GpuType.GetDescription() + a.Name).Select(a => new GpuNameViewModel(a)).ToList();
                 }

+ 2 - 1
src/NTMiner.Controllers/IGpuNameController.cs

@@ -1,8 +1,9 @@
 using NTMiner.Core.Gpus;
+using System.Collections.Generic;
 
 namespace NTMiner.Controllers {
     public interface IGpuNameController {
-        QueryGpuNamesResponse QueryGpuNames(QueryGpuNamesRequest request);
+        DataResponse<List<GpuName>> GpuNames(object requestss);
         /// <summary>
         /// 需签名
         /// </summary>

+ 0 - 15
src/NTMinerDataSchemas/Core/Gpus/QueryGpuNamesRequest.cs

@@ -1,15 +0,0 @@
-using System.Text;
-
-namespace NTMiner.Core.Gpus {
-    public class QueryGpuNamesRequest : IPagingRequest, ISignableData {
-        public QueryGpuNamesRequest() { }
-
-        public int PageIndex { get; set; }
-        public int PageSize { get; set; }
-        public string Keyword { get; set; }
-
-        public StringBuilder GetSignData() {
-            return this.GetActionIdSign("4FBC19D4-55AB-4827-BEF4-A24D28D620CE");
-        }
-    }
-}

+ 0 - 22
src/NTMinerDataSchemas/Core/Gpus/QueryGpuNamesResponse.cs

@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-
-namespace NTMiner.Core.Gpus {
-    public class QueryGpuNamesResponse : ResponseBase {
-        public QueryGpuNamesResponse() {
-            this.Data = new List<GpuName>();
-        }
-
-        public static QueryGpuNamesResponse Ok(List<GpuName> data, int total) {
-            return new QueryGpuNamesResponse() {
-                StateCode = 200,
-                ReasonPhrase = "Ok",
-                Description = "成功",
-                Data = data,
-                Total = total
-            };
-        }
-
-        public List<GpuName> Data { get; set; }
-        public int Total { get; set; }
-    }
-}

+ 0 - 2
src/NTMinerDataSchemas/NTMinerDataSchemas.csproj

@@ -50,8 +50,6 @@
     <Compile Include="Core\Gpus\IGpuNameCount.cs" />
     <Compile Include="Core\Gpus\QueryGpuNameCountsRequest.cs" />
     <Compile Include="Core\Gpus\QueryGpuNameCountsResponse.cs" />
-    <Compile Include="Core\Gpus\QueryGpuNamesRequest.cs" />
-    <Compile Include="Core\Gpus\QueryGpuNamesResponse.cs" />
     <Compile Include="Core\ICaptcha.cs" />
     <Compile Include="Core\IOperationResult.cs" />
     <Compile Include="Core\LocalMessageDto.cs" />

+ 3 - 2
src/NTMinerRpcClient/Services/Official/GpuNameService.cs

@@ -1,6 +1,7 @@
 using NTMiner.Controllers;
 using NTMiner.Core.Gpus;
 using System;
+using System.Collections.Generic;
 
 namespace NTMiner.Services.Official {
     public class GpuNameService {
@@ -8,8 +9,8 @@ namespace NTMiner.Services.Official {
 
         public GpuNameService() { }
 
-        public void QueryGpuNamesAsync(Action<QueryGpuNamesResponse, Exception> callback) {
-            JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.QueryGpuNames), new object(), callback, timeountMilliseconds: 5 * 1000);
+        public void GetGpuNamesAsync(Action<DataResponse<List<GpuName>>, Exception> callback) {
+            JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.GpuNames), new object(), callback, timeountMilliseconds: 5 * 1000);
         }
 
         public void QueryGpuNameCountsAsync(QueryGpuNameCountsRequest request, Action<QueryGpuNameCountsResponse, Exception> callback) {

+ 4 - 6
src/WebApiServer/Controllers/GpuNameController.cs

@@ -1,18 +1,16 @@
 using NTMiner.Core.Gpus;
+using System.Collections.Generic;
 using System.Web.Http;
 
 namespace NTMiner.Controllers {
     public class GpuNameController : ApiControllerBase, IGpuNameController {
         [HttpGet]
         [HttpPost]
-        public QueryGpuNamesResponse QueryGpuNames([FromBody]QueryGpuNamesRequest request) {
+        public DataResponse<List<GpuName>> GpuNames([FromBody]object request) {
             if (request == null) {
-                return ResponseBase.InvalidInput<QueryGpuNamesResponse>("参数错误");
+                return ResponseBase.InvalidInput<DataResponse<List<GpuName>>>("参数错误");
             }
-            request.PagingTrim();
-            var data = WebApiRoot.GpuNameSet.QueryGpuNames(request, out int total);
-
-            return QueryGpuNamesResponse.Ok(data, total);
+            return DataResponse<List<GpuName>>.Ok(WebApiRoot.GpuNameSet.GetAllGpuNames());
         }
 
         [Role.Admin]

+ 1 - 1
src/WebApiServer/Core/IGpuNameSet.cs

@@ -11,6 +11,6 @@ namespace NTMiner.Core {
         void Set(GpuName gpuName);
         void Remove(GpuName gpuName);
         List<GpuNameCount> QueryGpuNameCounts(QueryGpuNameCountsRequest query, out int total);
-        List<GpuName> QueryGpuNames(QueryGpuNamesRequest query, out int total);
+        List<GpuName> GetAllGpuNames();
     }
 }

+ 2 - 15
src/WebApiServer/Core/Impl/GpuNameSet.cs

@@ -84,21 +84,8 @@ namespace NTMiner.Core.Impl {
             }).ToList();
         }
 
-        public List<GpuName> QueryGpuNames(QueryGpuNamesRequest query, out int total) {
-            List<GpuName> list = new List<GpuName>();
-            bool isFilterByKeyword = !string.IsNullOrEmpty(query.Keyword);
-            if (isFilterByKeyword) {
-                foreach (var item in _gpuNameSet.OrderBy(a => a.Name)) {
-                    if (item.Name.Contains(query.Keyword)) {
-                        list.Add(item);
-                    }
-                }
-            }
-            else {
-                list.AddRange(_gpuNameSet);
-            }
-            total = list.Count;
-            return list.Take(query).ToList();
+        public List<GpuName> GetAllGpuNames() {
+            return _gpuNameSet.ToList();
         }
     }
 }