From 01656f0ff2bf7b62ef0fb039e24be888849ad728 Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期五, 30 八月 2024 11:06:44 +0800
Subject: [PATCH] 权限

---
 WebApi/Gs.User/Service/UserController.cs |  413 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 402 insertions(+), 11 deletions(-)

diff --git a/WebApi/Gs.User/Service/UserController.cs b/WebApi/Gs.User/Service/UserController.cs
index 614295d..bb6b364 100644
--- a/WebApi/Gs.User/Service/UserController.cs
+++ b/WebApi/Gs.User/Service/UserController.cs
@@ -8,6 +8,10 @@
 using System.Linq;
 using System.Text;
 using Gs.User.Modes;
+using System.Diagnostics;
+using System.Diagnostics.Metrics;
+using System.Security.Principal;
+using System.Net;
 
 namespace Gs.User.Service
 {
@@ -55,17 +59,6 @@
                             System.Data.DataRow row = dset.Tables[0].Rows[0];
                             m.loginGuid = Guid.Parse(row["loginGuid"].ToString());
                             m.loginOrgGuid = row["loginOrgGuid"].ToString();
-                            System.Text.StringBuilder sbR = new StringBuilder();
-                            if (dset.Tables.Count > 1 && dset.Tables[1].Rows.Count > 1)
-                            {
-                                foreach (System.Data.DataRow r in dset.Tables[1].Rows)
-                                {
-                                    if (sbR.Length > 0)
-                                        sbR.Append(",");
-                                    sbR.Append(r["rightGuid"].ToString());
-                                }
-                            }
-                            m.loginRightList = sbR.ToString();
                             return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "鐧诲綍鎴愬姛锛�");
                         }
                     }
@@ -81,5 +74,403 @@
             }
             return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "鐧诲綍澶辫触锛�");
         }
