code format

This commit is contained in:
MaysWind
2021-04-05 01:45:09 +08:00
parent 7b51584c7c
commit e34e55eac7
5 changed files with 38 additions and 38 deletions
+4 -4
View File
@@ -395,8 +395,8 @@ func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (inter
if !exists { if !exists {
monthTotalAmount = &models.TransactionAmountsResponseItemAmountInfo{ monthTotalAmount = &models.TransactionAmountsResponseItemAmountInfo{
Currency: account.Currency, Currency: account.Currency,
IncomeAmount: 0, IncomeAmount: 0,
ExpenseAmount: 0, ExpenseAmount: 0,
} }
} }
@@ -433,8 +433,8 @@ func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (inter
} }
amountsResp = append(amountsResp, &models.TransactionMonthAmountsResponseItem{ amountsResp = append(amountsResp, &models.TransactionMonthAmountsResponseItem{
Year: year, Year: year,
Month: month, Month: month,
Amounts: amounts, Amounts: amounts,
}) })
} }
+2 -2
View File
@@ -132,8 +132,8 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
anythingUpdate := false anythingUpdate := false
userNew := &models.User{ userNew := &models.User{
Uid: user.Uid, Uid: user.Uid,
Salt: user.Salt, Salt: user.Salt,
} }
if userUpdateReq.Email != "" && userUpdateReq.Email != user.Email { if userUpdateReq.Email != "" && userUpdateReq.Email != user.Email {
@@ -8,8 +8,8 @@ import (
"github.com/mayswind/lab/pkg/errs" "github.com/mayswind/lab/pkg/errs"
"github.com/mayswind/lab/pkg/log" "github.com/mayswind/lab/pkg/log"
"github.com/mayswind/lab/pkg/models" "github.com/mayswind/lab/pkg/models"
"github.com/mayswind/lab/pkg/validators"
"github.com/mayswind/lab/pkg/utils" "github.com/mayswind/lab/pkg/utils"
"github.com/mayswind/lab/pkg/validators"
) )
const euroCentralBankExchangeRateUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml" const euroCentralBankExchangeRateUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
@@ -41,11 +41,11 @@ func TestEuroCentralBankDataSource_StandardDataExtractExchangeRates(t *testing.T
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{ assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
Currency: "USD", Currency: "USD",
Rate: "1.1746", Rate: "1.1746",
}) })
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{ assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
Currency: "CNY", Currency: "CNY",
Rate: "7.7195", Rate: "7.7195",
}) })
} }
@@ -75,8 +75,8 @@ func TestEuroCentralBankDataSource_EmptyEnvelopeContent(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + _, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.NotEqual(t, nil, err) assert.NotEqual(t, nil, err)
} }
@@ -87,10 +87,10 @@ func TestEuroCentralBankDataSource_EmptyCubeContent(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
_, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + _, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.NotEqual(t, nil, err) assert.NotEqual(t, nil, err)
} }
@@ -101,13 +101,13 @@ func TestEuroCentralBankDataSource_InvalidCurrency(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"<Cube time=\"2021-04-01\">" + "<Cube time=\"2021-04-01\">"+
"<Cube currency=\"XXX\" rate=\"1\" />" + "<Cube currency=\"XXX\" rate=\"1\" />"+
"</Cube>" + "</Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0) assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
@@ -119,13 +119,13 @@ func TestEuroCentralBankDataSource_EmptyRate(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"<Cube time=\"2021-04-01\">" + "<Cube time=\"2021-04-01\">"+
"<Cube currency=\"USD\" rate=\"\" />" + "<Cube currency=\"USD\" rate=\"\" />"+
"</Cube>" + "</Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0) assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
@@ -137,13 +137,13 @@ func TestEuroCentralBankDataSource_InvalidRate(t *testing.T) {
Context: &gin.Context{}, Context: &gin.Context{},
} }
actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + actualLatestExchangeRateResponse, err := dataSource.Parse(context, []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">" + "<gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">"+
"<Cube>" + "<Cube>"+
"<Cube time=\"2021-04-01\">" + "<Cube time=\"2021-04-01\">"+
"<Cube currency=\"USD\" rate=\"null\" />" + "<Cube currency=\"USD\" rate=\"null\" />"+
"</Cube>" + "</Cube>"+
"</Cube>" + "</Cube>"+
"</gesmes:Envelope>")) "</gesmes:Envelope>"))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0) assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
+2 -2
View File
@@ -1019,8 +1019,8 @@ func (s *TransactionService) GetAccountsMonthTotalIncomeAndExpense(uid int64, st
if !exists { if !exists {
monthAccountAmount = &models.TransactionAccountAmount{ monthAccountAmount = &models.TransactionAccountAmount{
AccountId: transaction.AccountId, AccountId: transaction.AccountId,
TotalIncomeAmount: 0, TotalIncomeAmount: 0,
TotalExpenseAmount: 0, TotalExpenseAmount: 0,
} }
monthAccountsAmounts[transaction.AccountId] = monthAccountAmount monthAccountsAmounts[transaction.AccountId] = monthAccountAmount