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         |    4 
 WebApi/Gs.User/Modes/Sys_User.cs                 |   14 ++
 WebApi/Gs.User/Service/OrganizationController.cs |    2 
 WebApi/Gs.User/Service/RoleController.cs         |  194 ++++++++++++++++++++++++++++++++++++++
 WebApi/Gs.User/Modes/MenuAction.cs               |    6 +
 WebApi/Gs.User/Service/MenuActionController.cs   |   72 ++++++++++++++
 6 files changed, 290 insertions(+), 2 deletions(-)

diff --git a/WebApi/Gs.User/Modes/MenuAction.cs b/WebApi/Gs.User/Modes/MenuAction.cs
index 2aeb2e8..1c9c7ff 100644
--- a/WebApi/Gs.User/Modes/MenuAction.cs
+++ b/WebApi/Gs.User/Modes/MenuAction.cs
@@ -57,5 +57,11 @@
         /// </summary>
         public int isSys { get; set; }
 
+
+        /// <summary>
+        /// 缁勭粐Guid锛屼富瑕佺敤鍦ㄩ檮鍔犳潈闄�
+        /// </summary>
+        public string orgGuid { get; set; }
+
     }
 }
diff --git a/WebApi/Gs.User/Modes/Sys_User.cs b/WebApi/Gs.User/Modes/Sys_User.cs
index eea8aa0..91fcf53 100644
--- a/WebApi/Gs.User/Modes/Sys_User.cs
+++ b/WebApi/Gs.User/Modes/Sys_User.cs
@@ -177,6 +177,20 @@
             set { _issys = value; }
             get { return _issys; }
         }
+        /// <summary>
+        /// 閿佸畾璇存槑
+        /// </summary>
+        public string  isLockedTxt
+        {
+            get; set;
+        }
+        /// <summary>
+        /// 閿佸畾璇存槑
+        /// </summary>
+        public string isSysTxt
+        {
+            get; set;
+        }
         #endregion Model
 
     }
diff --git a/WebApi/Gs.User/Service/MenuActionController.cs b/WebApi/Gs.User/Service/MenuActionController.cs
index ab42aa4..035b1e4 100644
--- a/WebApi/Gs.User/Service/MenuActionController.cs
+++ b/WebApi/Gs.User/Service/MenuActionController.cs
@@ -9,6 +9,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using Gs.User.Modes;
+using Microsoft.Extensions.Primitives;
 
 namespace Gs.User.Service
 {
@@ -213,5 +214,76 @@
                 return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "璇诲彇澶辫触锛�");
             }
         }
+
+
+        /// <summary>
+        /// 璇诲彇鍔熻兘鑿滃崟鍒楄〃锛屽垎缁勭粐灞曠幇鏉冮檺鑿滃崟
+        /// </summary>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<PageList<MenuAction>> GetListPageByOrg()
+        {
+            System.Text.StringBuilder _orgSql = new StringBuilder();
+            _orgSql.Append("select org.guid,null as upGuid,org.name,org.status from [dbo].[sys_Organization] org   where upGuid is not null ");
+            DataSet _orgDset = new DataSet();
+            System.Text.StringBuilder sbSql = new StringBuilder();
+            try
+            {
+                _orgDset = Gs.Toolbox.DbHelperSQL.Query(_orgSql.ToString());
+                foreach (DataRow row in _orgDset.Tables[0].Rows)
+                {
+                    if (sbSql.Length > 0)
+                        sbSql.Append(" union all");
+                    sbSql.Append(" select org.guid,null as upGuid,org.name,org.status,'"+ row["guid"].ToString() + "' as orgGuid from [dbo].[sys_Organization] org where org.guid ='" + row["guid"].ToString() + "'");
+                    sbSql.Append(" union all");
+                    sbSql.Append(" select ma.guid,isnull(ma.upGuid,'" + row["guid"].ToString() + "') as upGuid,ma.name,ma.status,'"+ row["guid"].ToString() + "' as orgGuid from sys_MenuAction ma");
+                }
+            }
+            catch (Exception ex)
+            {
+                Gs.Toolbox.LogHelper.Debug(this.ToString(), "GetListPage error锛�" + ex.Message);
+                return ReturnDto<PageList<MenuAction>>.QuickReturn(default(PageList<MenuAction>), ReturnCode.Exception, "璇诲彇澶辫触");
+            }
+            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 = 999;
+                int pages = 1;
+                _pglist.total = intTotal;
+                _pglist.everyPageSize = 1;
+                _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(),
+                            status = int.Parse(dr["status"].ToString()),
+                            orgGuid = dr["orgGuid"].ToString(),
+                        }
+                    );
+                }
+            }
+            return ReturnDto<PageList<MenuAction>>.QuickReturn(_pglist, ReturnCode.Success, "璇诲彇鎴愬姛");
+        }
+
     }
 }
