public ReturnResult <PageList <ArticleContentDataContract> > GetArticleContentList(int categoryId, long userKeyId = 0, bool?isverify = true, int page = 1, int pageSize = 10) { int rootCategoryId = articleCategoryService.GetRootCategoryId(categoryId); if (rootCategoryId == -1) { return(new ReturnResult <PageList <ArticleContentDataContract> >(101, null, "分类ID错误")); } if (rootCategoryId == categoryId) { categoryId = 0; } var list = ArticleContentRepository.Instance.GetArticleContentList(rootCategoryId, categoryId, userKeyId, isverify, page, pageSize); if (list.DataList.Any()) { var userList = memberService.GetMember(list.DataList.Select(t => t.UserKeyId)).ToDictionary(c => c.UserKeyId, c => c); list.DataList.ForEach(t => { if (userList.ContainsKey(t.UserKeyId)) { t.FaceImg = userList[t.UserKeyId].FaceImg; } }); } return(new ReturnResult <PageList <ArticleContentDataContract> >(list)); }
public ReturnResult <PageList <ArticleAttentionDataContract> > GetArticleAttention(long userKeyId, int page, int pageSize) { if (page < 1) { page = 1; } var list = ArticleAttentionRepository.Instance.GetArticleAttention(userKeyId, page, pageSize); if (list.DataList.Any()) { var userList = memberService.GetMember(list.DataList.Select(t => t.AttentionUserKeyId)).ToDictionary(c => c.UserKeyId, c => c); list.DataList.ForEach(t => { if (userList.ContainsKey(t.AttentionUserKeyId)) { t.AttentionUserFaceImg = userList[t.AttentionUserKeyId].FaceImg; t.AttentionUserKeyName = userList[t.AttentionUserKeyId].NickName ?? userList[t.AttentionUserKeyId].UserName; } }); } return(new ReturnResult <PageList <ArticleAttentionDataContract> >(list)); }
public ReturnResult <OauthToken> RefreshAccessToken(string refreshToken, int clientId) { if (string.IsNullOrWhiteSpace(refreshToken)) { return(new ReturnResult <OauthToken>(21, null, "参数refreshToken错误")); } var rToken = TokenRepository.Instance.GetRefreshToken(refreshToken); if (null == rToken) { return(new ReturnResult <OauthToken>(22, null, "参数refreshToken错误")); } if (rToken.ClientID != clientId) { return(new ReturnResult <OauthToken>(23, null, "参数clientId错误")); } if (rToken.Expires < DateTime.Now.Epoch()) { return(new ReturnResult <OauthToken>(24, null, "refreshToken已过期,请重新登录")); } var user = memberService.GetMember(rToken.UserKeyID); if (null == user) { return(new ReturnResult <OauthToken>(25, null, "当前用户已失效,请重新登录")); } return(this.CreateAccessToken(user)); }
/// <summary> /// 获取我收藏的帖子 /// </summary> public PageList <ArticleCollectDataContract> GetArticleCollect(long userKeyId, int page, int pageSize) { var list = ArticleCollectRepository.Instance.GetArticleCollect(userKeyId, page, pageSize); if (list.DataList.Any()) { var userList = memberService.GetMember(list.DataList.Select(t => t.AuthorUserKeyId)).ToDictionary(c => c.UserKeyId, c => c); foreach (var item in list.DataList) { if (userList.ContainsKey(item.AuthorUserKeyId)) { item.FaceImg = userList[item.AuthorUserKeyId].FaceImg; item.Author = userList[item.AuthorUserKeyId].NickName ?? userList[item.AuthorUserKeyId].UserName; } } } return(list); }
public ReturnResult <PageList <ArticleCommentDataContract> > GetArticleCommentList(long articleID, int page = 1, int pageSize = 10) { if (page < 1) { page = 1; } var list = ArticleCommentRepository.Instance.GetArticleCommentList(articleID, page, pageSize); if (list.DataList.Any()) { var userList = memberService.GetMember(list.DataList.Select(t => t.UserKeyId)).ToDictionary(c => c.UserKeyId, c => c); foreach (var item in list.DataList) { if (userList.ContainsKey(item.UserKeyId)) { item.FaceImg = userList[item.UserKeyId].FaceImg; item.NickName = userList[item.UserKeyId].NickName ?? userList[item.UserKeyId].UserName; } } } return(new ReturnResult <PageList <ArticleCommentDataContract> >(list)); }