From 96bc7aaca75fcb2b49da8ca56f19d1852159bfc6 Mon Sep 17 00:00:00 2001 From: gongxh Date: Tue, 7 Dec 2021 13:07:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=BA=93=E5=8D=95=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=8D=95=E5=8F=B7=20=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.Model/Request/User.cs | 2 + NX.ERP.U8/Store/MaterielStoreOutDAL.cs | 20 ++++++++- NX.ERP.U8/System/User.cs | 41 +++++++++++-------- .../Controllers/System/SystemController.cs | 37 +++++++++++++---- 4 files changed, 76 insertions(+), 24 deletions(-) diff --git a/NX.ERP.Model/Request/User.cs b/NX.ERP.Model/Request/User.cs index 8effbd9..3c8a04f 100644 --- a/NX.ERP.Model/Request/User.cs +++ b/NX.ERP.Model/Request/User.cs @@ -9,8 +9,10 @@ namespace NX.ERP.Model.Request { private string _UserCode; private string _UserName; + private string _mdPassword; public string UserCode { get => _UserCode; set => _UserCode = value; } public string UserName { get => _UserName; set => _UserName = value; } + public string MdPassword { get => _mdPassword; set => _mdPassword = value; } } } diff --git a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs index e5979c9..d9b3e27 100644 --- a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs +++ b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs @@ -259,7 +259,18 @@ namespace NX.ERP.U8.Store try { - return AddRdVoucher(voucherParameter); + var voucherId = AddRdVoucher(voucherParameter); + if (!string.IsNullOrEmpty(voucherId)) + { + var model = this.GetModel(int.Parse(voucherId)); + if (model!=null) + { + voucherId = model.Code; + } + + + } + return voucherId; } catch (Exception err) { @@ -294,6 +305,13 @@ namespace NX.ERP.U8.Store } } + public MaterialStoreOut GetModel(int Id) + { + return GetList(" a.id=@id", new { Id }).FirstOrDefault(); + } + + + public MaterialStoreOut GetModel(string Code) { diff --git a/NX.ERP.U8/System/User.cs b/NX.ERP.U8/System/User.cs index 8efdaf6..a48d4f5 100644 --- a/NX.ERP.U8/System/User.cs +++ b/NX.ERP.U8/System/User.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; using System.Configuration; using System.Linq; +using System.Security.Cryptography; +using System.Text; using System.Web; @@ -17,22 +19,15 @@ namespace NX.ERP.U8.User public IEnumerable GetList(string strWhere = "", object Param = null) { - - using (var conn = U8LoginContext.Instance.Connection) { - var sql = @" select cUser_Id as UserCode ,cUser_Name as UserName from UFSystem..UA_User "; + var sql = @" select cUser_Id as UserCode ,cUser_Name as UserName,cPassword as mdPassword from UFSystem..UA_User "; if (!string.IsNullOrEmpty(strWhere)) { sql += $" where {strWhere}"; } return conn.Query(sql, Param); } - - - - - } @@ -44,23 +39,37 @@ namespace NX.ERP.U8.User + public bool Login(string UserId, string Password) + { + byte[] byte1 = Encoding.UTF8.GetBytes(Password); + SHA1Managed sHA1Managed = new SHA1Managed(); + var hashValue = sHA1Managed.ComputeHash(byte1); + var mdPassword = Convert.ToBase64String(hashValue) + (char)3; + //密码密文 + var userDal = new UserDal(); + var user = userDal.GetModel(UserId); + if (user == null) + { + return false; + } + if (user.MdPassword != mdPassword) + { + return false; + } + return true; + } + + + public string Userrole(string Opnanme, string Pasd) { var AccID = ConfigurationManager.AppSettings["AccId"]; - //NX.ERP.U8.U8LoginContext.Instance.PassWord = System.Configuration.ConfigurationManager.AppSettings["Password"]; - - //NX.ERP.U8.U8LoginContext.Instance.UserId = System.Configuration.ConfigurationManager.AppSettings["UserId"]; - var Server = ConfigurationManager.AppSettings["Server"]; var _login = new NX.ERP.U8.U8LoginContext(Server, AccID); _login.Login(Opnanme, Pasd); - var sql = $@" SELECT 1 from UFSystem..UA_Role where cUser_Id=@Opnanme and cGroup_Id='report' ;"; - - - using (var conn = _login.Connection) { return conn.ExecuteScalar(sql, new { Opnanme }, null, 30, System.Data.CommandType.Text); diff --git a/NX.ERP.WebAPi/Controllers/System/SystemController.cs b/NX.ERP.WebAPi/Controllers/System/SystemController.cs index 47e6773..2e85604 100644 --- a/NX.ERP.WebAPi/Controllers/System/SystemController.cs +++ b/NX.ERP.WebAPi/Controllers/System/SystemController.cs @@ -3,27 +3,50 @@ using System; using System.Collections.Generic; using System.Configuration; using System.Linq; +using System.Security.Cryptography; +using System.Text; using System.Web; using System.Web.Http; namespace NX.ERP.WebAPi.Controllers.System { - - public class SystemController:ApiController + + public class SystemController : ApiController { - + [HttpPost] - [Route("api/System/Login")] - public string Login(LoginEntity loginEntity) + [Route("api/System/BOLogin")] + public string BOLogin(LoginEntity loginEntity) { - var AccID = ConfigurationManager.AppSettings["AccId"]; + var AccID = ConfigurationManager.AppSettings["AccId"]; //NX.ERP.U8.U8LoginContext.Instance.PassWord = System.Configuration.ConfigurationManager.AppSettings["Password"]; //NX.ERP.U8.U8LoginContext.Instance.UserId = System.Configuration.ConfigurationManager.AppSettings["UserId"]; - var Server =ConfigurationManager.AppSettings["Server"]; + var Server = ConfigurationManager.AppSettings["Server"]; var _login = new NX.ERP.U8.U8LoginContext(Server, AccID); _login.Login(loginEntity.UserId, loginEntity.Password); return _login.loginId; } + + [HttpPost] + [Route("api/System/Login")] + public bool Login(LoginEntity loginEntity) + { + if (string.IsNullOrEmpty(loginEntity.Password) || string.IsNullOrEmpty(loginEntity.UserId)) + { + return false; + } + + //密码密文 + var userDal = new U8.User.UserDal(); + return userDal.Login(loginEntity.UserId, loginEntity.Password); + + + + + + } + + [HttpPost] [Route("api/System/Userrole")] public string Userrole(LoginEntity loginEntity)