...
|
...
|
@@ -2,10 +2,11 @@ package message |
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
...
|
...
|
@@ -137,29 +138,26 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 只有这个才需要
|
|
|
if msgType == int(domain.MsgTypeReply) || msgType == int(domain.MsgTypeLike) {
|
|
|
// 获取文章数据
|
|
|
if len(articleIds) > 0 {
|
|
|
_, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
|
|
|
domain.NewQueryOptions().
|
|
|
WithFindOnly().
|
|
|
WithKV("ids", articleIds).
|
|
|
WithKV("limit", len(articleIds)))
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
for i := range articleList {
|
|
|
articleIdMap[articleList[i].Id] = articleList[i]
|
|
|
}
|
|
|
// 获取文章数据
|
|
|
if len(articleIds) > 0 {
|
|
|
_, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
|
|
|
domain.NewQueryOptions().
|
|
|
WithFindOnly().
|
|
|
WithKV("ids", articleIds).
|
|
|
WithKV("limit", len(articleIds)))
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
for i := range articleList {
|
|
|
articleIdMap[articleList[i].Id] = articleList[i]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for _, item := range list {
|
|
|
to := types.MessageBusinessItem{
|
|
|
Id: item.Id,
|
|
|
Type: item.Type,
|
|
|
OptType: item.OptType,
|
|
|
Type: int(item.Type),
|
|
|
OptType: int(item.OptType),
|
|
|
CompanyId: item.CompanyId,
|
|
|
UserId: item.UserId,
|
|
|
RecipientId: item.RecipientId,
|
...
|
...
|
@@ -177,6 +175,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
|
CompanyId: v.CompanyId,
|
|
|
Position: v.Position,
|
|
|
Name: v.Name,
|
|
|
Avatar: v.Avatar,
|
|
|
}
|
|
|
|
|
|
if v, ok := companyIdMap[item.CompanyId]; ok {
|
...
|
...
|
@@ -206,3 +205,53 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
|
}
|
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
// CommentArticle 评论文章
|
|
|
func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, content string, at []int64) (err error) {
|
|
|
return l.submit(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, 0, content, at)
|
|
|
}
|
|
|
|
|
|
// CommentReply 评论回复
|
|
|
func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, commentId int64, content string, at []int64) (err error) {
|
|
|
return l.submit(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, commentId, content, at)
|
|
|
}
|
|
|
|
|
|
// LikeArticle 点赞文章
|
|
|
func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) {
|
|
|
return l.submit(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, "", []int64{at})
|
|
|
}
|
|
|
|
|
|
// LikeComment 点赞评论
|
|
|
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) {
|
|
|
return l.submit(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, "", []int64{at})
|
|
|
}
|
|
|
|
|
|
func (l *MiniBusinessLogic) submit(
|
|
|
conn transaction.Conn,
|
|
|
msgType domain.MsgBusinessType,
|
|
|
optType domain.MsgBusinessOpt,
|
|
|
articleId int64,
|
|
|
commentId int64,
|
|
|
content string,
|
|
|
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,
|
|
|
CommentId: commentId,
|
|
|
Content: content,
|
|
|
}
|
|
|
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|