123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using GxPress.Repository.Interface.SystemRoleMenus;
- using GxPress.Service.Interface.Role;
- using GxPress.Repository.Interface.SystemRole;
- using GxPress.Repository.Interface.Menus;
- using System.Threading.Tasks;
- using GxPress.Request.Role;
- using System.Collections.Generic;
- using System.Linq;
- namespace GxPress.Service.Implement.Role
- {
- public class RoleService : IRoleService
- {
- private readonly ISystemRoleMenusRepository systemRoleMenusRepository;
- private readonly IMenusRepository menusRepository;
- private readonly ISystemRoleRepository systemRoleRepository;
- public RoleService(ISystemRoleMenusRepository systemRoleMenusRepository, IMenusRepository menusRepository, ISystemRoleRepository systemRoleRepository)
- {
- this.systemRoleRepository = systemRoleRepository;
- this.systemRoleMenusRepository = systemRoleMenusRepository;
- this.menusRepository = menusRepository;
- }
- /// <summary>
- /// 添加权限菜单关联
- /// </summary>
- /// <param name="models"></param>
- /// <returns></returns>
- public async Task<bool> InsertSystemRoleMenusAsync(SystemRoleMenusInRequest models)
- {
- return await systemRoleMenusRepository.InsertAsync(models);
- }
- /// <summary>
- /// 添加权限
- /// </summary>
- /// <param name="models"></param>
- /// <returns></returns>
- public async Task<bool> InsertSystemRoleAsync(Entity.SystemRole.SystemRole model)
- {
- return await systemRoleRepository.InsertAsync(model) > 0;
- }
- /// <summary>
- /// 修改权限
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public async Task<bool> UpdateSystemRoleAsync(Entity.SystemRole.SystemRole model)
- {
- return await systemRoleRepository.UpdateAsync(model);
- }
- /// <summary>
- /// 删除权限
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<bool> DeleteSystemRoleAsync(int id)
- {
- return await systemRoleRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 添加菜单
- /// </summary>
- /// <param name="models"></param>
- /// <returns></returns>
- public async Task<bool> InsertMenusAsync(Entity.Menus.Menus model)
- {
- return await menusRepository.InsertAsync(model) > 0;
- }
- /// <summary>
- /// 修改菜单
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public async Task<bool> UpdateMenusAsync(Entity.Menus.Menus model)
- {
- return await menusRepository.UpdateAsync(model);
- }
- /// <summary>
- /// 删除菜单
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<bool> DeleteMenusAsync(int id)
- {
- return await menusRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 根据权限ID获取菜单
- /// </summary>
- /// <param name="roleId"></param>
- /// <returns></returns>
- public async Task<IEnumerable<Entity.Menus.Menus>> GetMenusAllAsync(int roleId)
- {
- //获取
- var models = await systemRoleMenusRepository.GetAllAsync(roleId);
- return await menusRepository.GetAllAsync(models.Select(n => n.Id).ToList());
- }
- /// <summary>
- /// 获取所有菜单
- /// </summary>
- /// <param name="roleId"></param>
- /// <returns></returns>
- public async Task<IEnumerable<Entity.Menus.Menus>> GetMenusAllAsync()
- {
- return await menusRepository.GetAllAsync();
- }
- }
- }
|