public JsonResult PageList([FromForm] string token, [FromForm] int userId = -1, [FromForm] int shareTypeId = -1, [FromForm] int shareTopicId = -1, [FromForm] int pageNumber = 1, [FromForm] int pageSize = 10) { DataResult dr = new DataResult(); try { int totalItemCount = shareBLL.Count(shareTypeId, shareTopicId, userId: userId); List <ShareEntity> shareEntities = shareBLL.List(shareTypeId, shareTopicId, userId: userId, pageNumber: pageNumber, pageSize: pageSize, totalCount: totalItemCount); UserEntity userEntity = new UserEntity(); if (!string.IsNullOrWhiteSpace(token)) { userEntity = this.GetUserByToken(token); shareEntities = ShareListEndorseCountByList(shareEntities, userEntity.userId); } else { shareEntities = ShareListEndorseCountByList(shareEntities); } shareEntities = ShareListCommentCountByList(shareEntities); PageData pageData = new PageData(shareEntities, pageNumber, pageSize, totalItemCount); dr.code = "200"; dr.data = pageData; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
public JsonResult Newest([FromForm] string token, [FromForm] int pageNumber = 1, [FromForm] int pageSize = 10) { DataResult dr = new DataResult(); try { CaseBLL caseBLL = new CaseBLL(); ShareBLL shareBLL = new ShareBLL(); CaseOfficialBLL caseOfficialBLL = new CaseOfficialBLL(); int caseCount = caseBLL.Count(); int shareCount = shareBLL.Count(); int caseOfficialCount = caseOfficialBLL.Count(); int totalItemCount = caseCount + shareCount + caseOfficialCount; UserEntity userEntity = new UserEntity(); if (!string.IsNullOrWhiteSpace(token)) { userEntity = this.GetUserByToken(token); } List <CircleResultHelper> circleResultHelpers = caseBLL.CaseAndShareList(pageNumber: pageNumber, pageSize: pageSize, totalCount: totalItemCount, thisUserId: userEntity.userId > 10000 ? userEntity.userId : -1); List <CaseEntity> caseEntities = circleResultHelpers.Where(it => it.type == (int)Entity.TypeEnumEntity.TypeEnum.案例).Select(it => it.caseEntity).ToList(); if (caseEntities.Count > 0) { caseEntities = CaseListEndorseCountByList(caseEntities, userEntity.userId > 10000 ? userEntity.userId : -1); caseEntities = CaseListCommentCountByList(caseEntities); caseEntities.ForEach(it => { circleResultHelpers.Find(itt => itt.id == it.caseId).caseEntity = it; }); } List <ShareEntity> shareEntities = circleResultHelpers.Where(it => it.type == (int)Entity.TypeEnumEntity.TypeEnum.说说).Select(it => it.shareEntity).ToList(); if (shareEntities.Count > 0) { shareEntities = ShareListEndorseCountByList(shareEntities, userEntity.userId > 10000 ? userEntity.userId : -1); shareEntities = ShareListCommentCountByList(shareEntities); shareEntities.ForEach(it => { circleResultHelpers.Find(itt => itt.id == it.shareId).shareEntity = it; }); } List <CaseOfficialEntity> caseOfficialEntities = circleResultHelpers.Where(it => it.type == (int)Entity.TypeEnumEntity.TypeEnum.官方案例).Select(it => it.caseOfficialEntity).ToList(); if (caseOfficialEntities.Count > 0) { caseOfficialEntities = CaseOfficialEndorseCountByList(caseOfficialEntities, userEntity.userId > 10000 ? userEntity.userId : -1); caseOfficialEntities = CaseOfficialCommentCountByList(caseOfficialEntities); caseOfficialEntities.ForEach(it => { circleResultHelpers.Find(itt => itt.id == it.caseOfficialId).caseOfficialEntity = it; }); } circleResultHelpers = (from crh in circleResultHelpers orderby crh.createDate descending select crh ).ToList(); PageData pageData = new PageData(circleResultHelpers, pageNumber, pageSize, totalItemCount); dr.code = "200"; dr.data = pageData; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }