作者 yangfu
... ... @@ -52,19 +52,20 @@ type (
MessageBusinessItem {
Id int64 `json:"id"`
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
OptType int `json:"optType"` // 操作类型(1针对文章或段落、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收者ID
ArticleId int64 `json:"articleId"` // 文章ID
CommentId int64 `json:"commentId"` // 评论ID
DiscussionId int64 `json:"discussionId"` // 圆桌ID
DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
Content string `json:"content"` // 消息内容
// CommentId int64 `json:"commentId"` // 评论ID
// DiscussionId int64 `json:"discussionId"` // 圆桌ID
// DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
// Content string `json:"content"` // 消息内容
CreatedAt int64 `json:"createdAt"` // 创建时间
User *SimpleUser `json:"user"` // 操作人
Article *SimpleArticle `json:"article"` // 文章
Comment *SimpleComment `json:"comment"` // 评论(不一定是自己,可能是被人@到)
Comment *SimpleComment `json:"comment"` // 评论
CommentParent *SimpleComment `json:"commentParent"` // 被回复的评论
}
SimpleUser {
... ...
... ... @@ -258,16 +258,15 @@ type (
}
SimpleComment {
Id int64 `json:"id"`
Content string `json:"content"` // 评论内容
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
AtWho []SimpleUser `json:"atWho"` // @用户
MatchUrl map[string]string `json:"matchUrl"` // 内容中的url文本
Id int64 `json:"id"`
Content string `json:"content"` // 评论内容
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
CountReply int `json:"countReply"` // 用户回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
}
MiniBeLikedRequest{
Page int `json:"page"`
Size int `json:"size"`
... ...
... ... @@ -357,7 +357,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
// 创建点赞消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.LikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId)
err = messageLogic.LikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.Pid, commentInfo.FromUserId)
if err != nil {
return err
}
... ...
... ... @@ -205,9 +205,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
atAllIds = append(atAllIds, atWhoIds...)
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
if pComment != nil {
err = messageLogic.CommentReply(c, pComment.ArticleId, pComment.SectionId, pComment.Id, req.Content, atAllIds) // 对评论回复
err = messageLogic.CommentReply(c, req.ArtitcleId, newComment.Id, pComment.Id, atAllIds) // 对评论回复
} else {
err = messageLogic.CommentArticle(c, req.ArtitcleId, req.SectionId, req.Content, atAllIds) // 对文章回复
err = messageLogic.CommentArticle(c, req.ArtitcleId, newComment.Id, atAllIds) // 对文章回复
}
if err != nil {
return err
... ...
... ... @@ -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,20 +184,40 @@ 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),
MatchUrl: v.MatchUrl,
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.Comment.AtWho = make([]types.SimpleUser, 0)
for _, at := range v.AtWho {
to.Comment.AtWho = append(to.Comment.AtWho, types.SimpleUser{
Id: at.Id,
Name: at.Name,
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,
})
}
}
... ... @@ -221,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 取消点赞文章
... ... @@ -255,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 {
... ...
... ... @@ -107,11 +107,19 @@ func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, company *d
if comment != nil {
item.Comment = &types.SimpleComment{
Id: comment.Id,
Content: comment.Content,
CountLove: comment.CountUserLove,
CountComment: comment.CountReply,
Show: int(comment.Show),
Id: comment.Id,
Content: comment.Content,
Show: int(comment.Show),
CountReply: comment.CountReply,
CountUserLove: comment.CountUserLove,
MatchUrl: comment.MatchUrl,
}
item.Comment.AtWho = make([]types.CommentAtWho, 0)
for _, who := range comment.AtWho {
item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{
Id: who.Id,
Name: who.Name,
})
}
}
... ...
... ... @@ -107,11 +107,19 @@ func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, company *doma
if comment != nil {
item.Comment = &types.SimpleComment{
Id: comment.Id,
Content: comment.Content,
CountLove: comment.CountUserLove,
CountComment: comment.CountReply,
Show: int(comment.Show),
Id: comment.Id,
Content: comment.Content,
Show: int(comment.Show),
CountReply: comment.CountReply,
CountUserLove: comment.CountUserLove,
MatchUrl: comment.MatchUrl,
}
item.Comment.AtWho = make([]types.CommentAtWho, 0)
for _, who := range comment.AtWho {
item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{
Id: who.Id,
Name: who.Name,
})
}
}
... ...
... ... @@ -10,6 +10,7 @@ type CommonSmsCodeResposne struct {
type MiniQrCodeRequest struct {
Page string `json:"page"` // 微信页面入口
Path string `json:"path"` //
Scene string `json:"scene"` // 参数
}
... ... @@ -286,21 +287,18 @@ type MessageBusinessResponse struct {
}
type MessageBusinessItem struct {
Id int64 `json:"id"`
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收者ID
ArticleId int64 `json:"articleId"` // 文章ID
CommentId int64 `json:"commentId"` // 评论ID
DiscussionId int64 `json:"discussionId"` // 圆桌ID
DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
Content string `json:"content"` // 消息内容
CreatedAt int64 `json:"createdAt"` // 创建时间
User *SimpleUser `json:"user"` // 操作人
Article *SimpleArticle `json:"article"` // 文章
Comment *SimpleComment `json:"comment"` // 评论(不一定是自己,可能是被人@到)
Id int64 `json:"id"`
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章或段落、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收者ID
ArticleId int64 `json:"articleId"` // 文章ID
CreatedAt int64 `json:"createdAt"` // 创建时间
User *SimpleUser `json:"user"` // 操作人
Article *SimpleArticle `json:"article"` // 文章
Comment *SimpleComment `json:"comment"` // 评论
CommentParent *SimpleComment `json:"commentParent"` // 被回复的评论
}
type SimpleUser struct {
... ... @@ -601,13 +599,13 @@ type MyLikeItem struct {
}
type SimpleComment struct {
Id int64 `json:"id"`
Content string `json:"content"` // 评论内容
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
AtWho []SimpleUser `json:"atWho"` // @用户
MatchUrl map[string]string `json:"matchUrl"` // 内容中的url文本
Id int64 `json:"id"`
Content string `json:"content"` // 评论内容
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本
CountReply int `json:"countReply"` // 用户回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
}
type MiniBeLikedRequest struct {
... ...
... ... @@ -10,21 +10,20 @@ import (
// MessageBusiness 消息中心业务
type MessageBusiness struct {
Id int64 // 唯一标识
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收人用户ID
ArticleId int64 `json:"articleId,omitempty"` // 文章ID
SectionId int64 `json:"sectionId,omitempty"` // 段落ID
CommentId int64 `json:"commentId,omitempty"` // 评论ID
Content string `json:"content,omitempty"` // 消息内容
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Id int64 // 唯一标识
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收人用户ID
ArticleId int64 `json:"articleId"` // 文章ID
CommentId int64 `json:"commentId"` // 评论来源ID
CommentParentId int64 `json:"commentParentId"` // 评论上级ID
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
//DiscussionId int64 `json:"discussionId,omitempty"` // 圆桌ID
//DiscussionOpinionId int64 `json:"discussionOpinionId,omitempty"` // 观点ID
}
... ...
... ... @@ -6,21 +6,22 @@ import (
)
type MessageBusiness struct {
Id int64 // 唯一标识
Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收人用户ID
ArticleId int64 `json:"articleId"` // 文章ID
SectionId int64 `json:"sectionId"` // 段落ID
CommentId int64 `json:"commentId"` // 评论ID
Content string `json:"content"` // 消息内容
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
Id int64 // 唯一标识
Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章或段落、2针对评论、3针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收人用户ID
ArticleId int64 `json:"articleId"` // 文章ID
CommentId int64 `json:"commentId"` // 评论来源ID
CommentParentId int64 `json:"commentParentId"` // 评论上级ID
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
//SectionId int64 `json:"sectionId"` // 段落ID
//Content string `json:"content"` // 消息内容
//DiscussionId int64 `json:"discussionId"` // 圆桌ID
//DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
}
... ...
... ... @@ -15,8 +15,8 @@ type UserLoveFlag struct {
CommentId int64 `json:"commentId"` // 点赞评论时,填评论id
CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人
ToUserId int64 `json:"toUserId"` // 点赞的接受人
UserId int64 `json:"userId"` // 点赞的人
CompanyId int64 `json:"companyId"` //
UserId int64 `json:"userId"` // 点赞人
CompanyId int64 `json:"companyId"` // 点赞人的公司
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
... ...