From b8510ca5d1e56ef78cd27c45b6bd65a2c13f6b27 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期一, 17 三月 2025 15:12:34 +0800
Subject: [PATCH] 代码优化

---
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs |   66 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs"
index 4d1ac2b..b09071d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/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;
@@ -26,6 +28,44 @@
         public Sys_UserController(ISys_UserService userService, IHttpContextAccessor httpContextAccessor) : base(userService)
         {
             _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]
@@ -90,5 +130,31 @@
             }
 
         }
+
+        [HttpGet, Route("GetUerType"), AllowAnonymous]
+        public WebResponseContent GetUerType()
+        {
+            return Service.GetUerType();
+        }
+
+        [HttpPost, Route("PermissionView"), AllowAnonymous]
+        public WebResponseContent PermissionView(int userId, string group)
+        {
+            return Service.PermissionView(userId,group);
+        }
+
+
+        [HttpPost, Route("UploadAvatar"), AllowAnonymous]
+        public WebResponseContent UploadAvatar(List<IFormFile> files, int userId)
+        {
+            return Service.UploaDavatar(files, userId);
+        }
+    }
+
+
+    public class SwaggerLoginRequest
+    {
+        public string name { get; set; }
+        public string pwd { get; set; }
     }
 }

--
Gitblit v1.9.3