Files
X-Agents/server/internal/model/tool.go

32 lines
1005 B
Go
Raw Normal View History

package model
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// Tool 工具
type Tool struct {
ID string `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"uniqueIndex;size:100;not null"`
Description string `json:"description" gorm:"type:text"`
Category string `json:"category" gorm:"size:50;not null"`
Provider string `json:"provider" gorm:"size:100"`
SecurityLevel string `json:"security_level" gorm:"size:20;default:'safe'"`
RequireApproval bool `json:"require_approval" gorm:"default:false"`
Parameters string `json:"parameters" gorm:"type:text"` // JSON格式存储
Status string `json:"status" gorm:"size:20;default:'active'"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// BeforeCreate 创建前自动生成ID
func (t *Tool) BeforeCreate(tx *gorm.DB) error {
if t.ID == "" {
t.ID = uuid.New().String()
}
return nil
}