Align backend workbench API with prototype
This commit is contained in:
23
backend/internal/models/cron_plan.go
Normal file
23
backend/internal/models/cron_plan.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type SenlinAgentCronPlan struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Identity string `gorm:"type:char(36);uniqueIndex"`
|
||||
ProjectID uint `gorm:"index;not null"`
|
||||
ProjectIdentity string `gorm:"type:char(36);index"`
|
||||
CreatedBy uint `gorm:"index;not null"`
|
||||
CreatedByIdentity string `gorm:"type:char(36);index"`
|
||||
Title string `gorm:"not null"`
|
||||
Schedule string `gorm:"not null"`
|
||||
NextRunAt *time.Time
|
||||
Enabled bool `gorm:"not null;default:false"`
|
||||
LastResult string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (SenlinAgentCronPlan) TableName() string {
|
||||
return "senlin_agent_cron_plans"
|
||||
}
|
||||
@@ -87,6 +87,23 @@ func (m *SenlinAgentTag) BeforeCreate(tx *gorm.DB) error {
|
||||
return resolveIdentity(tx, &SenlinAgentProject{}, m.ProjectID, &m.ProjectIdentity)
|
||||
}
|
||||
|
||||
func (m *SenlinAgentProjectChannel) BeforeCreate(tx *gorm.DB) error {
|
||||
if err := ensureIdentity(&m.Identity); err != nil {
|
||||
return err
|
||||
}
|
||||
return resolveIdentity(tx, &SenlinAgentProject{}, m.ProjectID, &m.ProjectIdentity)
|
||||
}
|
||||
|
||||
func (m *SenlinAgentCronPlan) BeforeCreate(tx *gorm.DB) error {
|
||||
if err := ensureIdentity(&m.Identity); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := resolveIdentity(tx, &SenlinAgentProject{}, m.ProjectID, &m.ProjectIdentity); err != nil {
|
||||
return err
|
||||
}
|
||||
return resolveIdentity(tx, &SenlinAgentUser{}, m.CreatedBy, &m.CreatedByIdentity)
|
||||
}
|
||||
|
||||
func (m *SenlinAgentProjectEvent) BeforeCreate(tx *gorm.DB) error {
|
||||
if err := ensureIdentity(&m.Identity); err != nil {
|
||||
return err
|
||||
|
||||
@@ -31,6 +31,8 @@ func AutoMigrate(database *gorm.DB) error {
|
||||
&SenlinAgentSource{},
|
||||
&SenlinAgentAISession{},
|
||||
&SenlinAgentTag{},
|
||||
&SenlinAgentProjectChannel{},
|
||||
&SenlinAgentCronPlan{},
|
||||
&SenlinAgentProjectEvent{},
|
||||
&SenlinAgentAIKey{},
|
||||
&SenlinAgentAICallLog{},
|
||||
|
||||
20
backend/internal/models/project_channel.go
Normal file
20
backend/internal/models/project_channel.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type SenlinAgentProjectChannel struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Identity string `gorm:"type:char(36);uniqueIndex"`
|
||||
ProjectID uint `gorm:"index;not null"`
|
||||
ProjectIdentity string `gorm:"type:char(36);index"`
|
||||
Title string `gorm:"not null"`
|
||||
Icon string `gorm:"not null;default:link"`
|
||||
URL string `gorm:"not null"`
|
||||
SortOrder int `gorm:"not null;default:0"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (SenlinAgentProjectChannel) TableName() string {
|
||||
return "senlin_agent_project_channels"
|
||||
}
|
||||
Reference in New Issue
Block a user