...
|
...
|
@@ -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
|
|
|
} |
...
|
...
|
|