From 94e53b9394aa981f0d6a1cd80edac9a9ba1ba97c Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期二, 27 八月 2024 11:08:07 +0800
Subject: [PATCH] 用户,权限,菜单

---
 WebApi/Gs.User/Service/UserController.cs       |   85 ++++++++++++
 WebApi/Gs.User/Modes/UserLogin.cs              |   28 ++++
 WebApi/Gs.User/Modes/MenuAction.cs             |   56 ++++++++
 WebApi/Gs.User/Service/MenuActionController.cs |  206 +++++++++++++++++++++++++++++
 4 files changed, 375 insertions(+), 0 deletions(-)

diff --git a/WebApi/Gs.User/Modes/MenuAction.cs b/WebApi/Gs.User/Modes/MenuAction.cs
new file mode 100644
index 0000000..6e1c262
--- /dev/null
+++ b/WebApi/Gs.User/Modes/MenuAction.cs
@@ -0,0 +1,56 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gs.User.Modes
+{
+    public class MenuAction
+    {
+        /// <summary>
+        /// 涓婚敭
+        /// </summary>
+        public Guid? guid { get; set; }
+
+        /// <summary>
+        /// 涓婄骇涓婚敭
+        /// </summary>
+        public Guid? upGuid { get; set; }
+
+        /// <summary>
+        /// 鑿滃崟鍚�
+        /// </summary>
+        public string name { get; set; }
+
+        /// <summary>
+        /// 缂栧彿
+        /// </summary>
+        public string serialNumber { get; set; }
+
+        /// <summary>
+        /// 鑿滃崟鍥炬爣
+        /// </summary>
+        public string icon { get; set; }
+
+        /// <summary>
+        /// 鐘舵��
+        /// </summary>
+        public int status { get; set; }
+
+        /// <summary>
+        /// 绐椾綋璺緞
+        /// </summary>
+        public string fromPath { get; set; }
+        /// <summary>
+        /// 鎺掑簭
+        /// </summary>
+        public int idx { get; set; }
+
+        /// <summary>
+        /// 绫诲埆
+        /// </summary>
+        public int category { get; set; }
+
+    }
+}
diff --git a/WebApi/Gs.User/Modes/UserLogin.cs b/WebApi/Gs.User/Modes/UserLogin.cs
new file mode 100644
index 0000000..49c93ce
--- /dev/null
+++ b/WebApi/Gs.User/Modes/UserLogin.cs
@@ -0,0 +1,28 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gs.User.Modes
+{
+    public class UserLogin
+    {
+        /// <summary>
+        /// 璐﹀彿
+        /// </summary>
+        public string accountNo { get; set; }
+
+        /// <summary>
+        /// 缁勭粐鏈烘瀯guid
+        /// </summary>
+        public Guid orgGuid { get; set; }
+
+        /// <summary>
+        /// 瀵嗙爜
+        /// </summary>
+        public string accountPwd { get; set; }
+
+
+    }
+}
diff --git a/WebApi/Gs.User/Service/MenuActionController.cs b/WebApi/Gs.User/Service/MenuActionController.cs
new file mode 100644
index 0000000..42f57ab
--- /dev/null
+++ b/WebApi/Gs.User/Service/MenuActionController.cs
@@ -0,0 +1,206 @@
+锘縰sing Gs.Toolbox;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Gs.User.Modes;
+
+namespace Gs.User.Service
+{
+    [ApiGroup(ApiGroupNames.Auth)]
+    public class MenuActionController : IRomteService
+    {
+
+        /// <summary>
+        /// 璇诲彇鍔熻兘鑿滃崟鍒楄〃锛屾敮鎸佸垎椤�
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<PageList<MenuAction>> GetListPage([FromBody] PageQuery model)
+        {
+            int currentPage = model.currentPage;
+            int everyPageSize = model.everyPageSize;
+            string sortName = string.IsNullOrEmpty(model.sortName) ? "a.idx" : 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_MenuAction 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 dbo.sys_MenuAction 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<MenuAction>>.QuickReturn(default(PageList<MenuAction>), ReturnCode.Exception, "璇诲彇澶辫触");
+            }
+            PageList<MenuAction> _pglist = new PageList<MenuAction>
+            {
+                total = 0,
+                everyPageSize = 0,
+                pages = 0,
+                list = new List<MenuAction>()
+            };
+            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 dr in dset.Tables[0].Rows)
+                {
+                    _pglist.list.Add(
+                        new MenuAction()
+                        {
+                            guid = Guid.Parse(dr["guid"].ToString()),
+                            upGuid = dr["upGuid"].ToString().Length > 0 ? Guid.Parse(dr["upGuid"].ToString()) : null,
+                            name = dr["name"].ToString(),
+                            serialNumber = dr["serialNumber"].ToString(),
+                            icon = dr["icon"].ToString(),
+                            status = int.Parse(dr["status"].ToString()),
+                            fromPath = dr["fromPath"].ToString(),
+                            idx = int.Parse(dr["idx"].ToString()),
+                            category = int.Parse(dr["category"].ToString()),
+                        }
+                    );
+                }
+            }
+            return ReturnDto<PageList<MenuAction>>.QuickReturn(_pglist, ReturnCode.Success, "璇诲彇鎴愬姛");
+        }
+
+
+        /// <summary>
+        /// 鍒犻櫎鍔熻兘鑿滃崟
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<int?> DeleteModel([FromBody] MenuAction model)
+        {
+            int rtnInt = (int)ReturnCode.Default;
+            try
+            {
+                rtnInt = DbHelperSQL.ExecuteSql("delete from dbo.sys_MenuAction where guid='" + model.guid.ToString() + "'");
+            }
+            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] MenuAction model)
+        {
+            string dddd= model.guid.ToString();
+            Guid? guid = model.guid;
+            Guid? upGuid = model.upGuid;
+            string name = model.name;
+            string serialNumber = model.serialNumber;
+            string icon = model.icon;
+            int status = model.status;
+            string fromPath = model.fromPath;
+            int category = model.category;
+            int idx = model.idx;
+            int? rtnInt = (int)ReturnCode.Default;
+            StringBuilder strSql = new StringBuilder();
+            if (guid != null)
+            {
+                strSql.Append(" update dbo.sys_MenuAction");
+                strSql.Append(" set upGuid=@upGuid,name=@name,serialNumber=@serialNumber,icon=@icon,status=@status,fromPath=@fromPath,category=@category,idx=@idx");
+                strSql.Append(" where guid='" + guid + "'");
+            }
+            else
+            {
+                guid = Guid.NewGuid();
+                strSql.Append("insert into dbo.sys_MenuAction(");
+                strSql.Append(" guid,upGuid,name,serialNumber,icon,status,fromPath,category,idx)");
+                strSql.Append(" values (");
+                strSql.Append("'" + guid + "',@upGuid,@name,@serialNumber,@icon,@status,@fromPath,@category,@idx)");
+            }
+            SqlParameter[] parameters = {
+             new SqlParameter("@upGuid", upGuid),
+             new SqlParameter("@name", name),
+             new SqlParameter("@serialNumber",serialNumber),
+             new SqlParameter("@icon",icon),
+             new SqlParameter("@status",status),
+             new SqlParameter("@fromPath",fromPath),
+             new SqlParameter("@category",category),
+             new SqlParameter("@idx",idx),
+         };
+            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<MenuAction> GetModel([FromBody] MenuAction model )
+        {
+            MenuAction m = new MenuAction();
+            System.Text.StringBuilder sbSql = new StringBuilder();
+            sbSql.Append("select top 1 * from dbo.sys_MenuAction  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 dr = dset.Tables[0].Rows[0];
+                    m.guid = Guid.Parse(dr["guid"].ToString());
+                    m.upGuid = dr["upGuid"].ToString().Length > 0 ? Guid.Parse(dr["upGuid"].ToString()) : null;
+                    m.name = dr["name"].ToString();
+                    m.serialNumber = dr["serialNumber"].ToString();
+                    m.icon = dr["icon"].ToString();
+                    m.status = int.Parse(dr["status"].ToString());
+                    m.fromPath = dr["fromPath"].ToString();
+                    m.idx = int.Parse(dr["idx"].ToString());
+                    m.category = int.Parse(dr["category"].ToString());
+                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "璇诲彇鎴愬姛锛�");
+                }
+                else
+                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "璇诲彇澶辫触锛�");
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Debug(this.ToString(), "GetModel error:" + ex.Message);
+                return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "璇诲彇澶辫触锛�");
+            }
+        }
+    }
+}
diff --git a/WebApi/Gs.User/Service/UserController.cs b/WebApi/Gs.User/Service/UserController.cs
new file mode 100644
index 0000000..614295d
--- /dev/null
+++ b/WebApi/Gs.User/Service/UserController.cs
@@ -0,0 +1,85 @@
+锘縰sing Gs.Toolbox;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Data;
+using System.Linq;
+using System.Text;
+using Gs.User.Modes;
+
+namespace Gs.User.Service
+{
+
+    [ApiGroup(ApiGroupNames.Auth)]
+    public class UserController : IRomteService
+    {
+        /// <summary>
+        /// 鐢ㄦ埛鐧诲綍
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<System.Dynamic.ExpandoObject> UserLogin([FromBody] UserLogin model)
+        {
+            string accountPwd = model.accountPwd;
+            string accountNo = model.accountNo;
+            Guid orgGuid = model.orgGuid;
+            string strPass = "";
+            DataSet dset = new DataSet();
+            dynamic m = new System.Dynamic.ExpandoObject();
+            using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
+            {
+                using (SqlCommand cmd = new SqlCommand("[prc_user_login]", conn))
+                {
+                    try
+                    {
+                        conn.Open();
+                        cmd.CommandType = CommandType.StoredProcedure;
+                        SqlParameter[] parameters = new SqlParameter[] {
+                                new SqlParameter("@accountNo",accountNo),
+                                new SqlParameter("@accountPwd",strPass),
+                                new SqlParameter("@orgGuid",orgGuid),
+                            };
+                        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();
+                            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, "鐧诲綍鎴愬姛锛�");
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        LogHelper.Debug(this.ToString(), "UserLogin error锛�" + ex.Message);
+                    }
+                    finally
+                    {
+                        conn.Close();
+                    }
+                }
+            }
+            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "鐧诲綍澶辫触锛�");
+        }
+    }
+}

--
Gitblit v1.9.3