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 {
monthTotalAmount = &models.TransactionAmountsResponseItemAmountInfo{
Currency: account.Currency,
IncomeAmount: 0,
Currency: account.Currency,
IncomeAmount: 0,
ExpenseAmount: 0,
}
}
@@ -433,8 +433,8 @@ func (a *TransactionsApi) TransactionMonthAmountsHandler(c *core.Context) (inter
}
amountsResp = append(amountsResp, &models.TransactionMonthAmountsResponseItem{
Year: year,
Month: month,
Year: year,
Month: month,
Amounts: amounts,
})
}
+2 -2
View File
@@ -132,8 +132,8 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
anythingUpdate := false
userNew := &models.User{
Uid: user.Uid,
Salt: user.Salt,
Uid: user.Uid,
Salt: user.Salt,
}
if userUpdateReq.Email != "" && userUpdateReq.Email != user.Email {
@@ -8,8 +8,8 @@ import (
"github.com/mayswind/lab/pkg/errs"
"github.com/mayswind/lab/pkg/log"
"github.com/mayswind/lab/pkg/models"
"github.com/mayswind/lab/pkg/validators"
"github.com/mayswind/lab/pkg/utils"
"github.com/mayswind/lab/pkg/validators"
)
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.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
Currency: "USD",
Rate: "1.1746",
Rate: "1.1746",
})
assert.Contains(t, actualLatestExchangeRateResponse.ExchangeRates, &models.LatestExchangeRate{
Currency: "CNY",
Rate: "7.7195",
Rate: "7.7195",
})
}
@@ -75,8 +75,8 @@ func TestEuroCentralBankDataSource_EmptyEnvelopeContent(t *testing.T) {
Context: &gin.Context{},
}
_, 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\">" +
_, 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>"))
assert.NotEqual(t, nil, err)
}
@@ -87,10 +87,10 @@ func TestEuroCentralBankDataSource_EmptyCubeContent(t *testing.T) {
Context: &gin.Context{},
}
_, 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\">" +
"<Cube>" +
"</Cube>" +
_, 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\">"+
"<Cube>"+
"</Cube>"+
"</gesmes:Envelope>"))
assert.NotEqual(t, nil, err)
}
@@ -101,13 +101,13 @@ func TestEuroCentralBankDataSource_InvalidCurrency(t *testing.T) {
Context: &gin.Context{},
}
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\">" +
"<Cube>" +
"<Cube time=\"2021-04-01\">" +
"<Cube currency=\"XXX\" rate=\"1\" />" +
"</Cube>" +
"</Cube>" +
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\">"+
"<Cube>"+
"<Cube time=\"2021-04-01\">"+
"<Cube currency=\"XXX\" rate=\"1\" />"+
"</Cube>"+
"</Cube>"+
"</gesmes:Envelope>"))
assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
@@ -119,13 +119,13 @@ func TestEuroCentralBankDataSource_EmptyRate(t *testing.T) {
Context: &gin.Context{},
}
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\">" +
"<Cube>" +
"<Cube time=\"2021-04-01\">" +
"<Cube currency=\"USD\" rate=\"\" />" +
"</Cube>" +
"</Cube>" +
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\">"+
"<Cube>"+
"<Cube time=\"2021-04-01\">"+
"<Cube currency=\"USD\" rate=\"\" />"+
"</Cube>"+
"</Cube>"+
"</gesmes:Envelope>"))
assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
@@ -137,13 +137,13 @@ func TestEuroCentralBankDataSource_InvalidRate(t *testing.T) {
Context: &gin.Context{},
}
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\">" +
"<Cube>" +
"<Cube time=\"2021-04-01\">" +
"<Cube currency=\"USD\" rate=\"null\" />" +
"</Cube>" +
"</Cube>" +
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\">"+
"<Cube>"+
"<Cube time=\"2021-04-01\">"+
"<Cube currency=\"USD\" rate=\"null\" />"+
"</Cube>"+
"</Cube>"+
"</gesmes:Envelope>"))
assert.Equal(t, nil, err)
assert.Len(t, actualLatestExchangeRateResponse.ExchangeRates, 0)
+2 -2
View File
@@ -1019,8 +1019,8 @@ func (s *TransactionService) GetAccountsMonthTotalIncomeAndExpense(uid int64, st
if !exists {
monthAccountAmount = &models.TransactionAccountAmount{
AccountId: transaction.AccountId,
TotalIncomeAmount: 0,
AccountId: transaction.AccountId,
TotalIncomeAmount: 0,
TotalExpenseAmount: 0,
}
monthAccountsAmounts[transaction.AccountId] = monthAccountAmount