+
+        /// <summary>
+        /// 璇诲彇鐢ㄦ埛鐧诲綍淇℃伅
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<System.Dynamic.ExpandoObject> GetUserLoginInfo([FromBody] UserLogin model)
+        {
+            Guid userGuid = model.userGuid;
+            DataSet dset = new DataSet();
+            dynamic m = new System.Dynamic.ExpandoObject();
+            using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
+            {
+                using (SqlCommand cmd = new SqlCommand("[prc_user_info]", conn))
+                {
+                    try
+                    {
+                        conn.Open();
+                        cmd.CommandType = CommandType.StoredProcedure;
+                        SqlParameter[] parameters = new SqlParameter[] {
+                                new SqlParameter("@userGuid",userGuid),
+                            };
+                        foreach (SqlParameter parameter in parameters)
+                        {
+                            cmd.Parameters.Add(parameter);
+                        }
+                        using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
+                        {
+                            dt.Fill(dset, "0");
+                        }
+                        if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0)
+                        {
+                            System.Data.DataRow row = dset.Tables[0].Rows[0];
+                            m.loginGuid = Guid.Parse(row["loginGuid"].ToString());
+                            m.loginOrgGuid = row["loginOrgGuid"].ToString();
+                            m.list = new List<MenuAction>();
+                            if (dset.Tables.Count > 1 && dset.Tables[1].Rows.Count > 1)
+                            {
+                                foreach (DataRow dr in dset.Tables[1].Rows)
+                                {
+                                    m.list.Add(
+                                        new MenuAction()
+                                        {
+                                            guid = Guid.Parse(dr["rightGuid"].ToString()),
+                                            upGuid = dr["upGuid"].ToString().Length > 0 ? Guid.Parse(dr["upGuid"].ToString()) : null,
+                                            name = dr["name"].ToString(),
+                                            icon = dr["icon"].ToString(),
+                                            formPath = dr["formPath"].ToString(),
+                                            category = int.Parse(dr["category"].ToString()),
+                                        }
+                                    );
+                                }
+                                string _msg = "娆㈣繋浣跨敤鏌愭煇鍏徃EMS绯荤粺锛屼綘鐨勮鑹蹭负銆愮鐞嗗憳銆戝綋鍓嶅叡鏈夈��20銆戞潯淇℃伅鏈鐞�";
+                                return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, _msg);
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        LogHelper.Debug(this.ToString(), "GetUserInfo error锛�" + ex.Message);
+                    }
+                    finally
+                    {
+                        conn.Close();
+                    }
+                }
+            }
+            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "鐧诲綍澶辫触锛�");
+        }
+
+
+        #region
+        /// <summary>
+        /// 璇诲彇鍒楄〃锛屾敮鎸佸垎椤�
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<PageList<dynamic>> GetListPage([FromBody] PageQuery model)
+        {
+            int currentPage = model.currentPage;
+            int everyPageSize = model.everyPageSize;
+            string sortName = string.IsNullOrEmpty(model.sortName) ? "a.name" : model.sortName;
+            System.Text.StringBuilder sbSql = new StringBuilder();
+            sbSql.Append("select * from ");
+            sbSql.Append("( ");
+            sbSql.Append("select top 100000 ROW_NUMBER() over(order by " + sortName + " " + model.sortOrder + ") as rowIndex,* from sys_User a where 1=1" + model.keyWhere);
+            sbSql.Append(") as T ");
+            sbSql.Append(" where T.rowindex>(" + currentPage + "-1)*" + everyPageSize + " and  T.rowindex<=" + currentPage + "*" + everyPageSize + "");
+            sbSql.Append(" select count(1) as intTotal  from sys_User a where 1=1 " + model.keyWhere).ToString();
+            DataSet dset = new DataSet();
+            try
+            {
+                dset = Gs.Toolbox.DbHelperSQL.Query(sbSql.ToString());
+            }
+            catch (Exception ex)
+            {
+                Gs.Toolbox.LogHelper.Debug(this.ToString(), "GetListPage error锛�" + ex.Message);
+                return ReturnDto<PageList<dynamic>>.QuickReturn(default(PageList<dynamic>), ReturnCode.Exception, "璇诲彇澶辫触");
+            }
+            PageList<dynamic> _pglist = new PageList<dynamic>
+            {
+                total = 0,
+                everyPageSize = 0,
+                pages = 0,
+                list = new List<dynamic>()
+            };
+            if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0)//鏈夋暟鎹�
+            {
+                int intTotal = int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString());
+                int pages = (intTotal % everyPageSize != 0) ? (intTotal / everyPageSize + 1) : (intTotal / everyPageSize);
+                _pglist.total = intTotal;
+                _pglist.everyPageSize = everyPageSize;
+                _pglist.pages = pages;
+                foreach (DataRow row in dset.Tables[0].Rows)
+                {
+                    Sys_User _model = new Sys_User();
+                    if (row["guid"] != null && row["guid"].ToString() != "")
+                    {
+                        _model.guid = new Guid(row["guid"].ToString());
+                    }
+                    if (row["account"] != null)
+                    {
+                        _model.account = row["account"].ToString();
+                    }
+                    if (row["password"] != null && row["password"].ToString() != "")
+                    {
+                        _model.password = new Guid(row["password"].ToString());
+                    }
+                    if (row["userName"] != null)
+                    {
+                        _model.userName = row["userName"].ToString();
+                    }
+                    if (row["address"] != null)
+                    {
+                        _model.address = row["address"].ToString();
+                    }
+                    if (row["tel"] != null)
+                    {
+                        _model.tel = row["tel"].ToString();
+                    }
+                    if (row["email"] != null)
+                    {
+                        _model.email = row["email"].ToString();
+                    }
+                    if (row["lastLoginTime"] != null && row["lastLoginTime"].ToString() != "")
+                    {
+                        _model.lastLoginTime = DateTime.Parse(row["lastLoginTime"].ToString());
+                    }
+                    if (row["lastLogoutTime"] != null && row["lastLogoutTime"].ToString() != "")
+                    {
+                        _model.lastLogoutTime = DateTime.Parse(row["lastLogoutTime"].ToString());
+                    }
+                    if (row["isLocked"] != null && row["isLocked"].ToString() != "")
+                    {
+                        _model.isLocked = int.Parse(row["isLocked"].ToString());
+                    }
+                    if (row["createTime"] != null && row["createTime"].ToString() != "")
+                    {
+                        _model.createTime = DateTime.Parse(row["createTime"].ToString());
+                    }
+                    if (row["flagAdmin"] != null && row["flagAdmin"].ToString() != "")
+                    {
+                        _model.flagAdmin = int.Parse(row["flagAdmin"].ToString());
+                    }
+                    if (row["flagOnline"] != null && row["flagOnline"].ToString() != "")
+                    {
+                        _model.flagOnline = int.Parse(row["flagOnline"].ToString());
+                    }
+                    if (row["loginCounter"] != null && row["loginCounter"].ToString() != "")
+                    {
+                        _model.loginCounter = int.Parse(row["loginCounter"].ToString());
+                    }
+                    if (row["workerID"] != null)
+                    {
+                        _model.workerID = row["workerID"].ToString();
+                    }
+                    if (row["remark"] != null)
+                    {
+                        _model.remark = row["remark"].ToString();
+                    }
+                    if (row["departGuid"] != null && row["departGuid"].ToString() != "")
+                    {
+                        _model.departGuid = new Guid(row["departGuid"].ToString());
+                    }
+                    if (row["isSys"] != null && row["isSys"].ToString() != "")
+                    {
+                        _model.isSys = int.Parse(row["isSys"].ToString());
+                    }
+                    _model.isLockedTxt = row["isLocked"].ToString() != "1" ? "姝e父" : "琚攣瀹�";
+                    _pglist.list.Add(_model);
+                }
+            }
+            return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist, ReturnCode.Success, "璇诲彇鎴愬姛");
+        }
+
+
+        /// <summary>
+        /// 鍒犻櫎
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<int?> DeleteModel([FromBody] string guidList)
+        {
+            int rtnInt = (int)ReturnCode.Default;
+            int cont = 0;
+            try
+            {
+                //鏄惁鍐呯疆
+                cont = int.Parse(DbHelperSQL.GetSingle("select count(1) from sys_User where   [isSys]=1 and guid in split('" + guidList + "',',')").ToString());
+                if (cont > 0)
+                {
+                    return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "鍒犻櫎澶辫触锛岃鏉$洰涓虹郴缁熷唴缃紝涓嶅彲鍒犻櫎锛�");
+                }
+                StringBuilder strSql = new StringBuilder();
+                strSql.Append("delete from sys_User ");
+                strSql.Append(" where guid in (" + guidList + ")  ");
+                int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
+                rtnInt = rows;
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Debug(this.ToString(), "DeleteModel error锛�" + ex.Message);
+                rtnInt = (int)ReturnCode.Exception;
+            }
+            if (rtnInt > 0)
+                return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, "鎿嶄綔鎴愬姛锛屽叡鍒犻櫎" + rtnInt.ToString() + "鏉℃暟鎹紒");
+            else
+                return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "鍒犻櫎澶辫触锛岃閲嶈瘯锛�");
+        }
+
+        /// <summary>
+        /// 澧炲姞
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<int?> EditModel([FromBody] Sys_User model)
+        {
+            Guid? guid = model.guid;
+            string strPass = Guid.NewGuid().ToString();
+            int? rtnInt = (int)ReturnCode.Default;
+            if (guid == null)
+            {
+                int cont = 0;
+                cont = int.Parse(DbHelperSQL.GetSingle("select count(1) from sys_User where account='" + guid.ToString() + "'").ToString());
+                if (cont > 0)
+                {
+                    return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "澧炲姞澶辫触锛岃璐﹀彿宸插瓨鍦紒");
+                }
+            }
+            StringBuilder strSql = new StringBuilder();
+            if (guid != null)
+            {
+                strSql.Append(" UPDATE [dbo].[sys_User]");
+                strSql.Append(" SET [userName] = @userName ,[address] =@address ,[tel] = @tel,[email] = @email ,[isLocked] =@isLocked,[createTime] = getdate() ,[flagAdmin] =@flagAdmin,[workerID] =@workerID ,[remark] = @remark,[departGuid] = @departGuid ");
+                strSql.Append(" where guid='" + guid + "'");
+            }
+            else
+            {
+                guid = Guid.NewGuid();
+                strSql.Append("insert into sys_User");
+                strSql.Append(" ([guid],[account],[password],[userName],[address],[tel],[email],[isLocked],[createTime],[flagAdmin],[flagOnline],[loginCounter],[workerID],[remark],[departGuid])");
+                strSql.Append(" values (");
+                strSql.Append("'" + guid + "',@account,'" + strPass + "',@userName,@address,@tel,@email,@isLocked,getdate(),@flagAdmin,0,0 ,@workerID,@remark,@departGuid)");
+            }
+            SqlParameter[] parameters = {
+             new SqlParameter("@account", model.account),
+             new SqlParameter("@userName",model.userName),
+             new SqlParameter("@address",model.address),
+             new SqlParameter("@tel",model.tel),
+             new SqlParameter("@email",model.email),
+             new SqlParameter("@isLocked",model.isLocked),
+             new SqlParameter("@flagAdmin",model.flagAdmin),
+             new SqlParameter("@workerID",model.workerID),
+             new SqlParameter("@remark",model.remark),
+             new SqlParameter("@departGuid",model.departGuid),
+         };
+            try
+            {
+                rtnInt = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Debug(this.ToString(), "EditModel error锛�" + ex.Message);
+                rtnInt = (int)ReturnCode.Exception;
+            }
+            if (rtnInt > 0)
+                return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, "鎿嶄綔鎴愬姛锛�");
+            else
+                return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, "澧炲姞澶辫触锛岃閲嶈瘯锛�");
+        }
+
+        /// <summary>
+        /// 璇诲彇
+        /// </summary>
+        /// <param name="guid"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        [AllowAnonymous]
+        public ReturnDto<Sys_User> GetModel([FromBody] Sys_User model)
+        {
+            Sys_User _model = new Sys_User();
+            System.Text.StringBuilder sbSql = new StringBuilder();
+            sbSql.Append("select top 1 * from sys_Organization where 1=1 and guid='" + model.guid.ToString() + "' ");
+            try
+            {
+                DataSet dset = new DataSet();
+                dset = DbHelperSQL.Query(sbSql.ToString());
+                if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0)
+                {
+                    System.Data.DataRow row = dset.Tables[0].Rows[0];
+                    if (row["guid"] != null && row["guid"].ToString() != "")
+                    {
+                        _model.guid = new Guid(row["guid"].ToString());
+                    }
+                    if (row["account"] != null)
+                    {
+                        _model.account = row["account"].ToString();
+                    }
+                    if (row["password"] != null && row["password"].ToString() != "")
+                    {
+                        _model.password = new Guid(row["password"].ToString());
+                    }
+                    if (row["userName"] != null)
+                    {
+                        _model.userName = row["userName"].ToString();
+                    }
+                    if (row["address"] != null)
+                    {
+                        _model.address = row["address"].ToString();
+                    }
+                    if (row["tel"] != null)
+                    {
+                        _model.tel = row["tel"].ToString();
+                    }
+                    if (row["email"] != null)
+                    {
+                        _model.email = row["email"].ToString();
+                    }
+                    if (row["lastLoginTime"] != null && row["lastLoginTime"].ToString() != "")
+                    {
+                        _model.lastLoginTime = DateTime.Parse(row["lastLoginTime"].ToString());
+                    }
+                    if (row["lastLogoutTime"] != null && row["lastLogoutTime"].ToString() != "")
+                    {
+                        _model.lastLogoutTime = DateTime.Parse(row["lastLogoutTime"].ToString());
+                    }
+                    if (row["isLocked"] != null && row["isLocked"].ToString() != "")
+                    {
+                        _model.isLocked = int.Parse(row["isLocked"].ToString());
+                    }
+                    if (row["createTime"] != null && row["createTime"].ToString() != "")
+                    {
+                        _model.createTime = DateTime.Parse(row["createTime"].ToString());
+                    }
+                    if (row["flagAdmin"] != null && row["flagAdmin"].ToString() != "")
+                    {
+                        _model.flagAdmin = int.Parse(row["flagAdmin"].ToString());
+                    }
+                    if (row["flagOnline"] != null && row["flagOnline"].ToString() != "")
+                    {
+                        _model.flagOnline = int.Parse(row["flagOnline"].ToString());
+                    }
+                    if (row["loginCounter"] != null && row["loginCounter"].ToString() != "")
+                    {
+                        _model.loginCounter = int.Parse(row["loginCounter"].ToString());
+                    }
+                    if (row["workerID"] != null)
+                    {
+                        _model.workerID = row["workerID"].ToString();
+                    }
+                    if (row["remark"] != null)
+                    {
+                        _model.remark = row["remark"].ToString();
+                    }
+                    if (row["departGuid"] != null && row["departGuid"].ToString() != "")
+                    {
+                        _model.departGuid = new Guid(row["departGuid"].ToString());
+                    }
+                    if (row["isSys"] != null && row["isSys"].ToString() != "")
+                    {
+                        _model.isSys = int.Parse(row["isSys"].ToString());
+                    }
+                    return ReturnDto<Sys_User>.QuickReturn(_model, ReturnCode.Success, "璇诲彇鎴愬姛锛�");
+                }
+                else
+                    return ReturnDto<Sys_User>.QuickReturn(_model, ReturnCode.Default, "璇诲彇澶辫触锛�");
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Debug(this.ToString(), "GetModel error:" + ex.Message);
+                return ReturnDto<Sys_User>.QuickReturn(_model, ReturnCode.Default, "璇诲彇澶辫触锛�");
+            }
+        }
+        #endregion
     }
 }

--
Gitblit v1.9.3