code refactor

This commit is contained in:
MaysWind
2020-12-22 23:01:33 +08:00
parent 024960f767
commit 5ba83192b0
6 changed files with 21 additions and 5 deletions
+6 -2
View File
@@ -278,13 +278,17 @@ func (s *AccountService) DeleteAccount(uid int64, accountId int64) error {
exists, err := sess.Cols("uid", "deleted", "source_account_id").Where("uid=? AND deleted=?", uid, false).In("source_account_id", accountAndSubAccountIds).Limit(1).Exist(&models.Transaction{})
if exists {
if err != nil {
return err
} else if exists {
return errs.ErrAccountInUseCannotBeDeleted
}
exists, err = sess.Cols("uid", "deleted", "destination_account_id").Where("uid=? AND deleted=?", uid, false).In("destination_account_id", accountAndSubAccountIds).Limit(1).Exist(&models.Transaction{})
if exists {
if err != nil {
return err
} else if exists {
return errs.ErrAccountInUseCannotBeDeleted
}