public async Task <ActionResult> GetPageListJson(TerInforListParam param, Pagination pagination) { OperatorInfo user = await Operator.Instance.Current(); TData <List <TerInforEntity> > obj = await terInforBLL.GetPageList(param, pagination, user); return(Json(obj)); }
/// <summary> /// 创建查询sql /// </summary> /// <param name="param">查询条件数据</param> /// <returns></returns> private StringBuilder CreateListSql(TerInforListParam param, OperatorInfo user) { StringBuilder sql = new StringBuilder(); sql.AppendFormat(" SELECT a.*,b.RealName AS BaseCreatorTxt, "); sql.AppendFormat(" c.RealName AS SaleManTxt, "); sql.AppendFormat(" c.DelegetZoneTxt AS Zone, "); sql.AppendFormat(" d.RealName AS BaseModifierTxt, "); sql.AppendFormat(" e.RealName AS ManageTxt, "); sql.AppendFormat(" f.PartCode AS TerPartCode, "); sql.AppendFormat(" f.PartName AS TerPartTxt "); sql.AppendFormat(" FROM ( "); sql.AppendFormat(" SELECT * FROM ter_infor WHERE 1=1"); if (param != null) { if (!string.IsNullOrEmpty(param.TerName)) { sql.AppendFormat(" AND TerName LIKE '%{0}%'", param.TerName); } if (!string.IsNullOrEmpty(param.TerNumber)) { sql.AppendFormat(" AND TerNumber LIKE '%{0}%'", param.TerNumber); } if (!user.IsAdminOrDev) { sql.AppendFormat(" AND ManageId = {0}", user.UserId); } if (!string.IsNullOrEmpty(param.StartTime)) { sql.AppendFormat(" AND BaseCreateTime >'{0} 00:00:00'", param.StartTime); } if (!string.IsNullOrEmpty(param.EndTime)) { sql.AppendFormat(" AND BaseCreateTime <'{0} 23:59:59'", param.EndTime); } } sql.AppendFormat(" ) a "); sql.AppendFormat(" JOIN sysuser b ON a.BaseCreatorId = b.Id "); sql.AppendFormat(" LEFT JOIN sysuser C ON a.SaleManId = C.Id "); sql.AppendFormat(" LEFT JOIN sysuser d ON a.BaseModifierId = d.Id "); sql.AppendFormat(" LEFT JOIN sysuser e ON a.ManageId = e.Id "); sql.AppendFormat(" JOIN ter_parts f ON a.TerPartId = f.Id "); // LogHelper.Info(" CreateListSql sql:"+sql.ToString()); return sql; }
public async Task <TData <List <TerInforEntity> > > GetList(TerInforListParam param, OperatorInfo user) { TData <List <TerInforEntity> > obj = new TData <List <TerInforEntity> >(); obj.Data = await terInforService.GetList(param, user); obj.Total = obj.Data.Count; obj.Tag = 1; return(obj); }
public async Task <TData <List <TerInforEntity> > > GetPageList(TerInforListParam param, Pagination pagination, OperatorInfo user) { TData <List <TerInforEntity> > obj = new TData <List <TerInforEntity> >(); obj.Data = await terInforService.GetPageList(param, pagination, user); obj.Total = pagination.TotalCount; obj.PageTotal = pagination.TotalPage; obj.Tag = 1; return(obj); }
public async Task<List<TerInforEntity>> GetPageList(TerInforListParam param, Pagination pagination, OperatorInfo user) { /* var expression = ListFilter(param); var list= await this.BaseRepository().FindList(expression, pagination); return list.ToList(); */ StringBuilder sql = CreateListSql(param, user); var data = await this.BaseRepository().FindList<TerInforEntity>(sql.ToString(), pagination); List<TerInforEntity> list = data.list.ToList<TerInforEntity>(); return list; }
private Expression<Func<TerInforEntity, bool>> ListFilter(TerInforListParam param) { var expression = LinqExtensions.True<TerInforEntity>(); if (param != null) { if (!string.IsNullOrEmpty(param.TerName)) { expression = expression.And(t => t.TerName.Contains(param.TerName)); } if (!string.IsNullOrEmpty(param.TerNumber)) { expression = expression.And(t => t.TerNumber.Contains(param.TerNumber)); } } return expression; }
public async Task<List<TerInforEntity>> GetList(TerInforListParam param, OperatorInfo user) { var expression = ListFilter(param); var list = await this.BaseRepository().FindList(expression); return list.ToList(); }