- model/skill.go: Status字段从 int 改为 string,支持 "active"/"inactive" - handler/skill_handler.go: 适配Status字段的类型变化,处理"1"/"0"和"active"/"inactive"两种格式 - repository/skill_repo.go: 更新Status字段的空值判断逻辑 - service/skill_service.go: 同步更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
888 B
Go
30 lines
888 B
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Skill 技能
|
|
type Skill struct {
|
|
ID string `json:"id" gorm:"primaryKey"`
|
|
SkillName string `json:"skill_name" gorm:"size:200;not null"`
|
|
SkillType string `json:"skill_type" gorm:"size:20;not null"` // system / user
|
|
SkillDesc string `json:"skill_desc" gorm:"type:text"`
|
|
Path string `json:"path" gorm:"size:500"` // skill 文件路径
|
|
Status string `json:"status" gorm:"size:20;default:active"` // active / inactive
|
|
CreatedBy string `json:"created_by" gorm:"size:100"` // 创建者用户名
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// BeforeCreate 创建前自动生成ID
|
|
func (s *Skill) BeforeCreate(tx *gorm.DB) error {
|
|
if s.ID == "" {
|
|
s.ID = uuid.New().String()
|
|
}
|
|
return nil
|
|
}
|