|
@@ -2,10 +2,13 @@ package message |
|
@@ -2,10 +2,13 @@ package message |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"context"
|
4
|
"context"
|
|
|
5
|
+ "fmt"
|
5
|
"github.com/zeromicro/go-zero/core/logx"
|
6
|
"github.com/zeromicro/go-zero/core/logx"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
9
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
11
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
|
9
|
)
|
12
|
)
|
10
|
|
13
|
|
11
|
type MiniSystemLogic struct {
|
14
|
type MiniSystemLogic struct {
|
|
@@ -23,8 +26,11 @@ func NewMiniSystemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSy |
|
@@ -23,8 +26,11 @@ func NewMiniSystemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSy |
23
|
}
|
26
|
}
|
24
|
|
27
|
|
25
|
func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *types.MessageSystemResponse, err error) {
|
28
|
func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *types.MessageSystemResponse, err error) {
|
26
|
- queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
|
|
|
27
|
- total, list, err := l.svcCtx.MessageSystemRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), queryOptions)
|
29
|
+ var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
|
|
|
30
|
+
|
|
|
31
|
+ total, list, err := l.svcCtx.MessageSystemRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions().
|
|
|
32
|
+ WithOffsetLimit(req.Page, req.Size).
|
|
|
33
|
+ WithKV("recipientId", userToken.UserId))
|
28
|
if err != nil {
|
34
|
if err != nil {
|
29
|
return nil, err
|
35
|
return nil, err
|
30
|
}
|
36
|
}
|
|
@@ -34,7 +40,7 @@ func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *typ |
|
@@ -34,7 +40,7 @@ func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *typ |
34
|
for _, item := range list {
|
40
|
for _, item := range list {
|
35
|
to := types.MessageSystemItem{
|
41
|
to := types.MessageSystemItem{
|
36
|
Id: item.Id,
|
42
|
Id: item.Id,
|
37
|
- Type: item.Type,
|
43
|
+ Type: int(item.Type),
|
38
|
Title: item.Title,
|
44
|
Title: item.Title,
|
39
|
Content: item.Content,
|
45
|
Content: item.Content,
|
40
|
CreatedAt: item.CreatedAt,
|
46
|
CreatedAt: item.CreatedAt,
|
|
@@ -44,15 +50,39 @@ func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *typ |
|
@@ -44,15 +50,39 @@ func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *typ |
44
|
return resp, nil
|
50
|
return resp, nil
|
45
|
}
|
51
|
}
|
46
|
|
52
|
|
47
|
-func (l *MiniSystemLogic) CreateMessage(dm *domain.MessageSystem) error {
|
|
|
48
|
- _, err := l.svcCtx.MessageSystemRepository.Insert(l.ctx, l.svcCtx.DefaultDBConn(), dm)
|
|
|
49
|
- l.Debugf("")
|
|
|
50
|
- return err
|
53
|
+// ArticleDefined 文章已定性
|
|
|
54
|
+func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at int64, item string) (err error) {
|
|
|
55
|
+ return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item))
|
|
|
56
|
+}
|
|
|
57
|
+
|
|
|
58
|
+// AbnormalArticleUnapproved 文章未审核通过
|
|
|
59
|
+func (l *MiniSystemLogic) AbnormalArticleUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
|
|
|
60
|
+ return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "发帖未通过审核", fmt.Sprintf("您的帖子[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
|
51
|
}
|
61
|
}
|
52
|
|
62
|
|
53
|
-//// CreateSystemMessage 生成一条信息
|
|
|
54
|
-//func CreateSystemMessage(ctx context.Context, svcCtx *svc.ServiceContext, dm *domain.MessageSystem) error {
|
|
|
55
|
-// l := NewMiniSystemLogic(ctx, svcCtx)
|
|
|
56
|
-// err := l.CreateMessage(dm)
|
|
|
57
|
-// return err
|
|
|
58
|
-//} |
63
|
+// AbnormalArticleHidden 文章被隐藏
|
|
|
64
|
+func (l *MiniSystemLogic) AbnormalArticleHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
|
|
|
65
|
+ return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "帖子被隐藏", fmt.Sprintf("您的帖子[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
|
|
|
66
|
+}
|
|
|
67
|
+
|
|
|
68
|
+// AbnormalCommentUnapproved 评论未审核通过
|
|
|
69
|
+func (l *MiniSystemLogic) AbnormalCommentUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
|
|
|
70
|
+ return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论未通过审核", fmt.Sprintf("您的评论[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
|
|
|
71
|
+}
|
|
|
72
|
+
|
|
|
73
|
+// AbnormalCommentHidden 评论被隐藏
|
|
|
74
|
+func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
|
|
|
75
|
+ return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
|
|
|
76
|
+}
|
|
|
77
|
+
|
|
|
78
|
+func (l *MiniSystemLogic) createMessage(conn transaction.Conn, companyId, at int64, msgType domain.MsgSystemType, title string, content string) (err error) {
|
|
|
79
|
+ var msg = &domain.MessageSystem{
|
|
|
80
|
+ Type: msgType,
|
|
|
81
|
+ CompanyId: companyId,
|
|
|
82
|
+ RecipientId: at,
|
|
|
83
|
+ Title: title,
|
|
|
84
|
+ Content: content,
|
|
|
85
|
+ }
|
|
|
86
|
+ msg, err = l.svcCtx.MessageSystemRepository.Insert(l.ctx, conn, msg)
|
|
|
87
|
+ return err
|
|
|
88
|
+} |