From ff99f55b0a9ec1d8931f14c2dbbe4e009ca68e67 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Mon, 6 Jan 2025 10:57:23 +0800 Subject: [PATCH] update ai key status to gateway --- module/ai-key/iml.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/module/ai-key/iml.go b/module/ai-key/iml.go index 0e939306..41ac7d90 100644 --- a/module/ai-key/iml.go +++ b/module/ai-key/iml.go @@ -367,9 +367,20 @@ func (i *imlKeyModule) UpdateKeyStatus(ctx context.Context, providerId string, i if !enable { // TODO:下线Key status := ai_key_dto.KeyDisable.Int() - return i.aiKeyService.Save(ctx, id, &ai_key.Edit{ + err = i.aiKeyService.Save(ctx, id, &ai_key.Edit{ Status: &status, }) + if err != nil { + return err + } + releases := []*gateway.DynamicRelease{{ + BasicItem: &gateway.BasicItem{ + ID: id, + Resource: "ai-key", + }, + Attr: nil, + }} + return i.syncGateway(ctx, providerId, releases, false) } if info.Status == ai_key_dto.KeyDisable.Int() || info.Status == ai_key_dto.KeyExceed.Int() { // 超额 或 停用状态,可启用 @@ -380,7 +391,6 @@ func (i *imlKeyModule) UpdateKeyStatus(ctx context.Context, providerId string, i Status: &status, }) } - // TODO:发布Key到网关 status := ai_key_dto.KeyNormal.Int() err = i.aiKeyService.Save(ctx, id, &ai_key.Edit{ Status: &status,