Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package eventmod
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type EventList []*Event
|
||||
type EventUpdate struct {
|
||||
RetryCount *int `json:"retryCount" bson:"retryCount,omitempty"` // 重试次数
|
||||
Status *EventStatus `json:"status" bson:"status,omitempty"` //
|
||||
Data *string `json:"data" bson:"data,omitempty"` //
|
||||
EventType *string `json:"eventType" bson:"eventType,omitempty"` //
|
||||
EventId *string `json:"eventId" bson:"eventId,omitempty"` //
|
||||
UpdatedAt *time.Time `json:"" bson:"updatedAt,omitempty"` // 修改时间
|
||||
}
|
||||
type EventQuery struct {
|
||||
ID *primitive.ObjectID `json:"" bson:"_id,omitempty"` //
|
||||
RetryCount *int `json:"retryCount" bson:"retryCount,omitempty"` // 重试次数
|
||||
Status *EventStatus `json:"status" bson:"status,omitempty"` //
|
||||
Data *string `json:"data" bson:"data,omitempty"` //
|
||||
EventType *string `json:"eventType" bson:"eventType,omitempty"` //
|
||||
EventId *string `json:"eventId" bson:"eventId,omitempty"` //
|
||||
UpdatedAt *time.Time `json:"" bson:"updatedAt,omitempty"` // 修改时间
|
||||
}
|
||||
|
||||
func (query *EventQuery) GetQueryFilter() bson.M {
|
||||
filter := bson.M{}
|
||||
if query.ID != nil {
|
||||
filter[FN.Event.ID] = *query.ID
|
||||
}
|
||||
if query.RetryCount != nil {
|
||||
filter[FN.Event.RetryCount] = *query.RetryCount
|
||||
}
|
||||
if query.Status != nil {
|
||||
filter[FN.Event.Status] = *query.Status
|
||||
}
|
||||
if query.Data != nil {
|
||||
filter[FN.Event.Data] = bson.M{"$regex": primitive.Regex{Pattern: *query.Data, Options: "i"}}
|
||||
}
|
||||
if query.EventType != nil {
|
||||
filter[FN.Event.EventType] = bson.M{"$regex": primitive.Regex{Pattern: *query.EventType, Options: "i"}}
|
||||
}
|
||||
if query.EventId != nil {
|
||||
filter[FN.Event.EventId] = bson.M{"$regex": primitive.Regex{Pattern: *query.EventId, Options: "i"}}
|
||||
}
|
||||
if query.UpdatedAt != nil {
|
||||
filter[FN.Event.UpdatedAt] = *query.UpdatedAt
|
||||
}
|
||||
return filter
|
||||
}
|
||||
Reference in New Issue
Block a user