code refactor

This commit is contained in:
MaysWind
2020-12-23 01:24:44 +08:00
parent 62ef7cbcbe
commit b3962e8af9
35 changed files with 256 additions and 255 deletions
+3 -3
View File
@@ -53,7 +53,7 @@ func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Er
continue
}
if userAccountResp.ParentId <= models.ACCOUNT_PARENT_ID_LEVEL_ONE {
if userAccountResp.ParentId <= models.LevelOneAccountParentId {
continue
}
@@ -69,7 +69,7 @@ func (a *AccountsApi) AccountListHandler(c *core.Context) (interface{}, *errs.Er
userFinalAccountResps := make(models.AccountInfoResponseSlice, 0, len(userAllAccountResps))
for i := 0; i < len(userAllAccountResps); i++ {
if userAllAccountResps[i].ParentId == models.ACCOUNT_PARENT_ID_LEVEL_ONE && (!accountListReq.VisibleOnly || !userAllAccountResps[i].Hidden) {
if userAllAccountResps[i].ParentId == models.LevelOneAccountParentId && (!accountListReq.VisibleOnly || !userAllAccountResps[i].Hidden) {
sort.Sort(userAllAccountResps[i].SubAccounts)
userFinalAccountResps = append(userFinalAccountResps, userAllAccountResps[i])
}
@@ -142,7 +142,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
return nil, errs.ErrAccountHaveNoSubAccount
}
if accountCreateReq.Currency != validators.PARENT_ACCOUNT_CURRENCY_PLACEHODLER {
if accountCreateReq.Currency != validators.ParentAccountCurrencyPlaceholder {
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] parent account cannot set currency")
return nil, errs.ErrParentAccountCannotSetCurrency
}
+2 -2
View File
@@ -335,7 +335,7 @@ func (a *TransactionCategoriesApi) getTransactionCategoryListByTypeResponse(cate
for i := 0; i < len(categoryResps); i++ {
categoryResp := categoryResps[i]
if categoryResp.ParentId <= models.TRANSACTION_PARENT_ID_LEVEL_ONE {
if categoryResp.ParentId <= models.LevelOneTransactionParentId {
continue
}
@@ -351,7 +351,7 @@ func (a *TransactionCategoriesApi) getTransactionCategoryListByTypeResponse(cate
finalCategoryResps := make(models.TransactionCategoryInfoResponseSlice, 0)
for i := 0; i < len(categoryResps); i++ {
if parentId <= 0 && categoryResps[i].ParentId == models.TRANSACTION_PARENT_ID_LEVEL_ONE {
if parentId <= 0 && categoryResps[i].ParentId == models.LevelOneTransactionParentId {
sort.Sort(categoryResps[i].SubCategories)
finalCategoryResps = append(finalCategoryResps, categoryResps[i])
} else if parentId > 0 && categoryResps[i].ParentId == parentId {