using langguanApi.Extensions.AutoDI; using langguanApi.Model; using langguanApi.Model.Dto.SystemConfigurationDto; using langguanApi.Model.SystemConfigurationEntity; using Mapster; using System.Linq.Expressions; namespace langguanApi.Service { /// /// 菜单服务 /// [ServiceInjection(InjectionType.Transient)] public class MeauService : BaseService { public MeauService(IConfiguration config) : base(config, nameof(Meau)) { } /// /// 获取菜单列表 /// /// /// public async Task GetMeauList(reqpage input) { Expression> exp = filter =>filter.IsDelete == false; if (!string.IsNullOrEmpty(input.key)) { exp=filter => filter.MenuName.Contains(input.key); } return await base.GetPager(new ReqPaing() { pageSize = input.pageSize, current = input.current }, exp); } /// /// 新加 /// /// /// public async Task AddMeau(MeauDto input) { if (await Exist(input)) { return new ApiResult { code = 1, msg = $"{input.MenuName}的菜单已存在" }; } var entity = input.Adapt(); if (entity != null) { await base.CreateAsync(entity); return new ApiResult { code = 0, msg = "" }; } return new ApiResult { code = 1, msg = "菜单添加失败" }; ; } /// /// 是否存在 /// /// /// public async Task Exist(MeauDto input) { var entity = input.Adapt(); Expression> exp = filter => filter.MenuName == entity.MenuName; return await base.Exist(exp); } } }