-
Notifications
You must be signed in to change notification settings - Fork 0
/
media_censor.go
113 lines (98 loc) · 2.42 KB
/
media_censor.go
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
106
107
108
109
110
111
112
113
package model
import (
"github.com/mongodb/mongo-go-driver/bson"
"github.com/mongodb/mongo-go-driver/bson/primitive"
)
// Frame ...
type Frame struct {
URL string `json:"url,omitempty"`
Offset int64 `json:"offset"`
Rate float64 `json:"rate,omitempty"`
SfaceData []struct {
Faces []struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Rate float64 `json:"rate,omitempty"`
} `json:"faces,omitempty"`
H int `json:"h,omitempty"`
W int `json:"w,omitempty"`
X int `json:"x,omitempty"`
Y int `json:"y,omitempty"`
} `json:"sfaceData,omitempty"`
}
// Result ...
type Result struct {
Frames []Frame `json:"frames"`
Label string `json:"label"`
Rate float64 `json:"rate"`
Scene string `json:"scene"`
Suggestion string `json:"suggestion"`
}
// ResultData ...
type ResultData struct {
Code int `json:"code"`
Data []struct {
Code int `json:"code"`
DataID string `json:"dataId"`
Extras struct {
} `json:"extras"`
Msg string `json:"msg"`
Results []Result `json:"results"`
TaskID string `json:"taskId"`
URL string `json:"url"`
} `json:"data"`
Msg string `json:"msg"`
RequestID string `json:"requestId"`
}
// MediaCensor ...
type MediaCensor struct {
Model `bson:",inline"`
MediaID primitive.ObjectID `bson:"media_id"`
Verify string `bson:"verify"` //AI审核结果判断
Offset int64 `bson:"offset"`
RequestKey string `bson:"request_key"`
ResultData []*ResultData `bson:"result_data,omitempty"`
}
func (m *MediaCensor) _Name() string {
return "media_censor"
}
// CreateIfNotExist ...
func (m *MediaCensor) CreateIfNotExist() error {
return CreateIfNotExist(m)
}
// Create ...
func (m *MediaCensor) Create() error {
return InsertOne(m)
}
// Update ...
func (m *MediaCensor) Update() error {
return UpdateOne(m)
}
// Delete ...
func (m *MediaCensor) Delete() error {
return DeleteByID(m)
}
// Find ...
func (m *MediaCensor) Find() error {
return FindByID(m)
}
// FindByKey ...
func (m *MediaCensor) FindByKey() error {
return FindOne(m, bson.M{
"request_key": m.RequestKey,
})
}
// Media ...
func (m *MediaCensor) Media() (*Media, error) {
media := NewMedia()
media.ID = m.MediaID
err := media.Find()
return media, err
}
// NewMediaCensor ...
func NewMediaCensor() *MediaCensor {
return &MediaCensor{
Verify: "verification",
Model: model(),
}
}