public List <ClubItem> GetFolloweePost(string followerOpenId) { logger.Info($"GetFolloweePost -> followerOpenId:{followerOpenId}"); List <ClubItem> results = new List <ClubItem>(); var followDao = new FollowDao(ConfigurationManager.AppSettings["mysqlConnStr"]); var followees = followDao.GetFolloweesList(followerOpenId); var dao = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]); StringBuilder sb = new StringBuilder(); sb.Append(" and g.openid in (''"); followees.ForEach(followeeOpenId => { sb.Append($",'{followeeOpenId}'"); }); sb.Append(")"); var messages = dao.GetListExt(sb.ToString(), count: int.MaxValue, endId: int.MaxValue); if (messages != null) { messages.ForEach(msg => { List <string> pics = new List <string>(); if (!string.IsNullOrEmpty(msg.pic01)) { pics.Add(msg.pic01); } if (!string.IsNullOrEmpty(msg.pic02)) { pics.Add(msg.pic02); } if (!string.IsNullOrEmpty(msg.pic03)) { pics.Add(msg.pic03); } if (!string.IsNullOrEmpty(msg.pic04)) { pics.Add(msg.pic04); } if (!string.IsNullOrEmpty(msg.pic05)) { pics.Add(msg.pic05); } if (!string.IsNullOrEmpty(msg.pic06)) { pics.Add(msg.pic06); } List <string> audioes = new List <string>(); if (!string.IsNullOrEmpty(msg.audio01)) { audioes.Add(msg.audio01); } if (!string.IsNullOrEmpty(msg.audio02)) { audioes.Add(msg.audio02); } if (!string.IsNullOrEmpty(msg.audio03)) { audioes.Add(msg.audio03); } results.Add(new ClubItem() { postId = msg.id, openId = msg.openId, author = msg.author, authorHeadPic = msg.authorHeadPic, name = msg.name, poster = msg.poster, pics = pics, audioes = audioes, itemType = ClubItemType.Graphic, text = msg.text, likeCount = msg.likeCount, commentCount = msg.commentCount, createdAt = msg.createdAt }); }); } results = results.OrderByDescending(r => r.createdAt).ToList(); logger.Info($"GetFolloweePost -> return:{results.Count} items"); return(results); }
public List <PostsByDoctor> GetFolloweePostV2(string followerOpenId) { List <PostsByDoctor> result = new List <PostsByDoctor>(); var followDao = new FollowDao(ConfigurationManager.AppSettings["mysqlConnStr"]); var userDao = new UserDao(ConfigurationManager.AppSettings["mysqlConnStr"]); var dao = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]); var followees = followDao.GetFolloweesList(followerOpenId); followees.ForEach(followeeOpenId => { PostsByDoctor post = new PostsByDoctor(); var author = userDao.GetUser(followeeOpenId); post.author = author; StringBuilder sb = new StringBuilder(); sb.Append($" and g.openid='{followeeOpenId}' "); var messages = dao.GetListExt(sb.ToString(), count: 2, endId: int.MaxValue); //每个作者只取前两个作品 var clubItems = new List <ClubItem>(); if (messages != null) { messages.ForEach(msg => { List <string> pics = new List <string>(); if (!string.IsNullOrEmpty(msg.pic01)) { pics.Add(msg.pic01); } if (!string.IsNullOrEmpty(msg.pic02)) { pics.Add(msg.pic02); } if (!string.IsNullOrEmpty(msg.pic03)) { pics.Add(msg.pic03); } if (!string.IsNullOrEmpty(msg.pic04)) { pics.Add(msg.pic04); } if (!string.IsNullOrEmpty(msg.pic05)) { pics.Add(msg.pic05); } if (!string.IsNullOrEmpty(msg.pic06)) { pics.Add(msg.pic06); } List <string> audioes = new List <string>(); if (!string.IsNullOrEmpty(msg.audio01)) { audioes.Add(msg.audio01); } if (!string.IsNullOrEmpty(msg.audio02)) { audioes.Add(msg.audio02); } if (!string.IsNullOrEmpty(msg.audio03)) { audioes.Add(msg.audio03); } clubItems.Add(new ClubItem() { postId = msg.id, openId = msg.openId, author = msg.author, authorHeadPic = msg.authorHeadPic, name = msg.name, poster = msg.poster, pics = pics, audioes = audioes, itemType = ClubItemType.Graphic, text = msg.text, likeCount = msg.likeCount, commentCount = msg.commentCount, createdAt = msg.createdAt }); }); } post.posts = clubItems; result.Add(post); }); return(result); }