74 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			74 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								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
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /// <summary>
							 | 
						|||
| 
								 | 
							
								    ///  菜单服务
							 | 
						|||
| 
								 | 
							
								    /// </summary>
							 | 
						|||
| 
								 | 
							
								    [ServiceInjection(InjectionType.Transient)]
							 | 
						|||
| 
								 | 
							
								    public class MeauService : BaseService<Meau>
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        public MeauService(IConfiguration config) : base(config, nameof(Meau))
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取菜单列表
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="input"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public async Task<object> GetMeauList(reqpage input)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Expression<Func<Meau, bool>> 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);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 新加
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="input"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public async Task<ApiResult> AddMeau(MeauDto input)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (await Exist(input))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return new ApiResult { code = 1, msg = $"{input.MenuName}的菜单已存在" };
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            var entity = input.Adapt<Meau>();
							 | 
						|||
| 
								 | 
							
								            if (entity != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                await base.CreateAsync(entity);
							 | 
						|||
| 
								 | 
							
								                return new ApiResult { code = 0, msg = "" };
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return new ApiResult { code = 1, msg = "菜单添加失败" }; ;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 是否存在
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="input"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public async Task<bool> Exist(MeauDto input)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var entity = input.Adapt<MeauDto>();
							 | 
						|||
| 
								 | 
							
								            Expression<Func<Meau, bool>> exp = filter => filter.MenuName == entity.MenuName;
							 | 
						|||
| 
								 | 
							
								            return await base.Exist(exp);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |