From 88a89610739b2e8b17af8c8b64efc86ba7ff8f46 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 16 Nov 2020 01:28:31 +0800 Subject: [PATCH] code refactor --- pkg/api/accounts.go | 4 ++-- pkg/services/accounts.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/api/accounts.go b/pkg/api/accounts.go index 906c2e14..23c1cb75 100644 --- a/pkg/api/accounts.go +++ b/pkg/api/accounts.go @@ -92,9 +92,9 @@ func (a *AccountsApi) AccountGetHandler(c *core.Context) (interface{}, *errs.Err accountRespMap[acccountResp.Id] = acccountResp } - accountResp := accountRespMap[accountGetReq.Id] + accountResp, exists := accountRespMap[accountGetReq.Id] - if accountResp == nil { + if !exists { return nil, errs.ErrAccountNotFound } diff --git a/pkg/services/accounts.go b/pkg/services/accounts.go index 65e00ca4..0e3bff2e 100644 --- a/pkg/services/accounts.go +++ b/pkg/services/accounts.go @@ -197,7 +197,7 @@ func (s *AccountService) ModifyAccountDisplayOrders(uid int64, accounts []*model return s.UserDataDB(uid).DoTransaction(func(sess *xorm.Session) error { for i := 0; i < len(accounts); i++ { account := accounts[i] - _, err := sess.Cols("display_order", "updated_unix_time").Where("account_id=? AND uid=? AND deleted=?", account.AccountId, account.Uid, false).Update(account) + _, err := sess.Cols("display_order", "updated_unix_time").Where("account_id=? AND uid=? AND deleted=?", account.AccountId, uid, false).Update(account) if err != nil { return err