diff --git a/WebApi/Gs.User/Service/OrganizationController.cs b/WebApi/Gs.User/Service/OrganizationController.cs
index 997cc76..6e1e1a3 100644
--- a/WebApi/Gs.User/Service/OrganizationController.cs
+++ b/WebApi/Gs.User/Service/OrganizationController.cs
@@ -82,7 +82,7 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [RequestMethod(RequestMethods.POST)]
-        public ReturnDto<int?> DeleteModel([FromBody] MenuAction model)
+        public ReturnDto<int?> DeleteModel([FromBody] dynamic model)
         {
             int rtnInt = (int)ReturnCode.Default;
             int cont = 0;
diff --git a/WebApi/Gs.User/Service/RoleController.cs b/WebApi/Gs.User/Service/RoleController.cs
new file mode 100644
index 0000000..f10abca
--- /dev/null
+++ b/WebApi/Gs.User/Service/RoleController.cs
@@ -0,0 +1,194 @@
+锘縰sing Gs.Toolbox;
+using Gs.User.Modes;
+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 Microsoft.AspNetCore.Http.HttpResults;
+
+namespace Gs.User.Service
+{
+    [ApiGroup(ApiGroupNames.Auth)]
+    public class RoleController : IRomteService
+    {
+        /// <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.createDate" : 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_Role 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_Role 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 dr in dset.Tables[0].Rows)
+                {
+                    _pglist.list.Add(
+                        new
+                        {
+                            guid = Guid.Parse(dr["guid"].ToString()),
+                            roleName = dr["roleName"].ToString(),
+                            rolRemark = dr["rolRemark"].ToString(),
+                            createDate = dr["createDate"].ToString(),
+                            createBy = dr["createBy"].ToString(),
+                            lastUpdateDate = dr["lastUpdateDate"].ToString(),
+                            lastUpdatedBy = dr["lastUpdatedBy"].ToString(),
+                            status = dr["status"].ToString(),
+                        }
+                    );
+                }
+            }
+            return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist, ReturnCode.Success, "璇诲彇鎴愬姛");
+        }
+
+
+        /// <summary>
+        /// 鍒犻櫎
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [RequestMethod(RequestMethods.POST)]
+        public ReturnDto<int?> DeleteModel([FromBody] dynamic model)
+        {
+            int rtnInt = (int)ReturnCode.Default;
+            int cont = 0;
+            try
+            {
+                rtnInt = DbHelperSQL.ExecuteSql("delete from sys_Role 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] dynamic model)
+        {
+            Guid? guid = UtilityHelper.GetGuid(model.guid.ToString());
+            string roleName = model.roleName;
+            string rolRemark = model.rolRemark;
+            int status = model.status;
+            int? rtnInt = (int)ReturnCode.Default;
+            StringBuilder strSql = new StringBuilder();
+            if (guid != null)
+            {
+                strSql.Append(" update sys_Role");
+                strSql.Append(" set roleName=@roleName,rolRemark=@rolRemark,status=@status,lastUpdateDate=getdate()");
+                strSql.Append(" where guid='" + guid + "'");
+            }
+            else
+            {
+                guid = Guid.NewGuid();
+                strSql.Append("insert into sys_Role(");
+                strSql.Append(" guid,roleName,rolRemark,status,createDate,lastUpdateDate)");
+                strSql.Append(" values (");
+                strSql.Append("'" + guid + "',@roleName,@rolRemark,@status,getdate(),getdate())");
+            }
+            SqlParameter[] parameters = {
+             new SqlParameter("@roleName", roleName),
+             new SqlParameter("@rolRemark", rolRemark),
+             new SqlParameter("@status",status),
+         };
+            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] dynamic model)
+        {
+            dynamic m = new System.Dynamic.ExpandoObject();
+            System.Text.StringBuilder sbSql = new StringBuilder();
+            sbSql.Append("select top 1 * from sys_Role 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.roleName = dr["roleName"].ToString();
+                    m.rolRemark = dr["rolRemark"].ToString();
+                    m.createDate = dr["createDate"].ToString();
+                    m.createBy = dr["createBy"].ToString();
+                    m.lastUpdateDate = dr["lastUpdateDate"].ToString();
+                    m.lastUpdatedBy = dr["lastUpdatedBy"].ToString();
+                    m.status = dr["status"].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
index d404929..bb6b364 100644
--- a/WebApi/Gs.User/Service/UserController.cs
+++ b/WebApi/Gs.User/Service/UserController.cs
@@ -127,7 +127,8 @@
                                         }
                                     );
                                 }
-                                return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "鐧诲綍鎴愬姛锛�");
+                                string _msg = "娆㈣繋浣跨敤鏌愭煇鍏徃EMS绯荤粺锛屼綘鐨勮鑹蹭负銆愮鐞嗗憳銆戝綋鍓嶅叡鏈夈��20銆戞潯淇℃伅鏈鐞�";
+                                return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, _msg);
                             }
                         }
                     }
@@ -263,6 +264,7 @@
                     {
                         _model.isSys = int.Parse(row["isSys"].ToString());
                     }
+                    _model.isLockedTxt = row["isLocked"].ToString() != "1" ? "姝e父" : "琚攣瀹�";
                     _pglist.list.Add(_model);
                 }
             }

--
Gitblit v1.9.3