From aaae232ced5996a26a8ea546b2e156b8edb521a1 Mon Sep 17 00:00:00 2001 From: lg <999544862qq.com> Date: 星期五, 30 八月 2024 13:22:15 +0800 Subject: [PATCH] 图片 --- WebApi/Gs.User/Service/MenuActionController.cs | 111 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 97 insertions(+), 14 deletions(-) diff --git a/WebApi/Gs.User/Service/MenuActionController.cs b/WebApi/Gs.User/Service/MenuActionController.cs index 42f57ab..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 { @@ -66,12 +67,13 @@ 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(), + formPath = dr["formPath"].ToString(), idx = int.Parse(dr["idx"].ToString()), category = int.Parse(dr["category"].ToString()), + statusTxt = (dr["status"].ToString() == "1" ? "姝e父" : "绂佺敤"), + categoryTxt = (dr["category"].ToString() == "1" ? "绐椾綋绫诲瀷" : "鎸夐挳绫诲瀷"), } ); } @@ -89,8 +91,22 @@ public ReturnDto<int?> DeleteModel([FromBody] MenuAction model) { int rtnInt = (int)ReturnCode.Default; + int cont = 0; try { + //鏄惁鍐呯疆 + cont = int.Parse(DbHelperSQL.GetSingle("select count(1) from sys_MenuAction where guid='" + model.guid.ToString() + "' and [isSys]=1").ToString()); + if (cont > 0) + { + return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "鍒犻櫎澶辫触锛岃鏉$洰涓虹郴缁熷唴缃紝涓嶅彲鍒犻櫎锛�"); + } + cont = 0; + //鏄惁鏈夊瓙鑿滃崟 + cont = int.Parse(DbHelperSQL.GetSingle("select count(1) from sys_MenuAction where upguid='" + model.guid.ToString() + "'").ToString()); + if (cont > 0) + { + return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "鍒犻櫎澶辫触锛岃鏉$洰涓嬮潰鏈夊瓙鑿滃崟锛屼笉鍙垹闄わ紒"); + } rtnInt = DbHelperSQL.ExecuteSql("delete from dbo.sys_MenuAction where guid='" + model.guid.ToString() + "'"); } catch (Exception ex) @@ -112,14 +128,12 @@ [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; + string formPath = model.formPath; int category = model.category; int idx = model.idx; int? rtnInt = (int)ReturnCode.Default; @@ -127,24 +141,23 @@ 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(" set upGuid=@upGuid,name=@name,icon=@icon,status=@status,formPath=@formPath,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(" guid,upGuid,name,icon,status,formPath,category,idx)"); strSql.Append(" values ("); - strSql.Append("'" + guid + "',@upGuid,@name,@serialNumber,@icon,@status,@fromPath,@category,@idx)"); + strSql.Append("'" + guid + "',@upGuid,@name,@icon,@status,@formPath,@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("@formPath",formPath), new SqlParameter("@category",category), new SqlParameter("@idx",idx), }; @@ -158,7 +171,7 @@ rtnInt = (int)ReturnCode.Exception; } if (rtnInt > 0) - return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, "澧炲姞鎴愬姛锛�"); + return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, "鎿嶄綔鎴愬姛锛�"); else return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, "澧炲姞澶辫触锛岃閲嶈瘯锛�"); } @@ -170,7 +183,7 @@ /// <returns></returns> [RequestMethod(RequestMethods.POST)] [AllowAnonymous] - public ReturnDto<MenuAction> GetModel([FromBody] MenuAction model ) + public ReturnDto<MenuAction> GetModel([FromBody] MenuAction model) { MenuAction m = new MenuAction(); System.Text.StringBuilder sbSql = new StringBuilder(); @@ -185,10 +198,9 @@ 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.formPath = dr["formPath"].ToString(); m.idx = int.Parse(dr["idx"].ToString()); m.category = int.Parse(dr["category"].ToString()); return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "璇诲彇鎴愬姛锛�"); @@ -202,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, "璇诲彇鎴愬姛"); + } + } } -- Gitblit v1.9.3