init
This commit is contained in:
18
internal/store/model/admin_profile.go
Normal file
18
internal/store/model/admin_profile.go
Normal 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"`
|
||||
}
|
||||
19
internal/store/model/admin_user.go
Normal file
19
internal/store/model/admin_user.go
Normal 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"`
|
||||
}
|
||||
33
internal/store/model/job_config.go
Normal file
33
internal/store/model/job_config.go
Normal 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,
|
||||
}
|
||||
}
|
||||
10
internal/store/model/job_config_test.go
Normal file
10
internal/store/model/job_config_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
23
internal/store/model/job_execution.go
Normal file
23
internal/store/model/job_execution.go
Normal 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"`
|
||||
}
|
||||
19
internal/store/model/system_config.go
Normal file
19
internal/store/model/system_config.go
Normal 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"`
|
||||
}
|
||||
Reference in New Issue
Block a user