article_security_search_logic.go
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package secuirty
import (
"context"
"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/domain"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type ArticleSecuritySearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewArticleSecuritySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleSecuritySearchLogic {
return &ArticleSecuritySearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ArticleSecuritySearchLogic) ArticleSecuritySearch(req *types.ArticleSecuritySearchRequest) (resp *types.ArticleSecuritySearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleSecurity
total int64
)
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
WithKV("reviewStatus", req.ReviewStatus).
WithKV("suggest", req.Suggest).
WithKV("contentType", req.ContentType).
WithKV("authorName", req.AuthorName).
WithKV("beginTime", req.BeginTime).
WithKV("endTime", req.EndTime)
total, dms, err = l.svcCtx.ArticleSecurityRepository.Find(l.ctx, conn, queryOptions)
list := make([]types.ArticleSecurityItem, 0)
for i := range dms {
list = append(list, NewTypesArticleSecurity(dms[i], nil))
}
resp = &types.ArticleSecuritySearchResponse{
List: list,
Total: total,
}
return
}
func NewDomainArticleSecurity(item types.ArticleSecurityItem) *domain.ArticleSecurity {
return &domain.ArticleSecurity{}
}
func NewTypesArticleSecurity(item *domain.ArticleSecurity, reviewer *domain.User) types.ArticleSecurityItem {
result := types.ArticleSecurityItem{
Id: item.Id,
ContentKeyWords: strings.Join(item.ContentKeyWords, ","),
Label: item.Label,
Prob: item.Prob,
Suggest: describeSuggest(item.Suggest),
Author: item.AuthorName,
ReviewAt: item.CreatedAt,
ReviewStatus: item.ReviewStatus,
Reviewer: "",
}
if reviewer != nil {
result.Reviewer = reviewer.Name
}
for _, detail := range item.Detail.Detail {
result.CheckList = append(result.CheckList, types.CheckDetailItem{
Label: detail.Label.String(),
Prob: detail.Prob,
Suggest: describeSuggest(detail.Suggest),
})
}
return result
}
func describeContentType(t int) string {
if t == domain.TypeArticle {
return "文本-帖子"
}
if t == domain.TypeComment {
return "文本-评论"
}
return ""
}
func describeSuggest(s string) string {
if s == "risk" {
return "风险"
}
if s == "pass" {
return "通过"
}
if s == "review" {
return "人工审核"
}
return ""
}