feat: data models and database migration
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Source struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
APIKey string `db:"api_key" json:"api_key,omitempty"`
|
||||
ParseMode string `db:"parse_mode" json:"parse_mode"`
|
||||
ParsePattern string `db:"parse_pattern" json:"parse_pattern,omitempty"`
|
||||
Status int `db:"status" json:"status"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
type Template struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Content string `db:"content" json:"content"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Type string `db:"type" json:"type"`
|
||||
Config *json.RawMessage `db:"config" json:"config"`
|
||||
Status int `db:"status" json:"status"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
type Rule struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
SourceID int `db:"source_id" json:"source_id"`
|
||||
Event string `db:"event" json:"event"`
|
||||
TemplateID int `db:"template_id" json:"template_id"`
|
||||
Conditions *json.RawMessage `db:"conditions" json:"conditions,omitempty"`
|
||||
Enabled int `db:"enabled" json:"enabled"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
type Condition struct {
|
||||
Field string `json:"field"`
|
||||
Op string `json:"op"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type RuleChannel struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
RuleID int `db:"rule_id" json:"rule_id"`
|
||||
ChannelID int `db:"channel_id" json:"channel_id"`
|
||||
Enabled int `db:"enabled" json:"enabled"`
|
||||
}
|
||||
|
||||
type MessageLog struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
RuleID int `db:"rule_id" json:"rule_id"`
|
||||
ChannelID int `db:"channel_id" json:"channel_id"`
|
||||
Source string `db:"source" json:"source"`
|
||||
Event string `db:"event" json:"event"`
|
||||
Payload json.RawMessage `db:"payload" json:"payload"`
|
||||
Content string `db:"content" json:"content"`
|
||||
Status string `db:"status" json:"status"`
|
||||
RetryCount int `db:"retry_count" json:"retry_count"`
|
||||
Response sql.NullString `db:"response" json:"response,omitempty"`
|
||||
ErrorMsg sql.NullString `db:"error_msg" json:"error_msg,omitempty"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
}
|
||||
Reference in New Issue
Block a user