This commit is contained in:
vet
2026-05-28 00:16:19 +08:00
commit 52446ccf3f
54 changed files with 4617 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type AdminProfile struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Account string `bson:"account" json:"account"`
Nickname string `bson:"nickname" json:"nickname"`
Avatar string `bson:"avatar" json:"avatar"`
Remark string `bson:"remark" json:"remark"`
PasswordHash string `bson:"passwordHash" json:"-"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
}

View File

@@ -0,0 +1,19 @@
package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type AdminUser struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Account string `bson:"account" json:"account"`
Nickname string `bson:"nickname" json:"nickname"`
Status string `bson:"status" json:"status"`
Role string `bson:"role" json:"role"`
Remark string `bson:"remark" json:"remark"`
PasswordHash string `bson:"passwordHash" json:"-"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
}

View File

@@ -0,0 +1,33 @@
package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type JobConfig struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Name string `bson:"name" json:"name"`
HandlerKey string `bson:"handlerKey" json:"handlerKey"`
Enabled bool `bson:"enabled" json:"enabled"`
ScheduleType string `bson:"scheduleType" json:"scheduleType"`
ScheduleValue string `bson:"scheduleValue" json:"scheduleValue"`
DefaultParams string `bson:"defaultParams" json:"defaultParams"`
LastStatus string `bson:"lastStatus" json:"lastStatus"`
LastRunAt *time.Time `bson:"lastRunAt,omitempty" json:"lastRunAt,omitempty"`
NextRunAt *time.Time `bson:"nextRunAt,omitempty" json:"nextRunAt,omitempty"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
}
func NewJobConfig(name, handlerKey string) JobConfig {
now := time.Now()
return JobConfig{
Name: name,
HandlerKey: handlerKey,
LastStatus: "idle",
CreatedAt: now,
UpdatedAt: now,
}
}

View File

@@ -0,0 +1,10 @@
package model
import "testing"
func TestJobConfigDefaultsToIdleStatus(t *testing.T) {
job := NewJobConfig("daily-check", "daily-check")
if job.LastStatus != "idle" {
t.Fatalf("LastStatus = %q, want idle", job.LastStatus)
}
}

View File

@@ -0,0 +1,23 @@
package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type JobExecution struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
JobConfigID primitive.ObjectID `bson:"jobConfigId" json:"jobConfigId"`
TriggerType string `bson:"triggerType" json:"triggerType"`
Status string `bson:"status" json:"status"`
ParamsSnapshot string `bson:"paramsSnapshot" json:"paramsSnapshot"`
StartedAt *time.Time `bson:"startedAt,omitempty" json:"startedAt,omitempty"`
FinishedAt *time.Time `bson:"finishedAt,omitempty" json:"finishedAt,omitempty"`
DurationMs int64 `bson:"durationMs" json:"durationMs"`
ResultSummary string `bson:"resultSummary" json:"resultSummary"`
ErrorMessage string `bson:"errorMessage" json:"errorMessage"`
LogText string `bson:"logText" json:"logText"`
LogFile string `bson:"logFile,omitempty" json:"logFile,omitempty"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
}

View File

@@ -0,0 +1,19 @@
package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type SystemConfig struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Key string `bson:"key" json:"key"`
Title string `bson:"title" json:"title"`
Value string `bson:"value" json:"value"`
ValueType string `bson:"valueType" json:"valueType"`
Description string `bson:"description" json:"description"`
Enabled bool `bson:"enabled" json:"enabled"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
}