This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch feat/1.4.0/badge
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
The following commit(s) were added to refs/heads/feat/1.4.0/badge by this push:
new 290f63f2 feat(badge): add comment for event schema
290f63f2 is described below
commit 290f63f2a14a542803e7190ccf0153324c1f1a77
Author: LinkinStars <[email protected]>
AuthorDate: Tue Aug 13 10:40:55 2024 +0800
feat(badge): add comment for event schema
---
internal/schema/event_schema.go | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/internal/schema/event_schema.go b/internal/schema/event_schema.go
index fd8e06dd..a507f269 100644
--- a/internal/schema/event_schema.go
+++ b/internal/schema/event_schema.go
@@ -38,6 +38,7 @@ type EventMsg struct {
ExtraInfo map[string]string
}
+// NewEvent create a new event
func NewEvent(e constant.EventType, userID string) *EventMsg {
return &EventMsg{
UserID: userID,
@@ -46,29 +47,34 @@ func NewEvent(e constant.EventType, userID string)
*EventMsg {
}
}
+// QID get question id
func (e *EventMsg) QID(questionID, userID string) *EventMsg {
e.QuestionID = questionID
e.QuestionUserID = userID
return e
}
+// AID get answer id
func (e *EventMsg) AID(answerID, userID string) *EventMsg {
e.AnswerID = answerID
e.AnswerUserID = userID
return e
}
+// CID get comment id
func (e *EventMsg) CID(comment, userID string) *EventMsg {
e.CommentID = comment
e.CommentUserID = userID
return e
}
+// AddExtra add extra info
func (e *EventMsg) AddExtra(key, value string) *EventMsg {
e.ExtraInfo[key] = value
return e
}
+// GetExtra get extra info
func (e *EventMsg) GetExtra(key string) string {
if v, ok := e.ExtraInfo[key]; ok {
return v
@@ -76,6 +82,7 @@ func (e *EventMsg) GetExtra(key string) string {
return ""
}
+// GetObjectID get object id
func (e *EventMsg) GetObjectID() string {
if len(e.CommentID) > 0 {
return e.CommentID