public async Task <MessageModel <PageModel <TopicDetail> > > Get(int page = 1, string tname = "", string key = "") { int tid = 0; if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) { key = ""; } if (string.IsNullOrEmpty(tname) || string.IsNullOrWhiteSpace(tname)) { tname = ""; } tname = UnicodeHelper.UnicodeToString(tname); if (!string.IsNullOrEmpty(tname)) { tid = ((await _topicServices.Query(ts => ts.tName == tname)).FirstOrDefault()?.Id).ObjToInt(); } int intPageSize = 6; var data = await _topicDetailServices.QueryPage(a => !a.tdIsDelete && a.tdSectendDetail == "tbug" && ((tid == 0 && true) || (tid > 0 && a.TopicId == tid)) && ((a.tdName != null && a.tdName.Contains(key)) || (a.tdDetail != null && a.tdDetail.Contains(key))), page, intPageSize, " Id desc "); return(new MessageModel <PageModel <TopicDetail> >() { msg = "获取成功", success = data.dataCount >= 0, response = data }); }
public async Task <object> Get() { List <Topic> topics = new List <Topic>(); try { topics = await _topicServices.Query(a => !a.tIsDelete && a.tSectendDetail == "tbug"); } catch (Exception) { } return(Ok(new { success = topics.Any(), data = topics })); }
public async Task <MessageModel <PageModel <TopicDetail> > > Get(int page = 1, string tname = "", string key = "") { var data = new MessageModel <PageModel <TopicDetail> >(); int intTotalCount = 6; int TotalCount = 0; int PageCount = 1; List <TopicDetail> topicDetails = new List <TopicDetail>(); //总数据,使用AOP切面缓存 //topicDetails = await _topicDetailServices.GetTopicDetails(); topicDetails = await _topicDetailServices.Query(a => !a.tdIsDelete && a.tdSectendDetail == "tbug"); if (!string.IsNullOrEmpty(key)) { topicDetails = topicDetails.Where(t => (t.tdName != null && t.tdName.Contains(key)) || (t.tdDetail != null && t.tdDetail.Contains(key))).ToList(); } tname = UnicodeHelper.UnicodeToString(tname); if (!string.IsNullOrEmpty(tname)) { var tid = (await _topicServices.Query(ts => ts.tName == tname)).FirstOrDefault()?.Id.ObjToInt(); topicDetails = topicDetails.Where(t => t.TopicId == tid).ToList(); } //筛选后的数据总数 TotalCount = topicDetails.Count; //筛选后的总页数 PageCount = (Math.Ceiling(TotalCount.ObjToDecimal() / intTotalCount.ObjToDecimal())).ObjToInt(); topicDetails = topicDetails.OrderByDescending(d => d.Id).Skip((page - 1) * intTotalCount).Take(intTotalCount).ToList(); return(new MessageModel <PageModel <TopicDetail> >() { msg = "获取成功", success = TotalCount >= 0, response = new PageModel <TopicDetail>() { page = page, pageCount = PageCount, dataCount = TotalCount, data = topicDetails, } }); }
public async Task <object> Get(int page = 1, string tname = "") { int intTotalCount = 6; int TotalCount = 1; List <TopicDetail> topicDetails = new List <TopicDetail>(); topicDetails = await _topicDetailServices.Query(a => !a.tdIsDelete && a.tdSectendDetail == "tbug"); if (!string.IsNullOrEmpty(tname)) { var tid = (await _topicServices.Query(ts => ts.tName == tname)).FirstOrDefault()?.Id.ObjToInt(); topicDetails = topicDetails.Where(t => t.TopicId == tid).ToList(); } topicDetails = topicDetails.OrderByDescending(d => d.Id).Skip((page - 1) * intTotalCount).Take(intTotalCount).ToList(); return(Ok(new { success = true, page = page, pageCount = TotalCount, Article = topicDetails })); }
public async Task <MessageModel <PageModel <TopicDetail> > > Get(int page = 1, string tname = "") { var data = new MessageModel <PageModel <TopicDetail> >(); int intTotalCount = 6; int TotalCount = 0; int PageCount = 1; List <TopicDetail> topicDetails = new List <TopicDetail>(); topicDetails = await _topicDetailServices.Query(a => !a.tdIsDelete && a.tdSectendDetail == "tbug"); if (!string.IsNullOrEmpty(tname)) { var tid = (await _topicServices.Query(ts => ts.tName == tname)).FirstOrDefault()?.Id.ObjToInt(); topicDetails = topicDetails.Where(t => t.TopicId == tid).ToList(); } //数据总数 TotalCount = topicDetails.Count; //总页数 PageCount = (Math.Ceiling(topicDetails.Count.ObjToDecimal() / intTotalCount.ObjToDecimal())).ObjToInt(); topicDetails = topicDetails.OrderByDescending(d => d.Id).Skip((page - 1) * intTotalCount).Take(intTotalCount).ToList(); return(new MessageModel <PageModel <TopicDetail> >() { Msg = "获取成功", Success = topicDetails.Count >= 0, Response = new PageModel <TopicDetail>() { page = page, pageCount = PageCount, dataCount = TotalCount, data = topicDetails, } }); }