From 41a5531dc31a642623f0a7a766fbe9c256ba9247 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 11 二月 2025 13:53:29 +0800
Subject: [PATCH] 优化WMS前端
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_UserController.cs | 174 +++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 125 insertions(+), 49 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_UserController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_UserController.cs"
index e0dbf29..e62000c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_UserController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_UserController.cs"
@@ -1,56 +1,132 @@
-锘縩amespace WIDESEA_WMSServer.Controllers;
+锘縰sing Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Caching.Memory;
+using StackExchange.Profiling;
+using WIDESEA_Core;
+using WIDESEA_Core.Authorization;
+using WIDESEA_Core.BaseController;
+using WIDESEA_Core.Caches;
+using WIDESEA_Core.Const;
+using WIDESEA_Core.Extensions;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.HttpContextUser;
+using WIDESEA_Core.Utilities;
+using WIDESEA_ISystemService;
+using WIDESEA_Model;
+using WIDESEA_Model.Models;
-[Route("api/Sys_User")]
-[ApiController]
-public class Sys_UserController : ApiBaseController<ISys_UserService, Sys_User>
+namespace WIDESEA_WMSServer.Controllers
{
- private readonly IHttpContextAccessor _httpContextAccessor;
+ [Route("api/User")]
+ [ApiController]
+ public class Sys_UserController : ApiBaseController<ISys_UserService, Sys_User>
+ {
+ private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly ICacheService _cacheService;
- public Sys_UserController(ISys_UserService userService, IHttpContextAccessor httpContextAccessor) : base(userService)
- {
- _httpContextAccessor = httpContextAccessor;
- }
-
- [HttpPost, Route("login"), AllowAnonymous]
- public IActionResult Login([FromBody] LoginInfo loginInfo)
- {
- return Json(Service.Login(loginInfo));
- }
-
- [HttpPost, Route("getCurrentUserInfo")]
- public WebResponseContent GetCurrentUser()
- {
- return Service.GetCurrentUserInfo();
- }
-
- [HttpPost, Route("modifyPwd")]
- public IActionResult ModifyPwd(string oldPwd, string newPwd)
- {
- return Json(Service.ModifyPwd(oldPwd, newPwd));
- }
- [HttpPost, Route("UpdateInfo")]
- public IActionResult UpdateInfo(int user_Id, string roleName, string userName, string userTrueName, string address, int gender, string remark)
- {
- return Json(Service.UpdateInfo(user_Id, roleName, userName, userTrueName, address, gender, remark));
- }
-
- [HttpGet, Route("getVierificationCode"), AllowAnonymous]
- public IActionResult GetVierificationCode()
- {
- //var html = MiniProfiler.Current.RenderIncludes(_httpContextAccessor.HttpContext);
- string code = "1234" /*VierificationCode.RandomText()*/;
- var data = new
+ public Sys_UserController(ISys_UserService userService, IHttpContextAccessor httpContextAccessor, ICacheService cacheService) : base(userService)
{
- img = VierificationCode.CreateBase64Imgage(code),
- uuid = Guid.NewGuid()
- };
+ _httpContextAccessor = httpContextAccessor;
+ _cacheService = cacheService;
+ }
+ /// <summary>
+ /// 鐢ㄦ埛鐧婚檰
+ /// </summary>
+ /// <param name="loginInfo"></param>
+ /// <returns></returns>
+ [HttpPost, Route("login"), AllowAnonymous]
+ public IActionResult Login([FromBody] LoginInfo loginInfo)
+ {
+ return Json(Service.Login(loginInfo));
+ }
- return Json(data);
- }
+ [HttpPost, Route("swgLogin"), AllowAnonymous]
+ public dynamic SwgLogin([FromBody] SwaggerLoginRequest loginRequest)
+ {
+ if (loginRequest is null)
+ {
+ return new { result = false };
+ }
- [HttpGet, Route("SerializeJwt"), AllowAnonymous]
- public WebResponseContent SerializeJwt(string code)
- {
- return WebResponseContent.Instance.OK(data: JwtHelper.SerializeJwt(code));
+ try
+ {
+ if (loginRequest.name == "admin" && loginRequest.pwd == $"admin!{DateTime.Now.ToString("yyyyMMdd")}")
+ {
+ HttpContext.SuccessSwagger();
+ return new { result = true };
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+
+ return new { result = false };
+ }
+
+ [HttpPost, Route("getCurrentUserInfo")]
+ public WebResponseContent GetCurrentUser()
+ {
+ return Service.GetCurrentUserInfo();
+ }
+
+ [HttpPost, Route("modifyPwd")]
+ public IActionResult ModifyPwd(string oldPwd, string newPwd, string userName)
+ {
+ return Json(Service.ModifyPwd(oldPwd, newPwd, userName));
+ }
+
+ [HttpGet, Route("getVierificationCode"), AllowAnonymous]
+ public IActionResult GetVierificationCode()
+ {
+ //var html = MiniProfiler.Current.RenderIncludes(_httpContextAccessor.HttpContext);
+ string code = "1234" /*VierificationCode.RandomText()*/;
+ var data = new
+ {
+ img = VierificationCode.CreateBase64Imgage(code),
+ uuid = Guid.NewGuid()
+ };
+
+ return Json(data);
+ }
+ [HttpGet, Route("SerializeJwt"), AllowAnonymous]
+ public WebResponseContent SerializeJwt(string code)
+ {
+ return WebResponseContent.Instance.OK(data: JwtHelper.SerializeJwt(code));
+ }
+ [HttpPost, Route("replaceToken")]
+ public WebResponseContent ReplaceToken()
+ {
+ WebResponseContent responseContent = new WebResponseContent();
+ try
+ {
+ string token = App.User.GetToken();
+ if (string.IsNullOrEmpty(token))
+ {
+ return responseContent = WebResponseContent.Instance.Error("token鏃犳晥锛岃閲嶆柊鐧诲綍锛�");
+ }
+ TokenModelJwt tokenModelJwt = new TokenModelJwt()
+ {
+ RoleId = App.User.RoleId,
+ TenantId = App.User.TenantId,
+ UserId = App.User.UserId,
+ UserName = App.User.UserName
+ };
+ string newToken = JwtHelper.IssueJwt(tokenModelJwt);
+ _cacheService.AddOrUpdate(tokenModelJwt.UserId.ToString(), newToken);
+ return responseContent = WebResponseContent.Instance.OK(data: newToken);
+ }
+ catch (Exception ex)
+ {
+ return responseContent.Error(ex.Message);
+ }
+
+ }
+ public class SwaggerLoginRequest
+ {
+ public string name { get; set; }
+ public string pwd { get; set; }
+ }
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3