winform+dev的前后台分离标准项目
lg
2024-08-30 aaae232ced5996a26a8ea546b2e156b8edb521a1
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, "读取成功");
        }
    }
}