From 182a80ed28bc67dc2af6709a305430b99a7a87ac Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 29 九月 2025 10:10:30 +0800
Subject: [PATCH] 大屏
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_UserService.cs | 78 ++++++++++++++++++++++++++++++++++----
1 files changed, 69 insertions(+), 9 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_UserService.cs"
index 11f2d94..337a8c8 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_UserService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_UserService.cs"
@@ -13,6 +13,8 @@
using WIDESEA_Core.Caches;
using SqlSugar;
using ICacheService = WIDESEA_Core.Caches.ICacheService;
+using Newtonsoft.Json;
+using WIDESEA_Core.HostedService;
namespace WIDESEA_SystemService
{
@@ -21,14 +23,16 @@
private readonly IUnitOfWorkManage _unitOfWorkManage;
private readonly ICacheService _cacheService;
private readonly ISys_MenuService _menuService;
+ private readonly ISys_RoleService _sys_RoleService;
public ISys_UserRepository Repository => BaseDal;
- public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService) : base(repository)
+ public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService, ISys_RoleService sys_RoleService) : base(repository)
{
_unitOfWorkManage = unitOfWorkManage;
_cacheService = cacheService;
_menuService = menuService;
+ _sys_RoleService = sys_RoleService;
}
public WebResponseContent Login(LoginInfo loginInfo)
@@ -37,8 +41,21 @@
try
{
//BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName);
-
string msg = string.Empty;
+ if (App.ExpDateTime != null)
+ {
+ if ((DateTime.Now - App.ExpDateTime.GetValueOrDefault()).TotalSeconds > 0)
+ return WebResponseContent.Instance.Error("鎺堟潈宸插埌鏈燂紝璇疯仈绯荤鐞嗗憳");
+ var span = App.ExpDateTime.GetValueOrDefault() - DateTime.Now;
+ var Days = span.TotalDays;
+ var Hours = span.TotalHours;
+ var Minutes = span.TotalMinutes;
+ var Seconds = span.TotalSeconds;
+ if (Minutes < 1) msg = $"绯荤粺灏嗗湪 {Math.Ceiling(Seconds)} 绉掗挓鍚庡埌鏈燂紝鍒版湡鏃堕棿锛歿App.ExpDateTime.GetValueOrDefault():yyyy-MM-dd HH:mm:ss}銆傝鑱旂郴绠$悊鍛樼画鏈熴��";
+ else if (Hours < 1) msg = $"绯荤粺灏嗗湪 {Math.Ceiling(Minutes)} 鍒嗛挓鍚庡埌鏈燂紝鍒版湡鏃堕棿锛歿App.ExpDateTime.GetValueOrDefault():yyyy-MM-dd HH:mm:ss}銆傝鑱旂郴绠$悊鍛樼画鏈熴��";
+ else if (Hours < 72) msg = $"绯荤粺灏嗗湪 {Math.Ceiling(Hours)} 灏忔椂鍚庡埌鏈燂紝鍒版湡鏃堕棿锛歿App.ExpDateTime.GetValueOrDefault():yyyy-MM-dd HH:mm:ss}銆傝鑱旂郴绠$悊鍛樼画鏈熴��";
+ else if (Days < 7) msg = $"绯荤粺灏嗗湪 {Math.Ceiling(Days)} 澶╁悗鍒版湡锛屽埌鏈熸椂闂达細{App.ExpDateTime.GetValueOrDefault():yyyy-MM-dd HH:mm:ss}銆傝鑱旂郴绠$悊鍛樼画鏈熴��";
+ }
#region 涓存椂浣跨敤
try
@@ -74,7 +91,7 @@
_cacheService.AddOrUpdate(user.UserId.ToString(), token);
- content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl });
+ content = WebResponseContent.Instance.OK(msg, data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl });
}
else
{
@@ -88,9 +105,48 @@
return content;
}
+ public override PageGridData<Sys_User> GetPageData(PageDataOptions options)
+ {
+ var roleIds = _sys_RoleService.GetAllChildren(App.User.RoleId).Select(x => x.Id);
+ PageGridData<Sys_User> pageGridData = new PageGridData<Sys_User>();
+ //鏍戝舰鑿滃崟浼犳煡璇㈣鑹蹭笅鎵�鏈夌敤鎴�
+ if (App.User.IsSuperAdmin)
+ {
+ var GridData = base.GetPageData(options);
+ pageGridData = new PageGridData<Sys_User>()
+ {
+ Rows = options.Order?.ToLower() == "asc" ? GridData.Rows.OrderBy(x => x.Role_Id).ToList() : GridData.Rows,
+ Total = GridData.Total
+ };
+ return pageGridData;
+ }
+ string where = ValidatePageOptions(options);
+ var a = BaseDal.Db.Queryable<Sys_User>().Where(x => roleIds.Contains(x.Role_Id)).Where(where);
+ int total = 0;
+ pageGridData = new PageGridData<Sys_User>()
+ {
+ Rows = BaseDal.Db.Queryable<Sys_User>().Where(x => roleIds.Contains(x.Role_Id)).Where(where).ToPageList(options.Page, options.Rows),
+ Total = total
+ };
+
+ return pageGridData;
+ }
public override WebResponseContent UpdateData(SaveModel saveModel)
{
+ var User = JsonConvert.DeserializeObject<Sys_User>(GetCurrentUserInfo().Data.ToJson());
+
+ #region 鍙兘淇敼姣斿綋鍓嶇敤鎴疯鑹茬瓑绾т綆鐨勭敤鎴�
+ int userId = saveModel.MainData[nameof(Sys_User.User_Id).FirstLetterToLower()].ObjToInt();
+ int RoleId = saveModel.MainData[nameof(Sys_User.Role_Id).FirstLetterToLower()].ObjToInt();
+ var user = BaseDal.QueryFirst(x => x.User_Id == userId);
+ if (User.User_Id == user.User_Id && User.Role_Id != RoleId) return WebResponseContent.Instance.Error("涓嶅彲淇敼鑷繁鐨勮鑹�");
+ if (User.User_Id != user.User_Id && User.Role_Id >= RoleId) return WebResponseContent.Instance.Error("鏉冮檺绛夌骇涓嶈冻");
+ if (User.Role_Id > user.Role_Id || User.Role_Id == user.Role_Id && User.User_Id != userId) return WebResponseContent.Instance.Error("鏆傛棤淇敼鏉冮檺");
+ //if (User.User_Id != userId) return WebResponseContent.Instance.Error("鏆傛棤淇敼鏉冮檺");鍙檺褰撳墠鐢ㄦ埛淇敼
+ #endregion
+
+ saveModel.MainData[nameof(Sys_User.UserPwd).FirstLetterToLower()] = User.UserPwd;
UpdateIgnoreColOnExecute = x =>
{
return new List<string>
@@ -128,6 +184,9 @@
var data = BaseDal.QueryFirst(x => x.User_Id == App.User.UserId, s => new
{
s.UserName,
+ s.Role_Id,
+ s.User_Id,
+ s.UserPwd,
s.UserTrueName,
s.Address,
s.PhoneNo,
@@ -146,7 +205,7 @@
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
- public WebResponseContent ModifyPwd(string oldPwd, string newPwd)
+ public WebResponseContent ModifyPwd(string oldPwd, string newPwd, string userName)
{
WebResponseContent content = WebResponseContent.Instance;
oldPwd = oldPwd?.Trim();
@@ -158,19 +217,20 @@
if (string.IsNullOrEmpty(newPwd)) return WebResponseContent.Instance.Error("鏂板瘑鐮佷笉鑳戒负绌�");
if (newPwd.Length < 6) return WebResponseContent.Instance.Error("瀵嗙爜涓嶈兘灏戜簬6浣�");
- int userId = App.User.UserId;
- string userCurrentPwd = BaseDal.QueryFirst(x => x.User_Id == userId, s => s.UserPwd);
+ var User = JsonConvert.DeserializeObject<Sys_User>(GetCurrentUserInfo().Data.ToJson());
+
+ if (User.UserName != userName) return WebResponseContent.Instance.Error($"闈炴湰浜轰笉鍙慨鏀瑰瘑鐮�");
string _oldPwd = oldPwd.EncryptDES(AppSecret.User);
- if (_oldPwd != userCurrentPwd) return WebResponseContent.Instance.Error("鏃у瘑鐮佷笉姝g‘");
+ if (_oldPwd != User.UserPwd) return WebResponseContent.Instance.Error("鏃у瘑鐮佷笉姝g‘");
string _newPwd = newPwd.EncryptDES(AppSecret.User);
- if (userCurrentPwd == _newPwd) return WebResponseContent.Instance.Error("鏂板瘑鐮佷笉鑳戒笌鏃у瘑鐮佺浉鍚�");
+ if (User.UserPwd == _newPwd) return WebResponseContent.Instance.Error("鏂板瘑鐮佷笉鑳戒笌鏃у瘑鐮佺浉鍚�");
BaseDal.UpdateData(new Sys_User
{
- User_Id = userId,
+ User_Id = User.User_Id,
UserPwd = _newPwd,
LastModifyPwdDate = DateTime.Now
}, new List<string>
--
Gitblit v1.9.3