53 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
using langguanApi.Extensions.AutoDI;
 | 
						|
using langguanApi.Model;
 | 
						|
using langguanApi.Model.Dto;
 | 
						|
using System.Linq.Expressions;
 | 
						|
 | 
						|
namespace langguanApi.Service
 | 
						|
{
 | 
						|
    [ServiceInjection(InjectionType.Transient)]
 | 
						|
    public class AlertService : BaseService<Alert>
 | 
						|
    {
 | 
						|
        public AlertService(IConfiguration config) : base(config, nameof(Alert))
 | 
						|
        {
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 新加
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="input"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public async Task<ApiResult> Add(Alert input)
 | 
						|
        {
 | 
						|
            if (input != null)
 | 
						|
            {
 | 
						|
                await base.CreateAsync(input);
 | 
						|
                return new ApiResult { code = 0, msg = "" };
 | 
						|
            }
 | 
						|
            return new ApiResult { code = -1, msg = "" }; ;
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 首页数据,最近7天的
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        public async Task<object> IndexData()
 | 
						|
        {
 | 
						|
            Expression<Func<Alert, bool>> exp = filter => filter.CreateDateTime >= DateTime.Now.AddDays(-7) && filter.IsDelete == false;
 | 
						|
            return (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime);
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 分页取数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="input"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public async Task<object> GetPage(reqpage input)
 | 
						|
        {
 | 
						|
            Expression<Func<Alert, bool>> exp = filter => filter.DeviceMn.Contains(input.key) && filter.IsDelete == false;
 | 
						|
            return await base.GetPager(new ReqPaing()
 | 
						|
            {
 | 
						|
                pageSize = input.pageSize,
 | 
						|
                current = input.current
 | 
						|
            }, exp);
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |