Skip to content

Commit 014096f

Browse files
committed
fix(admin): 修复 UpdateAccount 无法清空 credentials 和 extra 字段的问题
之前使用 len(x) > 0 作为判断条件,导致传入空值时字段不会被更新, 无法通过 API 清空 credentials 和 extra 字段。 将判断条件改为 x != nil,使得传入空值时能正确清空对应字段。
1 parent 3cc407b commit 014096f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

backend/internal/service/admin_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,10 +1495,10 @@ func (s *adminServiceImpl) UpdateAccount(ctx context.Context, id int64, input *U
14951495
if input.Notes != nil {
14961496
account.Notes = normalizeAccountNotes(input.Notes)
14971497
}
1498-
if len(input.Credentials) > 0 {
1498+
if input.Credentials != nil {
14991499
account.Credentials = input.Credentials
15001500
}
1501-
if len(input.Extra) > 0 {
1501+
if input.Extra != nil {
15021502
// 保留配额用量字段,防止编辑账号时意外重置
15031503
for _, key := range []string{"quota_used", "quota_daily_used", "quota_daily_start", "quota_weekly_used", "quota_weekly_start"} {
15041504
if v, ok := account.Extra[key]; ok {

0 commit comments

Comments
 (0)