作者 郑周

1. 消息列表 系统消息 增加逻辑

... ... @@ -207,25 +207,25 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res
// 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)
return l.createMessage(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)
return l.createMessage(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})
return l.createMessage(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})
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, "", []int64{at})
}
func (l *MiniBusinessLogic) submit(
func (l *MiniBusinessLogic) createMessage(
conn transaction.Conn,
msgType domain.MsgBusinessType,
optType domain.MsgBusinessOpt,
... ...
... ... @@ -2,10 +2,13 @@ package message
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"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"
)
type MiniSystemLogic struct {
... ... @@ -23,8 +26,11 @@ func NewMiniSystemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSy
}
func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *types.MessageSystemResponse, err error) {
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
total, list, err := l.svcCtx.MessageSystemRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), queryOptions)
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
total, list, err := l.svcCtx.MessageSystemRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("recipientId", userToken.UserId))
if err != nil {
return nil, err
}
... ... @@ -34,7 +40,7 @@ func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *typ
for _, item := range list {
to := types.MessageSystemItem{
Id: item.Id,
Type: item.Type,
Type: int(item.Type),
Title: item.Title,
Content: item.Content,
CreatedAt: item.CreatedAt,
... ... @@ -44,15 +50,39 @@ func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *typ
return resp, nil
}
func (l *MiniSystemLogic) CreateMessage(dm *domain.MessageSystem) error {
_, err := l.svcCtx.MessageSystemRepository.Insert(l.ctx, l.svcCtx.DefaultDBConn(), dm)
l.Debugf("")
return err
// ArticleDefined 文章已定性
func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalArticleUnapproved 文章未审核通过
func (l *MiniSystemLogic) AbnormalArticleUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "发帖未通过审核", fmt.Sprintf("您的帖子[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
}
//// CreateSystemMessage 生成一条信息
//func CreateSystemMessage(ctx context.Context, svcCtx *svc.ServiceContext, dm *domain.MessageSystem) error {
// l := NewMiniSystemLogic(ctx, svcCtx)
// err := l.CreateMessage(dm)
// return err
//}
// AbnormalArticleHidden 文章被隐藏
func (l *MiniSystemLogic) AbnormalArticleHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "帖子被隐藏", fmt.Sprintf("您的帖子[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalCommentUnapproved 评论未审核通过
func (l *MiniSystemLogic) AbnormalCommentUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论未通过审核", fmt.Sprintf("您的评论[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalCommentHidden 评论被隐藏
func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
}
func (l *MiniSystemLogic) createMessage(conn transaction.Conn, companyId, at int64, msgType domain.MsgSystemType, title string, content string) (err error) {
var msg = &domain.MessageSystem{
Type: msgType,
CompanyId: companyId,
RecipientId: at,
Title: title,
Content: content,
}
msg, err = l.svcCtx.MessageSystemRepository.Insert(l.ctx, conn, msg)
return err
}
... ...
... ... @@ -6,16 +6,16 @@ import (
)
type MessageSystem struct {
Id int64 // 唯一标识
CompanyId int64 `json:"companyId"` // 公司ID
RecipientId int64 `json:"recipientId"` // 接收者ID
Type int `json:"type"` // 系统分类(0待定、1业务正常通知、2业务异常通知)
Title string `json:"title"` // 标题
Content string `json:"content"` // 内容
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
Id int64 // 唯一标识
CompanyId int64 `json:"companyId"` // 公司ID
RecipientId int64 `json:"recipientId"` // 接收者ID
Type MsgSystemType `json:"type"` // 系统分类(0待定、1业务正常通知、2业务异常通知)
Title string `json:"title"` // 标题
Content string `json:"content"` // 内容
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
}
type MsgSystemType int
... ...