using Microsoft.AspNetCore.Http; using System; using System.Collections.Generic; using System.Linq.Expressions; using VOL.Core.CacheManager; using VOL.Core.Utilities; using VOL.Entity.DomainModels; using VOL.Entity.SystemModels; namespace VOL.Core.BaseProvider { public interface IService where T : BaseEntity { ICacheService CacheContext { get; } Microsoft.AspNetCore.Http.HttpContext Context { get; } /// /// 查询 /// /// /// PageGridData GetPageData(PageDataOptions pageData); object GetDetailPage(PageDataOptions pageData); WebResponseContent Upload(List files); WebResponseContent DownLoadTemplate(); WebResponseContent Import(List files); /// /// 导出 /// /// /// WebResponseContent Export(PageDataOptions pageData); /// /// 新增 /// /// 主表与子表的数据 /// WebResponseContent Add(SaveModel saveDataModel); /// /// /// /// 保存的实体 /// 是否对实体进行校验 /// WebResponseContent AddEntity(T entity, bool validationEntity = true); /// /// /// /// /// 保存的实体 /// 保存的明细 /// 是否对实体进行校验 /// WebResponseContent Add(T entity, List list = null, bool validationEntity = true) where TDetail : class; /// /// 编辑 /// /// 主表与子表的数据 /// WebResponseContent Update(SaveModel saveDataModel); /// /// 删除数据 /// /// 删除的主键 /// 是否删除对应明细(默认会删除明细) /// WebResponseContent Del(object[] keys, bool delList = true); WebResponseContent Audit(object[] id, int? auditStatus, string auditReason); (string, T, bool) ApiValidate(string bizContent, Expression> expression = null); /// /// /// /// /// /// 对指属性验证格式如:x=>new { x.UserName,x.Value } /// (string,TInput, bool) string:返回验证消息,TInput:bizContent序列化后的对象,bool:验证是否通过 (string, TInput, bool) ApiValidateInput(string bizContent, Expression> expression); /// /// /// /// /// /// 对指属性验证格式如:x=>new { x.UserName,x.Value } /// 对指定的字段只做合法性判断比如长度是是否超长 /// (string,TInput, bool) string:返回验证消息,TInput:bizContent序列化后的对象,bool:验证是否通过 (string, TInput, bool) ApiValidateInput(string bizContent, Expression> expression, Expression> validateExpression); /// /// 将数据源映射到新的数据中,List映射到List或TSource映射到TResult /// 目前只支持Dictionary或实体类型 /// /// /// /// /// 只映射返回对象的指定字段 /// 只映射数据源对象的指定字段 /// 过滤条件表达式调用方式:List表达式x => new { x[0].MenuName, x[0].Menu_Id},表示指定映射MenuName,Menu_Id字段 /// List list = new List(); /// list.MapToObject, List>(x => new { x[0].MenuName, x[0].Menu_Id}, null); /// ///过滤条件表达式调用方式:实体表达式x => new { x.MenuName, x.Menu_Id},表示指定映射MenuName,Menu_Id字段 /// Sys_Menu sysMenu = new Sys_Menu(); /// sysMenu.MapToObject(x => new { x.MenuName, x.Menu_Id}, null); /// TResult MapToEntity(TSource source, Expression> resultExpression, Expression> sourceExpression = null) where TResult : class; /// /// 将一个实体的赋到另一个实体上,应用场景: /// 两个实体,a a1= new a();b b1= new b(); a1.P=b1.P; a1.Name=b1.Name; /// /// /// /// /// /// 指定对需要的字段赋值,格式x=>new {x.Name,x.P},返回的结果只会对Name与P赋值 void MapValueToEntity(TSource source, TResult result, Expression> expression = null) where TResult : class; } }