PermissionHelper.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using System.Data;
  6. using CoreEntity.Entity;
  7. using System.Data.SqlClient;
  8. using ZcPeng.PublicLibrary;
  9. using Common.Model;
  10. using Newtonsoft.Json.Converters;
  11. using Newtonsoft.Json;
  12. using Common.Wechat;
  13. using CoreEntity.DAL;
  14. namespace SupplierWeb.Codes.Auth
  15. {
  16. public class PermissionHelper
  17. {
  18. public static Dictionary<string,Permission> Permissions(int roleId,string filter = " and A.AuthType ='O'")
  19. {
  20. #region 获取角色的权限
  21. IList<Permission> perms = (List<Permission>)RoleDAL.GetPermissions(roleId, filter);
  22. #endregion
  23. Dictionary<string, Permission> permsd = new Dictionary<string, Permission>(perms.Count);
  24. foreach (Permission perm in perms)
  25. {
  26. if (perm.PermissionUrl!=null&&!permsd.ContainsKey(perm.PermissionUrl)) {
  27. perm.Roleids = null;
  28. permsd.Add(perm.PermissionUrl,perm);
  29. }
  30. }
  31. //IsoDateTimeConverter timejson = new IsoDateTimeConverter
  32. //{
  33. // DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
  34. //};
  35. //var jsonData = JsonConvert.SerializeObject(users, timejson);
  36. return permsd;
  37. }
  38. }
  39. }