35 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
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<Menu>
 | 
						|
    {
 | 
						|
        public MenuService(IConfiguration config) : base(config, nameof(Menu))
 | 
						|
        {
 | 
						|
        }
 | 
						|
        public async Task<List<Menu>> GetMenusByParentId(string parentId)
 | 
						|
        {
 | 
						|
            Expression<Func<Menu, bool>> exp = filter => filter.IsDelete == false && filter.ParentId == parentId;
 | 
						|
            return (await base.GetListWithExp(exp)).OrderBy(x => x.Sort).ToList();
 | 
						|
        }
 | 
						|
        public async Task<ApiResult> AddMenu(AddMenuDto menu)
 | 
						|
        {
 | 
						|
            var entity = menu.Adapt<Menu>();
 | 
						|
            await base.CreateAsync(entity);
 | 
						|
            return new ApiResult();
 | 
						|
        }
 | 
						|
        public async Task<ApiResult> UpdateMenu(UpdateMenuDto menu)
 | 
						|
        {
 | 
						|
            var entity = menu.Adapt<Menu>();
 | 
						|
            await base.UpdateAsync(entity.Id, entity);
 | 
						|
            return new ApiResult();
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |