Skip to content

Commit 79c451a

Browse files
authored
Merge pull request #102 from yokowu/feat-model-delete-check
feat(model): 模型删除检查
2 parents a40a37b + 1d3efe9 commit 79c451a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

backend/docs/swagger.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,6 +3441,10 @@
34413441
"description": "用户ID",
34423442
"type": "string"
34433443
},
3444+
"is_deleted": {
3445+
"description": "是否删除",
3446+
"type": "boolean"
3447+
},
34443448
"last_active_at": {
34453449
"description": "最后活跃时间",
34463450
"type": "integer"
@@ -3517,6 +3521,10 @@
35173521
"domain.UserLoginHistory": {
35183522
"type": "object",
35193523
"properties": {
3524+
"client_id": {
3525+
"description": "插件ID vscode",
3526+
"type": "string"
3527+
},
35203528
"client_version": {
35213529
"description": "客户端版本",
35223530
"type": "string"
@@ -3529,6 +3537,10 @@
35293537
"description": "设备信息",
35303538
"type": "string"
35313539
},
3540+
"hostname": {
3541+
"description": "主机名",
3542+
"type": "string"
3543+
},
35323544
"ip_info": {
35333545
"description": "IP信息",
35343546
"allOf": [

backend/internal/model/repo/model.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,15 @@ func (r *ModelRepo) Delete(ctx context.Context, id string) error {
249249
if err != nil {
250250
return err
251251
}
252+
model, err := r.db.Model.Get(ctx, uuidID)
253+
if err != nil {
254+
return err
255+
}
256+
if model.IsInternal {
257+
return fmt.Errorf("internal model can not be deleted")
258+
}
259+
if model.Status == consts.ModelStatusActive {
260+
return fmt.Errorf("active model can not be deleted")
261+
}
252262
return r.db.Model.DeleteOneID(uuidID).Exec(ctx)
253263
}

0 commit comments

Comments
 (0)