Explorar o código

添加MobileMenuLoad

yuanrf hai 6 meses
pai
achega
05ee9e288f

+ 12 - 0
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -1879,6 +1879,18 @@ And u.UId = {0} And u.FId = 1 ", dto.UserId);
             _JobPostAuthorityRepository.CommitTran();
             return Ok(JsonView(200, "成功", new { }));
         }
+
+        /// <summary>
+        /// 获取员工权限
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public IActionResult MobileMenuLoad(MobileMenuLoadDto Dto)
+        {
+            return Ok(JsonView(200, "成功", _SystemMenuPermissionRepository.MobileMenuLoad(Dto.uid, Dto.PortType).Data));
+        }
         #endregion
 
         #region 页面配置

+ 6 - 0
OASystem/OASystem.Domain/Dtos/System/SaveJobDto.cs

@@ -42,4 +42,10 @@ namespace OASystem.Domain.Dtos.System
         /// </summary>
         public List<int> FIds { get; set; }
     }
+
+    public class MobileMenuLoadDto
+    {
+        public int uid { get; set; }
+        public int PortType { get; set; }
+    }
 }

+ 78 - 0
OASystem/OASystem.Infrastructure/Repositories/System/SystemMenuPermissionRepository.cs

@@ -179,6 +179,84 @@ namespace OASystem.Infrastructure.Repositories.System
             return result;
         }
 
+        public Result MobileMenuLoad(int uid, int PortType)
+        {
+            Result result = new Result();
+            result.Data = new string[0];
+
+            if (uid != 0)
+            {
+                List<MenuLoadView> DBData = new List<MenuLoadView>();
+                string sql = $@"
+                     select a.UId,a.SmId,b.Id as Funid,b.FunctionName,b.FunctionCode,c.Id as modulid,
+                      c.Name as modulName,c.STid,d.Id as pageid ,d.Name as PageName,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
+                      d.IosUrl
+                      from Sys_UserAuthority a inner join Sys_PageFunctionPermission b on a.FId = b.Id 
+                      inner join Sys_SystemMenuPermission d on a.SmId = d.Id inner join Sys_SetData c on c.Id = d.Mid
+                      where uid = {uid} and a.IsDel= 0  and b.IsDel = 0 
+                      and b.IsEnable = 1 and c.IsDel = 0 and d.IsDel = 0   ";
+
+                if (PortType == 1)
+                {
+                    //只返回查看权限
+                    //sql += $@" and b.Id = 1 and d.IsEnable = 1  group by 
+                    //  a.UId,a.SmId,b.Id,b.FunctionName,b.FunctionCode,c.Id,
+                    //  c.Name,c.STid,d.Id,d.Name,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
+                    //  d.IosUrl";
+
+                    //返回所有权限
+                    sql += $@" and d.IsEnable = 1 group by 
+                      a.UId,a.SmId,b.Id,b.FunctionName,b.FunctionCode,c.Id,
+                      c.Name,c.STid,d.Id,d.Name,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
+                      d.IosUrl";
+                    DBData = _sqlSugar.SqlQueryable<MenuLoadView>(sql).ToList();
+                }
+                else if (PortType == 2)
+                {
+                    sql += $@" and d.phoneIsEnable = 1 group by 
+                      a.UId,a.SmId,b.Id,b.FunctionName,b.FunctionCode,c.Id,
+                      c.Name,c.STid,d.Id,d.Name,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
+                      d.IosUrl ";
+                    DBData = _sqlSugar.SqlQueryable<MenuLoadView>(sql).ToList();
+                }
+
+                result.Code = -1;
+                result.Msg = "暂无数据!";
+
+                if (DBData.Count > 0)
+                {
+                    result.Code = 0;
+                    result.Msg = "成功!";
+                    var arr = new ArrayList();
 
+                    var modelGroup = DBData.GroupBy(x => x.modulid);
+                    foreach (var item in modelGroup)
+                    {
+                        var modelData = new
+                        {
+                            modelId = item.Key,
+                            modelName = item.First().modulName,
+                            PageList = new ArrayList(),
+                        };
+
+                        var pageGroup = item.GroupBy(x => x.pageid);
+                        foreach (var page in pageGroup)
+                        {
+                            modelData.PageList.Add(new
+                            {
+                                pageId = page.Key,
+                                opList = page.Select(x => x.Funid)
+                            }) ;
+                        }
+
+                        arr.Add(modelData);
+                    }
+
+                    result.Data = arr;
+                }
+
+            }
+            return result;
+        }
     }
 }