first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

View File

@ -0,0 +1,49 @@
package messages
import (
"encoding/json"
"github.com/spf13/viper"
)
// 事件
type Event struct {
MessageId string
Tag EventTag // 消息标签EventTagUser=用户
Flag EventFlag // 消息标签EventFlagCreate=创建 EventFlagUpdate=更新
EventId string // 事件ID
EventContent interface{} // 事件内容
}
type EventTag string
const (
EventTagUser EventTag = "user"
EventTagRoomInto EventTag = "into_room"
EventTagMessage EventTag = "message"
)
func TagIndex(key string) string {
switch key {
case string(EventTagUser):
return viper.GetString("es.default.indexUser")
case string(EventTagMessage):
return viper.GetString("es.default.indexMessage")
default:
return ""
}
}
type EventFlag string
const (
EventFlagSave EventFlag = "save"
EventFlagCreate EventFlag = "create"
EventFlagUpdate EventFlag = "update"
EventFlagDelete EventFlag = "delete"
)
func (message *Event) ToJson() string {
b, _ := json.Marshal(message)
return string(b)
}