...
|
...
|
@@ -50,8 +50,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
var userIdMap = map[int64]*domain.User{}
|
|
|
var articleIdMap = map[int64]*domain.Article{}
|
|
|
var commentIdMap = map[int64]*domain.ArticleComment{}
|
|
|
//var discussionIdMap = map[int64]int{}
|
|
|
//var discussionOpinionIdMap = map[int64]int{}
|
|
|
|
|
|
for _, item := range list {
|
|
|
if item.CompanyId != 0 {
|
|
|
companyIdMap[item.CompanyId] = nil
|
...
|
...
|
@@ -65,19 +64,15 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
if item.CommentId != 0 {
|
|
|
commentIdMap[item.CommentId] = nil
|
|
|
}
|
|
|
//if item.DiscussionId != 0 {
|
|
|
// discussionIdMap[item.DiscussionId] = 0
|
|
|
//}
|
|
|
//if item.DiscussionOpinionId != 0 {
|
|
|
// discussionOpinionIdMap[item.DiscussionOpinionId] = 0
|
|
|
//}
|
|
|
if item.CommentParentId != 0 {
|
|
|
commentIdMap[item.CommentParentId] = nil
|
|
|
}
|
|
|
}
|
|
|
var companyIds = make([]int64, 0) // 公司ID
|
|
|
var userIds = make([]int64, 0) // 用户ID
|
|
|
var articleIds = make([]int64, 0) // 文章ID
|
|
|
var commentIds = make([]int64, 0) // 评论ID
|
|
|
//var discussionIds = make([]int64, 0) // 讨论ID 暂时搁置
|
|
|
//var discussionOpinionIds = make([]int64, 0) // 观点ID
|
|
|
var commentIds = make([]int64, 0) // 评论ID(包含回复的评论)
|
|
|
|
|
|
for k, _ := range companyIdMap {
|
|
|
companyIds = append(companyIds, k)
|
|
|
}
|
...
|
...
|
@@ -90,12 +85,6 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
for k, _ := range commentIdMap {
|
|
|
commentIds = append(commentIds, k)
|
|
|
}
|
|
|
//for k, _ := range discussionIdMap {
|
|
|
// discussionIds = append(discussionIds, k)
|
|
|
//}
|
|
|
//for k, _ := range discussionOpinionIdMap {
|
|
|
// discussionOpinionIds = append(discussionOpinionIds, k)
|
|
|
//}
|
|
|
|
|
|
// 获取公司
|
|
|
if len(companyIds) > 0 {
|
...
|
...
|
@@ -166,13 +155,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
UserId: item.UserId,
|
|
|
RecipientId: item.RecipientId,
|
|
|
ArticleId: item.ArticleId,
|
|
|
CommentId: item.CommentId,
|
|
|
//DiscussionId: item.DiscussionId,
|
|
|
//DiscussionOpinionId: item.DiscussionOpinionId,
|
|
|
Content: item.Content,
|
|
|
CreatedAt: item.CreatedAt,
|
|
|
CreatedAt: item.CreatedAt,
|
|
|
}
|
|
|
|
|
|
// 发布者
|
|
|
if v, ok := userIdMap[item.UserId]; ok && v != nil {
|
|
|
to.User = &types.SimpleUser{
|
|
|
Id: v.Id,
|
...
|
...
|
@@ -187,6 +173,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 文章
|
|
|
if v, ok := articleIdMap[item.ArticleId]; ok && v != nil {
|
|
|
to.Article = &types.SimpleArticle{
|
|
|
Id: v.Id,
|
...
|
...
|
@@ -197,13 +184,41 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 评论
|
|
|
if v, ok := commentIdMap[item.CommentId]; ok && v != nil {
|
|
|
to.Comment = &types.SimpleComment{
|
|
|
Id: v.Id,
|
|
|
Content: v.Content,
|
|
|
CountLove: v.CountUserLove,
|
|
|
CountComment: v.CountReply,
|
|
|
Show: int(v.Show),
|
|
|
Id: v.Id,
|
|
|
Content: v.Content,
|
|
|
Show: int(v.Show),
|
|
|
CountReply: v.CountReply,
|
|
|
CountUserLove: v.CountUserLove,
|
|
|
MatchUrl: v.MatchUrl,
|
|
|
}
|
|
|
to.Comment.AtWho = make([]types.CommentAtWho, 0)
|
|
|
for _, who := range v.AtWho {
|
|
|
to.Comment.AtWho = append(to.Comment.AtWho, types.CommentAtWho{
|
|
|
Id: who.Id,
|
|
|
Name: who.Name,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 被回复的评论
|
|
|
if v, ok := commentIdMap[item.CommentParentId]; ok && v != nil {
|
|
|
to.CommentParent = &types.SimpleComment{
|
|
|
Id: v.Id,
|
|
|
Content: v.Content,
|
|
|
Show: int(v.Show),
|
|
|
CountReply: v.CountReply,
|
|
|
CountUserLove: v.CountUserLove,
|
|
|
MatchUrl: v.MatchUrl,
|
|
|
}
|
|
|
to.CommentParent.AtWho = make([]types.CommentAtWho, 0)
|
|
|
for _, who := range v.AtWho {
|
|
|
to.CommentParent.AtWho = append(to.CommentParent.AtWho, types.CommentAtWho{
|
|
|
Id: who.Id,
|
|
|
Name: who.Name,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -213,23 +228,23 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma |
|
|
}
|
|
|
|
|
|
// CommentArticle 评论文章
|
|
|
func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, sectionId int64, content string, at []int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, sectionId, 0, content, at)
|
|
|
func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, commentId int64, at []int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, commentId, 0, at)
|
|
|
}
|
|
|
|
|
|
// CommentReply 评论回复
|
|
|
func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, sectionId int64, commentId int64, content string, at []int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, sectionId, commentId, content, at)
|
|
|
func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, commentId int64, commentParentId int64, at []int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, commentId, commentParentId, at)
|
|
|
}
|
|
|
|
|
|
// LikeArticle 点赞文章
|
|
|
func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, 0, "", []int64{at})
|
|
|
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, 0, []int64{at})
|
|
|
}
|
|
|
|
|
|
// LikeComment 点赞评论
|
|
|
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, 0, commentId, "", []int64{at})
|
|
|
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, commentParentId int64, at int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, commentParentId, []int64{at})
|
|
|
}
|
|
|
|
|
|
// UnLikeArticle 取消点赞文章
|
...
|
...
|
@@ -247,24 +262,22 @@ func (l *MiniBusinessLogic) createMessage( |
|
|
msgType domain.MsgBusinessType,
|
|
|
optType domain.MsgBusinessOpt,
|
|
|
articleId int64,
|
|
|
sectionId int64,
|
|
|
commentId int64,
|
|
|
content string,
|
|
|
commentParentId int64,
|
|
|
at []int64) (err error) {
|
|
|
|
|
|
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
|
|
|
// 评论中携带了 @其他用户
|
|
|
for i := range at {
|
|
|
var msg = &domain.MessageBusiness{
|
|
|
Type: msgType,
|
|
|
OptType: optType,
|
|
|
CompanyId: userToken.CompanyId,
|
|
|
UserId: userToken.UserId,
|
|
|
RecipientId: at[i],
|
|
|
ArticleId: articleId,
|
|
|
SectionId: sectionId,
|
|
|
CommentId: commentId,
|
|
|
Content: content,
|
|
|
Type: msgType,
|
|
|
OptType: optType,
|
|
|
CompanyId: userToken.CompanyId,
|
|
|
UserId: userToken.UserId,
|
|
|
RecipientId: at[i],
|
|
|
ArticleId: articleId,
|
|
|
CommentId: commentId,
|
|
|
CommentParentId: commentParentId,
|
|
|
}
|
|
|
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
|
|
|
if err != nil {
|
...
|
...
|
|