mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 14:53:55 +08:00
Merge pull request #102 from yokowu/feat-model-delete-check
feat(model): 模型删除检查
This commit is contained in:
@@ -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": [
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user