using langguanApi.Extensions.AutoDI; using langguanApi.Model; using langguanApi.Model.Entity; using System.Linq.Expressions; namespace langguanApi.Service { [ServiceInjection(InjectionType.Transient)] public class RoleMenuServie : BaseService { public RoleMenuServie(IConfiguration config) : base(config, nameof(RoleMenu)) { } /// /// 根据角色ID获取角色菜单 /// /// /// public async Task> GetByRoleId(string roleId) { Expression> exp = filter => filter.IsDelete == false && filter.RoleId == roleId; return (await base.GetListWithExp(exp)).ToList(); } /// /// 表中添加角色菜单 /// /// /// public async Task AddRoleMenu(AddRoleMenuDTO input) { foreach (var item in input.MenuIds) { await base.CreateAsync(new RoleMenu() { RoleId = input.RoleId, MenuId = item }); } return new ApiResult() { code = 0 }; } public async Task DeleteRoleMenu(string roleId) { return null; } /// /// 更新角色菜单 /// /// /// public async Task UpdateRoleMenu(UpdateRoleMenuDTO input) { await base.BatchRemoveAsync(filter => filter.RoleId == input.RoleId); foreach (var item in input.MenuIds) { await base.CreateAsync(new RoleMenu() { RoleId = input.RoleId, MenuId = item }); } return new ApiResult() { code = 0 }; } } }