作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -42,25 +42,8 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
return nil, xerr.NewErrMsg("没有查看权限")
}
// 检查文章的可查看人
if articleInfo.AuthorId != int64(req.UserId) {
if len(articleInfo.WhoRead) > 0 {
inWhoRead := false
for _, val := range articleInfo.WhoRead {
if req.UserId == int(val) {
inWhoRead = true
}
}
if !inWhoRead {
// 文章内容不显示
// resp = &types.MiniArticleGetResponse{
// Id: articleInfo.Id,
// Title: articleInfo.Title,
// Show: int(domain.ArticleShowDisable),
// }
// return resp, nil
return nil, xerr.NewErrMsg("没有查看权限")
}
}
if ok := articleInfo.WhoCanRead(int64(req.UserId)); !ok {
return nil, xerr.NewErrMsg("没有查看权限")
}
if articleInfo.Show == domain.ArticleShowDisable {
// 文章内容不显示
... ...
... ... @@ -52,11 +52,8 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
return nil, xerr.NewErrMsg("没有评论权限")
}
//查看评论权限,
if len(articleInfo.WhoReview) > 0 {
ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
if ok < 0 {
return nil, xerr.NewErrMsg("没有评论权限")
}
if ok := articleInfo.WhoCanReview(req.FromUserId); ok {
return nil, xerr.NewErrMsg("没有评论权限")
}
// 对段落进行评论
var selctionInfo *domain.ArticleSection
... ...
... ... @@ -123,6 +123,9 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
}
func (m *Article) WhoCanRead(userId int64) bool {
if m.AuthorId == userId {
return true
}
if len(m.WhoRead) == 0 {
return true
}
... ... @@ -135,6 +138,9 @@ func (m *Article) WhoCanRead(userId int64) bool {
}
func (m *Article) WhoCanReview(userId int64) bool {
if m.AuthorId == userId {
return true
}
if len(m.WhoReview) == 0 {
return true
}
... ...