Browse Source

proxy不在区分crp/pro,新增版本控制器

linhong 3 years ago
parent
commit
6a73098c8f

+ 42 - 23
Controllers/L1SvrController.cs

@@ -49,12 +49,12 @@ namespace LJProxy.Controllers
                 return _PROPool;
             }
         }
-        private static ILJClient _CRPPool { get; set; }
-        private static ILJClient CRPPool
+        private static ILJClient _pool { get; set; }
+        private static ILJClient Pool
         {
             get
             {
-                if (_CRPPool == null)
+                if (_pool == null)
                 {
                     lock (_syncRoot)
                     {
@@ -63,39 +63,58 @@ namespace LJProxy.Controllers
                         var ip = urlArr[0];
                         var port = urlArr[1];
                         var creator = new DirectP1ClientCreator(ip, Convert.ToInt32(port));
-                        _CRPPool = new LJClientPool(creator, 20);
+                        _pool = new LJClientPool(creator, 20);
                     }
                 }
-                return _CRPPool;
+                return _pool;
             }
         }
 
-        [Route("PRO/{apiName}")]
-        [HttpPost]
-        public string PRO(string apiName, [FromBody] object requestBody)
-        {
-            var rslt = PROPool.DoExcute(apiName, requestBody.ToString());
-            return rslt;
-        }
+        //[Route("PRO/{apiName}")]
+        //[HttpPost]
+        //public string PRO(string apiName, [FromBody] object requestBody)
+        //{
+        //    var rslt = PROPool.DoExcute(apiName, requestBody.ToString());
+        //    return rslt;
+        //}
 
-        [Route("CRP/{apiName}/{**restPath}")]
+        //[Route("CRP/{apiName}/{**restPath}")]
+        //[HttpPost]
+        //[HttpGet]
+        //public async Task<IActionResult> CRP(string apiName)
+        //{ 
+        //    string requestBody;
+        //    using(StreamReader reader = new StreamReader(Request.Body,Encoding.UTF8))
+        //    {
+        //        requestBody = await reader.ReadToEndAsync();
+        //    }
+        //    var excuteResult = GlobalVar.Excute(apiName, requestBody, Request);
+        //    if (excuteResult.Item1) return excuteResult.Item2;
+        //    else
+        //    {
+        //        var rslt = CRPPool.DoExcute(apiName, requestBody);
+        //        return Content(rslt,"application/json");
+        //    }
+        //}
+
+        [Route("svr/{apiName}")]
         [HttpPost]
         [HttpGet]
-        public async Task<IActionResult> CRP(string apiName)
-        { 
+        public async Task<IActionResult> Svr(string apiName)
+        {
             string requestBody;
-            using(StreamReader reader = new StreamReader(Request.Body,Encoding.UTF8))
+            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
             {
                 requestBody = await reader.ReadToEndAsync();
             }
-            var excuteResult = GlobalVar.Excute(apiName, requestBody, Request);
-            if (excuteResult.Item1) return excuteResult.Item2;
-            else
-            {
-                var rslt = CRPPool.DoExcute(apiName, requestBody);
-                return Content(rslt,"application/json");
-            }
+            //var excuteResult = GlobalVar.Excute(apiName, requestBody, Request);
+            //if (excuteResult.Item1) return excuteResult.Item2;
+            var rslt = Pool.DoExcute(apiName, requestBody);
+            return Content(rslt, "application/json");
         }
 
+        
+
+
     }
 }

+ 49 - 0
Controllers/VersionController.cs

@@ -0,0 +1,49 @@
+using LJProxy.Services;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace LJProxy.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class VersionController: Controller
+    {
+        private VersionService _service;
+        public VersionController(VersionService vService)
+        {
+            _service = vService;
+        }
+
+        [Route("GetUpdateJson")]
+        [HttpGet]
+        [HttpPost]
+        public IActionResult GetUpdateJson()
+        {
+            string updateJson = _service.GetUpdateJson();
+            var result = new ContentResult();
+            result.Content = updateJson;
+            result.ContentType = "application/json";
+            return result;
+        }
+
+        [Route("GetAppUpdate/{apkName}")]
+        [HttpGet]
+        [HttpPost]
+        public IActionResult GetAppUpdate(string apkName)
+        {
+            var fs = _service.GetAPK(apkName);
+            if (fs == null)
+            {
+                return NotFound();
+            }
+            else
+            {
+                return new FileContentResult(fs, "application/vnd.android.package-archive");
+            }
+        }
+    }
+}

+ 0 - 33
Models/AppLogin.cs

@@ -1,33 +0,0 @@
-using LJLib.Net.SPI.Com;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Models
-{
-    public class AppLoginRequest:LJRequest 
-    {
-        /// <summary>
-        /// 用户编号
-        /// </summary>
-        public string userid { get; set; }
-        /// <summary>
-        /// 密码
-        /// </summary>
-        public string password { get; set; }
-    }
-
-    public class AppLoginResponse : LJResponse
-    {
-        /// <summary>
-        /// 用户唯一标识
-        /// </summary>
-        public string token { get; set; }
-        /// <summary>
-        /// 用户名称
-        /// </summary>
-        public string username { get; set; }
-    }
-
-}

+ 1 - 1
Properties/PublishProfiles/FolderProfile.pubxml.user

@@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <_PublishTargetUrl>F:\projects\LJProxy\bin\Release\netcoreapp3.1\publish\</_PublishTargetUrl>
-    <History>True|2021-09-05T02:02:29.7646709Z;True|2021-09-04T22:32:42.5817800+08:00;True|2021-08-16T14:51:54.8412175+08:00;True|2021-08-16T11:30:00.7278175+08:00;</History>
+    <History>True|2021-09-06T06:54:37.4829251Z;True|2021-09-06T14:46:46.4478494+08:00;True|2021-09-05T10:02:29.7646709+08:00;True|2021-09-04T22:32:42.5817800+08:00;True|2021-08-16T14:51:54.8412175+08:00;True|2021-08-16T11:30:00.7278175+08:00;</History>
   </PropertyGroup>
 </Project>

+ 2 - 0
Startup.cs

@@ -1,3 +1,4 @@
+using LJProxy.Services;
 using LJProxy.Settings;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
@@ -30,6 +31,7 @@ namespace LJProxy
                 //opt.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
             });
             services.Configure<AppSettings>(Configuration.GetSection("Appsettings"));
+            services.AddScoped<VersionService>();
             GlobalVar.InitSetting(Configuration.GetSection("Appsettings"));
         }
 

+ 3 - 3
apk/update.json

@@ -1,5 +1,5 @@
 {
-  "url":"http://127.0.0.1:58966/api/l1svr/crp/GetAppUpdate/android-auto-update-v1.3.apk",
-  "versionCode":4,
-  "updateMessage":"1. 适配 Android 8.0\n2. 适配 Android 9.0\n3. 更新说明"
+  "url": "http://127.0.0.1:58966/api/version/getappupdate/android-auto-update-v1.3.apk",
+  "versionCode": 4,
+  "updateMessage": "1. 适配 Android 8.0\n2. 适配 Android 9.0\n3. 更新说明"
 }