123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using Attribute;
- using Model;
- using Service;
- namespace Services
- {
- /// <summary>
- /// 角色菜单
- /// </summary>
- [AppService(ServiceType = typeof(ISysRoleMenuService), ServiceLifetime = LifeTime.Transient)]
- public class SysRoleMenuService : BaseService<SysRoleMenu>, ISysRoleMenuService
- {
- public int AddRoleMenu(List<SysRoleMenu> sysRoleMenus)
- {
- return Insert(sysRoleMenus);
- }
- public bool CheckMenuExistRole(long menuId)
- {
- return Count(it => it.MenuId == menuId) > 0;
- }
- public int DeleteRoleMenuByRoleId(long roleId)
- {
- return Delete(roleId);
- }
- public bool DeleteRoleMenuByRoleIdMenuIds(long roleId, long[] menuIds)
- {
- return Delete(f => f.RoleId == roleId && menuIds.Contains(f.MenuId));
- }
- /// <summary>
- /// 根据角色获取菜单id
- /// </summary>
- /// <param name="roleId"></param>
- /// <returns></returns>
- public List<SysRoleMenu> SelectRoleMenuByRoleId(long roleId)
- {
- return GetList(f => f.RoleId == roleId);
- }
- /// <summary>
- /// 根据用户所有角色获取菜单
- /// </summary>
- /// <param name="roleIds"></param>
- /// <returns></returns>
- public List<SysRoleMenu> SelectRoleMenuByRoleIds(long[] roleIds)
- {
- return GetList(it => roleIds.Contains(it.RoleId));
- }
- }
- }
|