Merge pull request #102 from yokowu/feat-model-delete-check

feat(model): 模型删除检查
This commit is contained in:
Yoko
2025-07-17 19:49:24 +08:00
committed by GitHub
2 changed files with 22 additions and 0 deletions

View File

@@ -3441,6 +3441,10 @@
"description": "用户ID",
"type": "string"
},
"is_deleted": {
"description": "是否删除",
"type": "boolean"
},
"last_active_at": {
"description": "最后活跃时间",
"type": "integer"
@@ -3517,6 +3521,10 @@
"domain.UserLoginHistory": {
"type": "object",
"properties": {
"client_id": {
"description": "插件ID vscode",
"type": "string"
},
"client_version": {
"description": "客户端版本",
"type": "string"
@@ -3529,6 +3537,10 @@
"description": "设备信息",
"type": "string"
},
"hostname": {
"description": "主机名",
"type": "string"
},
"ip_info": {
"description": "IP信息",
"allOf": [

View File

@@ -249,5 +249,15 @@ func (r *ModelRepo) Delete(ctx context.Context, id string) error {
if err != nil {
return err
}
model, err := r.db.Model.Get(ctx, uuidID)
if err != nil {
return err
}
if model.IsInternal {
return fmt.Errorf("internal model can not be deleted")
}
if model.Status == consts.ModelStatusActive {
return fmt.Errorf("active model can not be deleted")
}
return r.db.Model.DeleteOneID(uuidID).Exec(ctx)
}