feat(model): add task defaults, job queries, and refine file/task DTOs
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Parameter type constants for ParameterSchema.Type.
|
||||
// 参数类型常量
|
||||
const (
|
||||
ParamTypeString = "string"
|
||||
ParamTypeInteger = "integer"
|
||||
@@ -15,62 +15,59 @@ const (
|
||||
ParamTypeBoolean = "boolean"
|
||||
)
|
||||
|
||||
// Application represents a parameterized application definition for HPC job submission.
|
||||
// Application 表示一个参数化的 HPC 应用定义。
|
||||
type Application struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Name string `gorm:"uniqueIndex;size:255;not null" json:"name"`
|
||||
Description string `gorm:"type:text" json:"description,omitempty"`
|
||||
Icon string `gorm:"size:255" json:"icon,omitempty"`
|
||||
Category string `gorm:"size:255" json:"category,omitempty"`
|
||||
ScriptTemplate string `gorm:"type:text;not null" json:"script_template"`
|
||||
Parameters json.RawMessage `gorm:"type:json" json:"parameters,omitempty"`
|
||||
Scope string `gorm:"size:50;default:'system'" json:"scope,omitempty"`
|
||||
CreatedBy int64 `json:"created_by,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` // 主键
|
||||
Name string `gorm:"uniqueIndex;size:255;not null" json:"name"` // 应用名称(唯一)
|
||||
Description string `gorm:"type:text" json:"description,omitempty"` // 应用描述
|
||||
Icon string `gorm:"size:255" json:"icon,omitempty"` // 图标
|
||||
Category string `gorm:"size:255" json:"category,omitempty"` // 分类
|
||||
ScriptTemplate string `gorm:"type:text;not null" json:"script_template"` // 脚本模板
|
||||
Parameters json.RawMessage `gorm:"type:json" json:"parameters,omitempty"` // 参数表单JSON
|
||||
Scope string `gorm:"size:50;default:'system'" json:"scope,omitempty"` // 作用域(system/user)
|
||||
CreatedBy int64 `json:"created_by,omitempty"` // 创建者ID
|
||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
func (Application) TableName() string {
|
||||
return "hpc_applications"
|
||||
}
|
||||
|
||||
// ParameterSchema defines a single parameter in an application's form schema.
|
||||
// ParameterSchema 定义应用表单中单个参数的格式。
|
||||
type ParameterSchema struct {
|
||||
Name string `json:"name"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
Default string `json:"default,omitempty"`
|
||||
Options []string `json:"options,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Name string `json:"name"` // 参数名
|
||||
Label string `json:"label,omitempty"` // 显示名称
|
||||
Type string `json:"type"` // 参数类型
|
||||
Required bool `json:"required,omitempty"` // 是否必填
|
||||
Default string `json:"default,omitempty"` // 默认值
|
||||
Options []string `json:"options,omitempty"` // 枚举选项列表
|
||||
Description string `json:"description,omitempty"` // 参数说明
|
||||
}
|
||||
|
||||
// CreateApplicationRequest is the DTO for creating a new application.
|
||||
// CreateApplicationRequest 是创建应用的 API 请求。
|
||||
type CreateApplicationRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
ScriptTemplate string `json:"script_template" binding:"required"`
|
||||
Parameters json.RawMessage `json:"parameters,omitempty"`
|
||||
Scope string `json:"scope,omitempty"`
|
||||
Name string `json:"name" binding:"required"` // 应用名称(必填)
|
||||
Description string `json:"description,omitempty"` // 应用描述
|
||||
Icon string `json:"icon,omitempty"` // 图标
|
||||
Category string `json:"category,omitempty"` // 分类
|
||||
ScriptTemplate string `json:"script_template" binding:"required"` // 脚本模板(必填)
|
||||
Parameters json.RawMessage `json:"parameters,omitempty"` // 参数表单JSON
|
||||
Scope string `json:"scope,omitempty"` // 作用域
|
||||
}
|
||||
|
||||
// UpdateApplicationRequest is the DTO for updating an existing application.
|
||||
// All fields are optional. Parameters uses *json.RawMessage to distinguish
|
||||
// between "not provided" (nil) and "set to empty" (non-nil).
|
||||
// UpdateApplicationRequest 是更新应用的 API 请求。所有字段可选。
|
||||
type UpdateApplicationRequest struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Icon *string `json:"icon,omitempty"`
|
||||
Category *string `json:"category,omitempty"`
|
||||
ScriptTemplate *string `json:"script_template,omitempty"`
|
||||
Parameters *json.RawMessage `json:"parameters,omitempty"`
|
||||
Scope *string `json:"scope,omitempty"`
|
||||
Name *string `json:"name,omitempty"` // 应用名称
|
||||
Description *string `json:"description,omitempty"` // 应用描述
|
||||
Icon *string `json:"icon,omitempty"` // 图标
|
||||
Category *string `json:"category,omitempty"` // 分类
|
||||
ScriptTemplate *string `json:"script_template,omitempty"` // 脚本模板
|
||||
Parameters *json.RawMessage `json:"parameters,omitempty"` // 参数表单JSON
|
||||
Scope *string `json:"scope,omitempty"` // 作用域
|
||||
}
|
||||
|
||||
// ApplicationSubmitRequest is the DTO for submitting a job from an application.
|
||||
// ApplicationID is parsed from the URL :id parameter, not included in the body.
|
||||
// ApplicationSubmitRequest 是通过应用提交作业的 API 请求。
|
||||
type ApplicationSubmitRequest struct {
|
||||
Values map[string]string `json:"values" binding:"required"`
|
||||
Values map[string]string `json:"values" binding:"required"` // 脚本业务参数键值对
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user