From 0b275760ee275562439c91e473e731a82c836b57 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期二, 26 八月 2025 11:41:22 +0800
Subject: [PATCH] 新增无仓储层版本WCS

---
 WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs
index 4d1ac2b..4aceb97 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs
@@ -3,11 +3,13 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Caching.Memory;
+using Newtonsoft.Json;
 using StackExchange.Profiling;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Authorization;
 using WIDESEAWCS_Core.BaseController;
 using WIDESEAWCS_Core.Const;
+using WIDESEAWCS_Core.Extensions;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Core.HttpContextUser;
 using WIDESEAWCS_Core.Utilities;
@@ -27,7 +29,41 @@
         {
             _httpContextAccessor = httpContextAccessor;
         }
+        [HttpPost, Route("swgLogin"), AllowAnonymous]
+        public dynamic SwgLogin([FromBody] SwaggerLoginRequest loginRequest)
+        {
+            if (loginRequest is null)
+            {
+                return new { result = false };
+            }
 
+            try
+            {
+                LoginInfo loginInfo = new LoginInfo
+                {
+                    Password = loginRequest.pwd,
+                    UserName = loginRequest.name
+                };
+                var result = Service.Login(loginInfo);
+                if (result.Status)
+                {
+                    HttpContext.SuccessSwagger();
+                    Dictionary<string, object>? dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(result.Data.Serialize());
+                    if (dict != null)
+                    {
+                        HttpContext.SuccessSwaggerJwt((dict.ContainsKey("token") ? dict["token"].ToString() : "") ?? "");
+                    }
+                    string str = HttpContext.GetSuccessSwaggerJwt();
+                    return new { result = true };
+                }
+            }
+            catch (Exception ex)
+            {
+
+            }
+
+            return new { result = false };
+        }
         [HttpPost, Route("login"), AllowAnonymous]
         public IActionResult Login([FromBody] LoginInfo loginInfo)
         {
@@ -91,4 +127,10 @@
 
         }
     }
+
+    public class SwaggerLoginRequest
+    {
+        public string name { get; set; }
+        public string pwd { get; set; }
+    }
 }

--
Gitblit v1.9.3