From 58de308f30cd001508ac56f0155bc27e7956168e Mon Sep 17 00:00:00 2001 From: MaysWind Date: Tue, 9 Jul 2024 22:23:26 +0800 Subject: [PATCH] modify variable name --- pkg/api/data_managements.go | 4 +- pkg/cli/user_data.go | 46 +++++++++++----------- pkg/converters/data_converter.go | 2 +- pkg/converters/ezbookkeeping_csv_file.go | 4 +- pkg/converters/ezbookkeeping_plain_file.go | 12 +++--- pkg/converters/ezbookkeeping_tsv_file.go | 4 +- pkg/services/transaction_tags.go | 34 ++++++++-------- pkg/services/transactions.go | 34 ++++++++-------- 8 files changed, 70 insertions(+), 70 deletions(-) diff --git a/pkg/api/data_managements.go b/pkg/api/data_managements.go index cf362ae2..9ecba143 100644 --- a/pkg/api/data_managements.go +++ b/pkg/api/data_managements.go @@ -190,7 +190,7 @@ func (a *DataManagementsApi) getExportedFileContent(c *core.Context, fileType st return nil, "", errs.ErrOperationFailed } - tagIndexs, err := a.tags.GetAllTagIdsMapOfAllTransactions(c, uid) + tagIndexes, err := a.tags.GetAllTagIdsMapOfAllTransactions(c, uid) if err != nil { log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get tag index for user \"uid:%d\", because %s", uid, err.Error()) @@ -216,7 +216,7 @@ func (a *DataManagementsApi) getExportedFileContent(c *core.Context, fileType st dataExporter = a.ezBookKeepingCsvExporter } - result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexs) + result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexes) if err != nil { log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get csv format exported data for \"uid:%d\", because %s", uid, err.Error()) diff --git a/pkg/cli/user_data.go b/pkg/cli/user_data.go index 2093e7a2..83265875 100644 --- a/pkg/cli/user_data.go +++ b/pkg/cli/user_data.go @@ -432,7 +432,7 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string return false, err } - accountMap, categoryMap, tagMap, tagIndexs, tagIndexsMap, err := l.getUserEssentialData(uid, username) + accountMap, categoryMap, tagMap, tagIndexes, tagIndexesMap, err := l.getUserEssentialData(uid, username) if err != nil { log.BootErrorf("[user_data.CheckTransactionAndAccount] failed to get essential data for user \"%s\", because %s", username, err.Error()) @@ -472,7 +472,7 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string return false, err } - err = l.checkTransactionTag(c, transaction.TransactionId, tagIndexsMap, tagMap) + err = l.checkTransactionTag(c, transaction.TransactionId, tagIndexesMap, tagMap) if err != nil { return false, err @@ -535,8 +535,8 @@ func (l *UserDataCli) CheckTransactionAndAccount(c *cli.Context, username string } } - for i := 0; i < len(tagIndexs); i++ { - tagIndex := tagIndexs[i] + for i := 0; i < len(tagIndexes); i++ { + tagIndex := tagIndexes[i] if tagIndex.TransactionTime < 1 { log.BootErrorf("[user_data.CheckTransactionAndAccount] transaction tag index \"id:%d\" does not have transaction time", tagIndex.TagIndexId) @@ -561,24 +561,24 @@ func (l *UserDataCli) FixTransactionTagIndexWithTransactionTime(c *cli.Context, return false, err } - tagIndexs, err := l.tags.GetAllTagIdsOfAllTransactions(nil, uid) + tagIndexes, err := l.tags.GetAllTagIdsOfAllTransactions(nil, uid) if err != nil { log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] failed to get tag index for user \"%s\", because %s", username, err.Error()) return false, err } - invalidTagIndexs := make([]*models.TransactionTagIndex, 0, len(tagIndexs)) + invalidTagIndexes := make([]*models.TransactionTagIndex, 0, len(tagIndexes)) - for i := 0; i < len(tagIndexs); i++ { - tagIndex := tagIndexs[i] + for i := 0; i < len(tagIndexes); i++ { + tagIndex := tagIndexes[i] if tagIndex.TransactionTime < 1 { - invalidTagIndexs = append(invalidTagIndexs, tagIndex) + invalidTagIndexes = append(invalidTagIndexes, tagIndex) } } - if len(invalidTagIndexs) < 1 { + if len(invalidTagIndexes) < 1 { log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] all user transaction tag index data has been checked, there is no problem with user data") return false, errs.ErrOperationFailed } @@ -592,8 +592,8 @@ func (l *UserDataCli) FixTransactionTagIndexWithTransactionTime(c *cli.Context, transactionMap := l.transactions.GetTransactionMapByList(allTransactions) - for i := 0; i < len(invalidTagIndexs); i++ { - tagIndex := invalidTagIndexs[i] + for i := 0; i < len(invalidTagIndexes); i++ { + tagIndex := invalidTagIndexes[i] transaction, exists := transactionMap[tagIndex.TransactionId] if !exists { @@ -603,7 +603,7 @@ func (l *UserDataCli) FixTransactionTagIndexWithTransactionTime(c *cli.Context, tagIndex.TransactionTime = transaction.TransactionTime } - err = l.tags.ModifyTagIndexTransactionTime(nil, uid, invalidTagIndexs) + err = l.tags.ModifyTagIndexTransactionTime(nil, uid, invalidTagIndexes) if err != nil { log.BootErrorf("[user_data.FixTransactionTagIndexWithTransactionTime] failed to update transaction tag index for user \"%s\", because %s", username, err.Error()) @@ -627,7 +627,7 @@ func (l *UserDataCli) ExportTransaction(c *cli.Context, username string, fileTyp return nil, err } - accountMap, categoryMap, tagMap, _, tagIndexsMap, err := l.getUserEssentialData(uid, username) + accountMap, categoryMap, tagMap, _, tagIndexesMap, err := l.getUserEssentialData(uid, username) if err != nil { log.BootErrorf("[user_data.ExportTransaction] failed to get essential data for user \"%s\", because %s", username, err.Error()) @@ -649,7 +649,7 @@ func (l *UserDataCli) ExportTransaction(c *cli.Context, username string, fileTyp dataExporter = l.ezBookKeepingCsvExporter } - result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexsMap) + result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexesMap) if err != nil { log.BootErrorf("[user_data.ExportTransaction] failed to get csv format exported data for \"%s\", because %s", username, err.Error()) @@ -670,7 +670,7 @@ func (l *UserDataCli) getUserIdByUsername(c *cli.Context, username string) (int6 return user.Uid, nil } -func (l *UserDataCli) getUserEssentialData(uid int64, username string) (accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, tagIndexs []*models.TransactionTagIndex, tagIndexsMap map[int64][]int64, err error) { +func (l *UserDataCli) getUserEssentialData(uid int64, username string) (accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, tagIndexes []*models.TransactionTagIndex, tagIndexesMap map[int64][]int64, err error) { if uid <= 0 { log.BootErrorf("[user_data.getUserEssentialData] user uid \"%d\" is invalid", uid) return nil, nil, nil, nil, nil, errs.ErrUserIdInvalid @@ -703,16 +703,16 @@ func (l *UserDataCli) getUserEssentialData(uid int64, username string) (accountM tagMap = l.tags.GetTagMapByList(tags) - tagIndexs, err = l.tags.GetAllTagIdsOfAllTransactions(nil, uid) + tagIndexes, err = l.tags.GetAllTagIdsOfAllTransactions(nil, uid) if err != nil { log.BootErrorf("[user_data.getUserEssentialData] failed to get tag index for user \"%s\", because %s", username, err.Error()) return nil, nil, nil, nil, nil, err } - tagIndexsMap = l.tags.GetGroupedTransactionTagIds(tagIndexs) + tagIndexesMap = l.tags.GetGroupedTransactionTagIds(tagIndexes) - return accountMap, categoryMap, tagMap, tagIndexs, tagIndexsMap, nil + return accountMap, categoryMap, tagMap, tagIndexes, tagIndexesMap, nil } func (l *UserDataCli) checkTransactionAccount(c *cli.Context, transaction *models.Transaction, accountMap map[int64]*models.Account, accountHasChild map[int64]bool) error { @@ -770,15 +770,15 @@ func (l *UserDataCli) checkTransactionCategory(c *cli.Context, transaction *mode return nil } -func (l *UserDataCli) checkTransactionTag(c *cli.Context, transactionId int64, allTagIndexsMap map[int64][]int64, tagMap map[int64]*models.TransactionTag) error { - tagIndexs, exists := allTagIndexsMap[transactionId] +func (l *UserDataCli) checkTransactionTag(c *cli.Context, transactionId int64, allTagIndexesMap map[int64][]int64, tagMap map[int64]*models.TransactionTag) error { + tagIndexes, exists := allTagIndexesMap[transactionId] if !exists { return nil } - for i := 0; i < len(tagIndexs); i++ { - tagIndex := tagIndexs[i] + for i := 0; i < len(tagIndexes); i++ { + tagIndex := tagIndexes[i] tag, exists := tagMap[tagIndex] if !exists { diff --git a/pkg/converters/data_converter.go b/pkg/converters/data_converter.go index 999f3f5f..98be0a47 100644 --- a/pkg/converters/data_converter.go +++ b/pkg/converters/data_converter.go @@ -7,5 +7,5 @@ import ( // DataConverter defines the structure of data exporter type DataConverter interface { // ToExportedContent returns the exported data - ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) + ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) } diff --git a/pkg/converters/ezbookkeeping_csv_file.go b/pkg/converters/ezbookkeeping_csv_file.go index 0ec7ea24..77ae74e8 100644 --- a/pkg/converters/ezbookkeeping_csv_file.go +++ b/pkg/converters/ezbookkeeping_csv_file.go @@ -12,6 +12,6 @@ type EzBookKeepingCSVFileExporter struct { const csvSeparator = "," // ToExportedContent returns the exported CSV data -func (e *EzBookKeepingCSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { - return e.toExportedContent(uid, csvSeparator, transactions, accountMap, categoryMap, tagMap, allTagIndexs) +func (e *EzBookKeepingCSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) { + return e.toExportedContent(uid, csvSeparator, transactions, accountMap, categoryMap, tagMap, allTagIndexes) } diff --git a/pkg/converters/ezbookkeeping_plain_file.go b/pkg/converters/ezbookkeeping_plain_file.go index 74ed49ab..c0011296 100644 --- a/pkg/converters/ezbookkeeping_plain_file.go +++ b/pkg/converters/ezbookkeeping_plain_file.go @@ -20,7 +20,7 @@ const headerLine = "Time,Timezone,Type,Category,Sub Category,Account,Account Cur const dataLineFormat = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" + lineSeparator // toExportedContent returns the exported plain data -func (e *EzBookKeepingPlainFileExporter) toExportedContent(uid int64, separator string, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { +func (e *EzBookKeepingPlainFileExporter) toExportedContent(uid int64, separator string, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) { var ret strings.Builder ret.Grow(len(transactions) * 100) @@ -66,7 +66,7 @@ func (e *EzBookKeepingPlainFileExporter) toExportedContent(uid int64, separator geoLocation = fmt.Sprintf("%f%s%f", transaction.GeoLongitude, geoLocationSeparator, transaction.GeoLatitude) } - tags := e.replaceDelimiters(e.getTags(transaction.TransactionId, allTagIndexs, tagMap), separator) + tags := e.replaceDelimiters(e.getTags(transaction.TransactionId, allTagIndexes, tagMap), separator) comment := e.replaceDelimiters(transaction.Comment, separator) ret.WriteString(fmt.Sprintf(actualDataLineFormat, transactionTime, transactionTimezone, transactionType, category, subCategory, account, accountCurrency, amount, account2, account2Currency, account2Amount, geoLocation, tags, comment)) @@ -159,8 +159,8 @@ func (e *EzBookKeepingPlainFileExporter) getDisplayAmount(amount int64) string { return integer + "." + decimals } -func (e *EzBookKeepingPlainFileExporter) getTags(transactionId int64, allTagIndexs map[int64][]int64, tagMap map[int64]*models.TransactionTag) string { - tagIndexs, exists := allTagIndexs[transactionId] +func (e *EzBookKeepingPlainFileExporter) getTags(transactionId int64, allTagIndexes map[int64][]int64, tagMap map[int64]*models.TransactionTag) string { + tagIndexes, exists := allTagIndexes[transactionId] if !exists { return "" @@ -168,12 +168,12 @@ func (e *EzBookKeepingPlainFileExporter) getTags(transactionId int64, allTagInde var ret strings.Builder - for i := 0; i < len(tagIndexs); i++ { + for i := 0; i < len(tagIndexes); i++ { if i > 0 { ret.WriteString(transactionTagSeparator) } - tagIndex := tagIndexs[i] + tagIndex := tagIndexes[i] tag, exists := tagMap[tagIndex] if !exists { diff --git a/pkg/converters/ezbookkeeping_tsv_file.go b/pkg/converters/ezbookkeeping_tsv_file.go index eeb6f4d9..8d613c62 100644 --- a/pkg/converters/ezbookkeeping_tsv_file.go +++ b/pkg/converters/ezbookkeeping_tsv_file.go @@ -12,6 +12,6 @@ type EzBookKeepingTSVFileExporter struct { const tsvSeparator = "\t" // ToExportedContent returns the exported TSV data -func (e *EzBookKeepingTSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { - return e.toExportedContent(uid, tsvSeparator, transactions, accountMap, categoryMap, tagMap, allTagIndexs) +func (e *EzBookKeepingTSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexes map[int64][]int64) ([]byte, error) { + return e.toExportedContent(uid, tsvSeparator, transactions, accountMap, categoryMap, tagMap, allTagIndexes) } diff --git a/pkg/services/transaction_tags.go b/pkg/services/transaction_tags.go index 679aa775..4586dbd8 100644 --- a/pkg/services/transaction_tags.go +++ b/pkg/services/transaction_tags.go @@ -122,10 +122,10 @@ func (s *TransactionTagService) GetAllTagIdsOfAllTransactions(c *core.Context, u return nil, errs.ErrUserIdInvalid } - var tagIndexs []*models.TransactionTagIndex - err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).Find(&tagIndexs) + var tagIndexes []*models.TransactionTagIndex + err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).Find(&tagIndexes) - return tagIndexs, err + return tagIndexes, err } // GetAllTagIdsMapOfAllTransactions returns all transaction tag ids map grouped by transaction id @@ -134,10 +134,10 @@ func (s *TransactionTagService) GetAllTagIdsMapOfAllTransactions(c *core.Context return nil, errs.ErrUserIdInvalid } - var tagIndexs []*models.TransactionTagIndex - err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).Find(&tagIndexs) + var tagIndexes []*models.TransactionTagIndex + err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).Find(&tagIndexes) - allTransactionTagIds := s.GetGroupedTransactionTagIds(tagIndexs) + allTransactionTagIds := s.GetGroupedTransactionTagIds(tagIndexes) return allTransactionTagIds, err } @@ -148,10 +148,10 @@ func (s *TransactionTagService) GetAllTagIdsOfTransactions(c *core.Context, uid return nil, errs.ErrUserIdInvalid } - var tagIndexs []*models.TransactionTagIndex - err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).In("transaction_id", transactionIds).Find(&tagIndexs) + var tagIndexes []*models.TransactionTagIndex + err := s.UserDataDB(uid).NewSession(c).Where("uid=? AND deleted=?", uid, false).In("transaction_id", transactionIds).Find(&tagIndexes) - allTransactionTagIds := s.GetGroupedTransactionTagIds(tagIndexs) + allTransactionTagIds := s.GetGroupedTransactionTagIds(tagIndexes) return allTransactionTagIds, err } @@ -343,18 +343,18 @@ func (s *TransactionTagService) ExistsTagName(c *core.Context, uid int64, name s } // ModifyTagIndexTransactionTime updates transaction time of given transaction tag indexes -func (s *TransactionTagService) ModifyTagIndexTransactionTime(c *core.Context, uid int64, tagIndexs []*models.TransactionTagIndex) error { +func (s *TransactionTagService) ModifyTagIndexTransactionTime(c *core.Context, uid int64, tagIndexes []*models.TransactionTagIndex) error { if uid <= 0 { return errs.ErrUserIdInvalid } - for i := 0; i < len(tagIndexs); i++ { - tagIndexs[i].UpdatedUnixTime = time.Now().Unix() + for i := 0; i < len(tagIndexes); i++ { + tagIndexes[i].UpdatedUnixTime = time.Now().Unix() } return s.UserDataDB(uid).DoTransaction(c, func(sess *xorm.Session) error { - for i := 0; i < len(tagIndexs); i++ { - tagIndex := tagIndexs[i] + for i := 0; i < len(tagIndexes); i++ { + tagIndex := tagIndexes[i] updatedRows, err := sess.ID(tagIndex.TagIndexId).Cols("transaction_time", "updated_unix_time").Where("uid=? AND deleted=?", uid, false).Update(tagIndex) if err != nil { @@ -379,11 +379,11 @@ func (s *TransactionTagService) GetTagMapByList(tags []*models.TransactionTag) m return tagMap } -func (s *TransactionTagService) GetGroupedTransactionTagIds(tagIndexs []*models.TransactionTagIndex) map[int64][]int64 { +func (s *TransactionTagService) GetGroupedTransactionTagIds(tagIndexes []*models.TransactionTagIndex) map[int64][]int64 { allTransactionTagIds := make(map[int64][]int64) - for i := 0; i < len(tagIndexs); i++ { - tagIndex := tagIndexs[i] + for i := 0; i < len(tagIndexes); i++ { + tagIndex := tagIndexes[i] var transactionTagIds []int64 diff --git a/pkg/services/transactions.go b/pkg/services/transactions.go index 8c333692..375ac975 100644 --- a/pkg/services/transactions.go +++ b/pkg/services/transactions.go @@ -235,7 +235,7 @@ func (s *TransactionService) CreateTransaction(c *core.Context, transaction *mod transaction.UpdatedUnixTime = now tagIds = utils.ToUniqueInt64Slice(tagIds) - transactionTagIndexs := make([]*models.TransactionTagIndex, len(tagIds)) + transactionTagIndexes := make([]*models.TransactionTagIndex, len(tagIds)) for i := 0; i < len(tagIds); i++ { tagIndexId := s.GenerateUuid(uuid.UUID_TYPE_TAG_INDEX) @@ -244,7 +244,7 @@ func (s *TransactionService) CreateTransaction(c *core.Context, transaction *mod return errs.ErrSystemIsBusy } - transactionTagIndexs[i] = &models.TransactionTagIndex{ + transactionTagIndexes[i] = &models.TransactionTagIndex{ TagIndexId: tagIndexId, Uid: transaction.Uid, Deleted: false, @@ -280,7 +280,7 @@ func (s *TransactionService) CreateTransaction(c *core.Context, transaction *mod } // Get and verify tags - err = s.isTagsValid(sess, transaction, transactionTagIndexs, tagIds) + err = s.isTagsValid(sess, transaction, transactionTagIndexes, tagIds) if err != nil { return err @@ -353,9 +353,9 @@ func (s *TransactionService) CreateTransaction(c *core.Context, transaction *mod err = nil // Insert transaction tag index - if len(transactionTagIndexs) > 0 { - for i := 0; i < len(transactionTagIndexs); i++ { - transactionTagIndex := transactionTagIndexs[i] + if len(transactionTagIndexes) > 0 { + for i := 0; i < len(transactionTagIndexes); i++ { + transactionTagIndex := transactionTagIndexes[i] transactionTagIndex.TransactionTime = transaction.TransactionTime _, err := sess.Insert(transactionTagIndex) @@ -437,7 +437,7 @@ func (s *TransactionService) ModifyTransaction(c *core.Context, transaction *mod addTagIds = utils.ToUniqueInt64Slice(addTagIds) removeTagIds = utils.ToUniqueInt64Slice(removeTagIds) - transactionTagIndexs := make([]*models.TransactionTagIndex, len(addTagIds)) + transactionTagIndexes := make([]*models.TransactionTagIndex, len(addTagIds)) for i := 0; i < len(addTagIds); i++ { tagIndexId := s.GenerateUuid(uuid.UUID_TYPE_TAG_INDEX) @@ -446,7 +446,7 @@ func (s *TransactionService) ModifyTransaction(c *core.Context, transaction *mod return errs.ErrSystemIsBusy } - transactionTagIndexs[i] = &models.TransactionTagIndex{ + transactionTagIndexes[i] = &models.TransactionTagIndex{ TagIndexId: tagIndexId, Uid: transaction.Uid, Deleted: false, @@ -587,7 +587,7 @@ func (s *TransactionService) ModifyTransaction(c *core.Context, transaction *mod } // Get and verify tags - err = s.isTagsValid(sess, transaction, transactionTagIndexs, addTagIds) + err = s.isTagsValid(sess, transaction, transactionTagIndexes, addTagIds) if err != nil { return err @@ -635,9 +635,9 @@ func (s *TransactionService) ModifyTransaction(c *core.Context, transaction *mod } } - if len(transactionTagIndexs) > 0 { - for i := 0; i < len(transactionTagIndexs); i++ { - transactionTagIndex := transactionTagIndexs[i] + if len(transactionTagIndexes) > 0 { + for i := 0; i < len(transactionTagIndexes); i++ { + transactionTagIndex := transactionTagIndexes[i] transactionTagIndex.TransactionTime = transaction.TransactionTime _, err := sess.Insert(transactionTagIndex) @@ -646,7 +646,7 @@ func (s *TransactionService) ModifyTransaction(c *core.Context, transaction *mod return err } } - } else if len(transactionTagIndexs) == 0 && currentTagIdsCount > 0 && modifyTransactionTime { + } else if len(transactionTagIndexes) == 0 && currentTagIdsCount > 0 && modifyTransactionTime { tagIndexUpdateModel := &models.TransactionTagIndex{ TransactionTime: transaction.TransactionTime, } @@ -1649,8 +1649,8 @@ func (s *TransactionService) isCategoryValid(sess *xorm.Session, transaction *mo return nil } -func (s *TransactionService) isTagsValid(sess *xorm.Session, transaction *models.Transaction, transactionTagIndexs []*models.TransactionTagIndex, tagIds []int64) error { - if len(transactionTagIndexs) > 0 { +func (s *TransactionService) isTagsValid(sess *xorm.Session, transaction *models.Transaction, transactionTagIndexes []*models.TransactionTagIndex, tagIds []int64) error { + if len(transactionTagIndexes) > 0 { var tags []*models.TransactionTag err := sess.Where("uid=? AND deleted=?", transaction.Uid, false).In("tag_id", tagIds).Find(&tags) @@ -1664,8 +1664,8 @@ func (s *TransactionService) isTagsValid(sess *xorm.Session, transaction *models tagMap[tags[i].TagId] = tags[i] } - for i := 0; i < len(transactionTagIndexs); i++ { - if _, exists := tagMap[transactionTagIndexs[i].TagId]; !exists { + for i := 0; i < len(transactionTagIndexes); i++ { + if _, exists := tagMap[transactionTagIndexes[i].TagId]; !exists { return errs.ErrTransactionTagNotFound } }