BlRoleRight.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using ProjectBase.Data.BaseDAL;
  2. using ProjectBase.Data.Logs;
  3. using SIMDP.DAL.IDALSQL;
  4. using SIMDP.Model;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace SIMDP.BLL
  11. {
  12. public class BlRoleRight : BaseBLL<MoRoleRight>
  13. {
  14. private IDalRoleRight dalRoleRight;
  15. /// <summary>
  16. /// 构造函数
  17. /// </summary>
  18. public BlRoleRight() : base()
  19. {
  20. base.Init(this.GetType().FullName, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
  21. dalRoleRight = baseDal as IDalRoleRight;
  22. dalRoleRight.OnOperationLog += new OperationLogEventHandler(BlLogOperation.OnOperationLog);
  23. }
  24. public bool Function(string userId, string functionId)
  25. {
  26. List<MoRoleRight> MoList = null;
  27. try
  28. {
  29. // string sql = "select role_id, right_id, right_type from role_right b where b.role_id in " +
  30. //"(select a.role_id from user_role a where a.user_id = '" + userId +
  31. //"') and b.right_id = '" + functionId + "' UNION select role_id, right_id, right_type from role_right b where b.role_id in " +
  32. //"( select c.menu_function_id as right_id from menu c" +
  33. //" where c.menu_function_id = '" + functionId + "' and c.menu_delete = 0 and c.menu_visible = 1)";
  34. string sql = "select role_id, right_id, right_type from role_right b where b.role_id in " +
  35. "(select a.role_id from user_role a where a.user_id = '" + userId +
  36. "') and b.right_id = '" + functionId + "' and b.right_id in ( select c.menu_function_id as right_id from menu c" +
  37. " where c.menu_function_id = '" + functionId + "' and c.menu_delete = 0 and c.menu_visible = 1)";
  38. MoList = dalRoleRight.GetList(sql);
  39. }
  40. catch (Exception ex)
  41. {
  42. LogHelper.log.Error(functionId + "功能菜单验证失败 原因是{0}", ex);
  43. return false;
  44. }
  45. if (MoList == null || MoList.Count == 0)
  46. return false;
  47. else
  48. return true;
  49. }
  50. }
  51. }