public string Search() { ApiResult result = new ApiResult(); try { var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved && x.ArticlePower == Enum_ArticlePower.Public && x.Submission >= Enum_Submission.Approved); var title = SqlFilter(ZNRequest.GetString("Title")); if (!string.IsNullOrWhiteSpace(title)) { query.And("Title").IsNotNull().And("Title").Like("%" + title + "%"); } var UserNumber = ZNRequest.GetString("UserNumber"); if (!string.IsNullOrWhiteSpace(UserNumber)) { var black = db.Find <Black>(x => x.CreateUserNumber == UserNumber); if (black.Count > 0) { var userids = black.Select(x => x.ToUserNumber).ToArray(); query = query.And("CreateUserNumber").NotIn(userids); } } var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.result = true; result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc(new string[] { "Recommend", "Views" }).ExecuteTypedList <Article>(); List <ArticleJson> newlist = ArticleListInfo(list, UserNumber); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Article_Search:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Article() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var fans = db.Find <Fan>(x => x.CreateUserNumber == UserNumber).ToList(); if (fans.Count == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved); query = query.And("ArticlePower").In(new int[] { Enum_ArticlePower.Public, Enum_ArticlePower.Password }); query.And("CreateUserNumber").In(fans.Select(x => x.ToUserNumber).ToArray()); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc(new string[] { "ID" }).ExecuteTypedList <Article>(); List <ArticleJson> newlist = ArticleListInfo(list, UserNumber); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Fan_Article:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string ToUser_1_3() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var query = new SubSonic.Query.Select(provider).From <Order>().Where <Order>(x => x.Status == Enum_Status.Approved); query = query.And("CreateUserNumber").IsEqualTo(UserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Order>(); var userarray = list.Select(x => x.ToUserNumber).Distinct().ToList(); var allusers = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Number", "Cover").From <User>().And("Number").In(userarray.ToArray()).ExecuteTypedList <User>(); List <OrdersJson> newlist = new List <OrdersJson>(); list.ForEach(x => { var user = allusers.FirstOrDefault(y => y.Number == x.ToUserNumber); if (user != null) { OrdersJson model = new OrdersJson(); model.ID = x.ID; model.CreateDate = x.CreateDate.ToString("yyyy-MM-dd hh:mm:ss"); model.Price = x.Price; model.UserID = user.ID; model.UserNumber = user.Number; model.UserAvatar = user.Avatar; model.UserName = user.NickName; model.UserCover = user.Cover; newlist.Add(model); } }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Order_ToUser_1_3:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string LinkAll() { ApiResult result = new ApiResult(); try { User user = GetUserInfo(); if (user == null) { result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin); result.code = Enum_ErrorCode.UnLogin; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var query = new SubSonic.Query.Select(provider, "ID", "Number", "Title", "Cover", "CreateUserNumber", "CreateDate", "ArticlePower", "ArticlePowerPwd").From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved && x.Submission >= Enum_Submission.Approved); query = query.And("CreateUserNumber").IsEqualTo(user.Number); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var sort = new string[] { "ID" }; var list = query.Paged(pager.Index, pager.Size).OrderDesc(sort).ExecuteTypedList <Article>(); var newlist = (from l in list select new { ID = l.ID, Number = l.Number, Title = l.Title, Cover = l.Cover, CreateDate = l.CreateDate.ToString("yyyy-MM-dd hh:mm:ss"), ArticlePower = l.ArticlePower, ArticlePowerPwd = l.ArticlePowerPwd }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Article_LinkAll:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Pic() { ApiResult result = new ApiResult(); try { var Number = ZNRequest.GetString("Number"); var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <ArticlePart>().Where <ArticlePart>(x => x.Types == Enum_ArticlePart.Pic && x.Status != Enum_Status.Delete && x.Status != Enum_Status.DeleteCompletely); if (Number != UserNumber) { query = query.And("Status").IsEqualTo(Enum_Status.Approved); } query = query.And("CreateUserNumber").IsEqualTo(UserNumber); var recordCount = query.GetRecordCount(); var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <ArticlePart>(); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = list }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_User_Pic:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Apply_1_3() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var query = new SubSonic.Query.Select(provider).From <ApplyMoney>().Where <ApplyMoney>(x => x.Status == Enum_Status.Approved); query = query.And("CreateUserNumber").IsEqualTo(UserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <ApplyMoney>(); List <OrdersJson> newlist = new List <OrdersJson>(); list.ForEach(x => { OrdersJson model = new OrdersJson(); model.ID = x.ID; model.CreateDate = x.CreateDate.ToString("yyyy-MM-dd hh:mm:ss"); model.Price = Tools.SafeInt(System.Configuration.ConfigurationManager.AppSettings["applymoney"]) * 100; newlist.Add(model); }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Order_Apply_1_3:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 列表 /// </summary> public ActionResult All() { try { var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Order>().Where <Order>(x => x.Status == Enum_Status.Approved); var CreateUserNumber = ZNRequest.GetString("CreateUserNumber"); var ToUserNumber = ZNRequest.GetString("ToUserNumber"); if (!string.IsNullOrWhiteSpace(CreateUserNumber)) { query = query.And("CreateUserNumber").IsEqualTo(CreateUserNumber); } if (!string.IsNullOrWhiteSpace(ToUserNumber)) { query = query.And("ToUserNumber").IsEqualTo(ToUserNumber); } var recordCount = query.GetRecordCount(); if (recordCount == 0) { return(Json(new { currpage = pager.Index, records = recordCount, totalpage = 1, list = string.Empty }, JsonRequestBehavior.AllowGet)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Order>(); var fromarray = list.Select(x => x.CreateUserNumber).Distinct().ToList(); var toarray = list.Select(x => x.ToUserNumber).Distinct().ToList(); fromarray.AddRange(toarray); var allusers = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Number", "Cover").From <User>().And("Number").In(fromarray.ToArray()).ExecuteTypedList <User>(); List <OrderJson> newlist = new List <OrderJson>(); list.ForEach(x => { var fromUser = allusers.FirstOrDefault(y => y.Number == x.CreateUserNumber); var toUser = allusers.FirstOrDefault(y => y.Number == x.ToUserNumber); OrderJson model = new OrderJson(); model.ID = x.ID; model.CreateDate = x.CreateDate.ToString("yyyy-MM-dd"); model.Price = x.Price; if (fromUser != null) { model.FromUserID = fromUser.ID; model.FromUserNumber = fromUser.Number; model.FromUserAvatar = fromUser.Avatar; model.FromUserName = fromUser.NickName; model.FromUserCover = fromUser.Cover; } if (toUser != null) { model.ToUserID = toUser.ID; model.ToUserNumber = toUser.Number; model.ToUserAvatar = toUser.Avatar; model.ToUserName = toUser.NickName; model.ToUserCover = toUser.Cover; } newlist.Add(model); }); var result = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogHelper.ErrorLoger.Error("OrderController_All:" + ex.Message); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public string ArticleComment() { ApiResult result = new ApiResult(); try { var pager = new Pager(); var id = ZNRequest.GetInt("NewId"); var ArticleNumber = ZNRequest.GetString("ArticleNumber"); if (string.IsNullOrWhiteSpace(ArticleNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var UserNumber = ZNRequest.GetString("UserNumber"); var query = new SubSonic.Query.Select(provider).From <Comment>().Where <Comment>(x => x.ArticleNumber == ArticleNumber && x.ParentCommentNumber == ""); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.result = true; result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } if (recordCount == 1 && id > 0) { result.result = true; result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } query = query.And("ID").IsNotEqualTo(id); var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var isNew = ZNRequest.GetInt("New"); var list = new List <Comment>(); if (isNew > 0) { list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Comment>(); } else { list = query.Paged(pager.Index, pager.Size).OrderAsc("ID").ExecuteTypedList <Comment>(); } var users = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Number").From <User>().Where("Number").In(list.Select(x => x.CreateUserNumber).Distinct().ToArray()).ExecuteTypedList <User>(); var parentComments = new SubSonic.Query.Select(provider, "ID", "ParentCommentNumber", "Number", "CreateUserNumber").From <Comment>().Where("ParentCommentNumber").In(list.Select(x => x.Number).ToArray()).ExecuteTypedList <Comment>(); var zans = db.Find <CommentZan>(x => x.CreateUserNumber == UserNumber).ToList(); List <CommentJson> newlist = new List <CommentJson>(); list.ForEach(x => { CommentJson model = new CommentJson(); var user = users.FirstOrDefault(y => y.Number == x.CreateUserNumber); if (user == null) { return; } model.ID = x.ID; model.Summary = x.Summary; model.Goods = x.Goods; model.Number = x.Number; model.CreateDateText = FormatTime(x.CreateDate); model.ShowPosition = x.ShowPosition; model.City = x.City; if (string.IsNullOrWhiteSpace(model.City)) { model.ShowPosition = 0; } model.UserID = user.ID; model.UserNumber = user.Number; model.NickName = user.NickName; model.Avatar = user.Avatar; model.SubCommentCount = parentComments.Count(y => y.ParentCommentNumber == x.Number); if (model.SubCommentCount == 1) { var subuser = db.Single <User>(y => y.Number == parentComments[0].CreateUserNumber); var comment = db.Single <Comment>(y => y.Number == parentComments[0].Number); if (subuser == null && comment == null) { model.SubCommentCount = 0; } if (subuser != null) { model.SubUserName = subuser.NickName; } if (comment != null) { model.SubSummary = comment.Summary; } } model.ArticleNumber = x.ArticleNumber; model.IsZan = zans.Count(y => y.CommentNumber == x.Number); newlist.Add(model); }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_ArticleComment_All:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string All() { ApiResult result = new ApiResult(); try { var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved); //昵称 var title = SqlFilter(ZNRequest.GetString("Title")); if (!string.IsNullOrWhiteSpace(title)) { query.And("Title").Like("%" + title + "%"); } var CreateUserNumber = ZNRequest.GetString("CreateUserNumber"); if (!string.IsNullOrWhiteSpace(CreateUserNumber)) { query = query.And("CreateUserNumber").IsEqualTo(CreateUserNumber); } //其他用户的文章 var CurrUserNumber = ZNRequest.GetString("CurrUserNumber"); if (CreateUserNumber != CurrUserNumber || string.IsNullOrWhiteSpace(CreateUserNumber)) { query = query.And("ArticlePower").IsEqualTo(Enum_ArticlePower.Public); query = query.And("Submission").IsGreaterThan(Enum_Submission.Audit); } //文章类型 var TypeID = ZNRequest.GetInt("TypeID"); if (TypeID > 0) { query = query.And("TypeIDList").Like("%-0-" + TypeID.ToString() + "-%"); } //过滤黑名单 if (!string.IsNullOrWhiteSpace(CurrUserNumber)) { var black = db.Find <Black>(x => x.CreateUserNumber == CurrUserNumber); if (black.Count > 0) { var userids = black.Select(x => x.ToUserNumber).ToArray(); query = query.And("CreateUserNumber").NotIn(userids); } } var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var sort = new string[] { "Recommend", "ID" }; if (CreateUserNumber == CurrUserNumber) { sort = new string[] { "ID" }; } var Source = ZNRequest.GetString("Source"); if (!string.IsNullOrWhiteSpace(Source)) { sort = new string[] { "Views" }; } var list = query.Paged(pager.Index, pager.Size).OrderDesc(sort).ExecuteTypedList <Article>(); List <ArticleJson> newlist = ArticleListInfo(list, CurrUserNumber); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Article_All:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Pic_1_3() { ApiResult result = new ApiResult(); try { var Number = ZNRequest.GetString("Number"); var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); //日期分组 var datequery = new SubSonic.Query.Select(provider, "ID", "CreateDate", "Status").From <ArticlePart>().Where <ArticlePart>(x => x.Types == Enum_ArticlePart.Pic && x.Status != Enum_Status.Delete && x.Status != Enum_Status.DeleteCompletely && x.CreateUserNumber == UserNumber); if (Number != UserNumber) { datequery = datequery.And("Status").IsEqualTo(Enum_Status.Approved); } var datelist = datequery.ExecuteTypedList <ArticlePart>(); var newdatelist = new List <DateTime>(); datelist.OrderByDescending(x => x.ID).GroupBy(x => x.CreateDate.ToString("yyyy-MM-dd")).ToList().ForEach(x => { newdatelist.Add(x.FirstOrDefault().CreateDate); }); var recordCount = newdatelist.Count(); if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; newdatelist = newdatelist.Skip((pager.Index - 1) * pager.Size).Take(pager.Size).ToList(); //获取数据 var query = new SubSonic.Query.Select(provider).From <ArticlePart>().Where <ArticlePart>(x => x.Types == Enum_ArticlePart.Pic && x.Status != Enum_Status.Delete && x.Status != Enum_Status.DeleteCompletely && x.CreateUserNumber == UserNumber); if (Number != UserNumber) { query = query.And("Status").IsEqualTo(Enum_Status.Approved); } query.And("CreateDate").IsGreaterThanOrEqualTo(newdatelist[newdatelist.Count - 1].ToString("yyyy-MM-dd 00:00:00")); query.And("CreateDate").IsLessThanOrEqualTo(newdatelist[0].ToString("yyyy-MM-dd 23:59:59")); var list = query.ExecuteTypedList <ArticlePart>(); var newlist = new List <PicJson>(); //组织输出 string[] Month = new string[] { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" }; string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; Console.WriteLine(); newdatelist.ForEach(x => { PicJson pic = new PicJson(); pic.Month = Month[x.Month - 1]; pic.Day = x.Day; pic.Week = Day[Convert.ToInt16(x.DayOfWeek)]; pic.CreateDate = x.ToString("yyyy年MM月dd日"); pic.List = list.FindAll(y => y.CreateDate.Year == x.Year && y.CreateDate.Month == x.Month && y.CreateDate.Day == x.Day); newlist.Add(pic); }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_User_Pic_1_3:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Article_1_3() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); var CurrUserNumber = ZNRequest.GetString("CurrUserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); //日期分组 var datequery = new SubSonic.Query.Select(provider, "ID", "CreateDate", "ArticlePower").From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved && x.CreateUserNumber == UserNumber); if (UserNumber != CurrUserNumber) { datequery = datequery.And("ArticlePower").IsEqualTo(Enum_ArticlePower.Public); datequery = datequery.And("Submission").IsGreaterThan(Enum_Submission.Audit); } var datelist = datequery.ExecuteTypedList <Article>(); var newdatelist = new List <DateTime>(); datelist.OrderByDescending(x => x.ID).GroupBy(x => x.CreateDate.ToString("yyyy-MM")).ToList().ForEach(x => { newdatelist.Add(x.FirstOrDefault().CreateDate); }); var recordCount = newdatelist.Count(); if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; newdatelist = newdatelist.Skip((pager.Index - 1) * pager.Size).Take(pager.Size).ToList(); //获取数据 var query = new SubSonic.Query.Select(provider, "ID", "Number", "CreateUserNumber", "Cover", "ArticlePower", "Status", "CreateDate").From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved && x.CreateUserNumber == UserNumber); if (UserNumber != CurrUserNumber) { query = query.And("ArticlePower").IsEqualTo(Enum_ArticlePower.Public); query = query.And("Submission").IsGreaterThan(Enum_Submission.Audit); } recordCount = query.GetRecordCount(); query.And("CreateDate").IsGreaterThanOrEqualTo(newdatelist[newdatelist.Count - 1].ToString("yyyy-MM-01 00:00:00")); var day = DateTime.DaysInMonth(newdatelist[0].Year, newdatelist[0].Month);; query.And("CreateDate").IsLessThanOrEqualTo(newdatelist[0].ToString("yyyy-MM-" + day + " 23:59:59")); var list = query.ExecuteTypedList <Article>(); var newlist = new List <UserArticleJson>(); //组织输出 newdatelist.ForEach(x => { UserArticleJson model = new UserArticleJson(); model.List = new List <UserArticleSubJson>(); var items = list.FindAll(y => y.CreateDate.Year == x.Year && y.CreateDate.Month == x.Month); items.ForEach(y => { UserArticleSubJson item = new UserArticleSubJson(); item.ID = y.ID; item.Number = y.Number; item.CreateUserNumber = y.CreateUserNumber; item.Cover = y.Cover; item.ArticlePower = y.ArticlePower; model.List.Add(item); }); model.CreateDate = x.Year + "年" + x.Month + "月"; model.Count = model.List.Count; newlist.Add(model); }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_User_Article_1_3:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Search() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); var nickname = ZNRequest.GetString("NickName"); var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <User>().Where <User>(x => x.Status == Enum_Status.Approved); if (!string.IsNullOrWhiteSpace(nickname)) { query.And("NickName").IsNotNull().And("NickName").Like("%" + nickname + "%"); } if (!string.IsNullOrWhiteSpace(UserNumber)) { var black = db.Find <Black>(x => x.CreateUserNumber == UserNumber); if (black.Count > 0) { var userids = black.Select(x => x.ToUserNumber).ToArray(); query = query.And("Number").NotIn(userids); } } var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.result = true; result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("LoginTimes").ExecuteTypedList <User>(); var follows = db.Find <Fan>(x => x.CreateUserNumber == UserNumber).ToList(); var newlist = (from l in list select new { ID = l.ID, NickName = l.NickName, Signature = l.Signature, Avatar = l.Avatar, Cover = l.Cover, Number = l.Number, IsFollow = follows.Exists(x => x.ToUserNumber == l.Number) ? 1 : 0 }).ToList(); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api/User/Search:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }