SysRoleMenuService.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Attribute;
  2. using Model;
  3. using Service;
  4. namespace Services
  5. {
  6. /// <summary>
  7. /// 角色菜单
  8. /// </summary>
  9. [AppService(ServiceType = typeof(ISysRoleMenuService), ServiceLifetime = LifeTime.Transient)]
  10. public class SysRoleMenuService : BaseService<SysRoleMenu>, ISysRoleMenuService
  11. {
  12. public int AddRoleMenu(List<SysRoleMenu> sysRoleMenus)
  13. {
  14. return Insert(sysRoleMenus);
  15. }
  16. public bool CheckMenuExistRole(long menuId)
  17. {
  18. return Count(it => it.MenuId == menuId) > 0;
  19. }
  20. public int DeleteRoleMenuByRoleId(long roleId)
  21. {
  22. return Delete(roleId);
  23. }
  24. public bool DeleteRoleMenuByRoleIdMenuIds(long roleId, long[] menuIds)
  25. {
  26. return Delete(f => f.RoleId == roleId && menuIds.Contains(f.MenuId));
  27. }
  28. /// <summary>
  29. /// 根据角色获取菜单id
  30. /// </summary>
  31. /// <param name="roleId"></param>
  32. /// <returns></returns>
  33. public List<SysRoleMenu> SelectRoleMenuByRoleId(long roleId)
  34. {
  35. return GetList(f => f.RoleId == roleId);
  36. }
  37. /// <summary>
  38. /// 根据用户所有角色获取菜单
  39. /// </summary>
  40. /// <param name="roleIds"></param>
  41. /// <returns></returns>
  42. public List<SysRoleMenu> SelectRoleMenuByRoleIds(long[] roleIds)
  43. {
  44. return GetList(it => roleIds.Contains(it.RoleId));
  45. }
  46. }
  47. }