using langguanApi.Extensions.AutoDI; using langguanApi.Model; using langguanApi.Model.Entity; using Mapster; using Microsoft.AspNetCore.Mvc.ApiExplorer; using System.Linq.Expressions; namespace langguanApi.Service { [ServiceInjection(InjectionType.Transient)] public class MenuService : BaseService { public MenuService(IConfiguration config) : base(config, nameof(Menu)) { } public async Task> GetMenusByParentId(string parentId) { Expression> exp = filter => filter.IsDelete == false && filter.ParentId == parentId; return (await base.GetListWithExp(exp)).OrderBy(x => x.Sort).ToList(); } public async Task AddMenu(AddMenuDto menu) { var entity = menu.Adapt(); await base.CreateAsync(entity); return new ApiResult(); } public async Task UpdateMenu(UpdateMenuDto menu) { var entity = menu.Adapt(); await base.UpdateAsync(entity.Id, entity); return new ApiResult(); } } }