modify struct name
This commit is contained in:
@@ -382,10 +382,10 @@ func (a *TransactionsApi) TransactionStatisticsTrendsHandler(c *core.WebContext)
|
||||
return nil, errs.Or(err, errs.ErrOperationFailed)
|
||||
}
|
||||
|
||||
statisticTrendsResp := make(models.TransactionStatisticTrendsItemSlice, 0, len(allMonthlyTotalAmounts))
|
||||
statisticTrendsResp := make(models.TransactionStatisticTrendsResponseItemSlice, 0, len(allMonthlyTotalAmounts))
|
||||
|
||||
for yearMonth, monthlyTotalAmounts := range allMonthlyTotalAmounts {
|
||||
monthlyStatisticResp := &models.TransactionStatisticTrendsItem{
|
||||
monthlyStatisticResp := &models.TransactionStatisticTrendsResponseItem{
|
||||
Year: yearMonth / 100,
|
||||
Month: yearMonth % 100,
|
||||
Items: make([]*models.TransactionStatisticResponseItem, len(monthlyTotalAmounts)),
|
||||
|
||||
@@ -311,8 +311,8 @@ type TransactionStatisticResponseItem struct {
|
||||
TotalAmount int64 `json:"amount"`
|
||||
}
|
||||
|
||||
// TransactionStatisticTrendsItem represents the data within each statistic interval
|
||||
type TransactionStatisticTrendsItem struct {
|
||||
// TransactionStatisticTrendsResponseItem represents the data within each statistic interval
|
||||
type TransactionStatisticTrendsResponseItem struct {
|
||||
Year int32 `json:"year"`
|
||||
Month int32 `json:"month"`
|
||||
Items []*TransactionStatisticResponseItem `json:"items"`
|
||||
@@ -493,21 +493,21 @@ func (s TransactionInfoResponseSlice) Less(i, j int) bool {
|
||||
return s[i].Id > s[j].Id
|
||||
}
|
||||
|
||||
// TransactionStatisticTrendsItemSlice represents the slice data structure of TransactionStatisticTrendsItem
|
||||
type TransactionStatisticTrendsItemSlice []*TransactionStatisticTrendsItem
|
||||
// TransactionStatisticTrendsResponseItemSlice represents the slice data structure of TransactionStatisticTrendsResponseItem
|
||||
type TransactionStatisticTrendsResponseItemSlice []*TransactionStatisticTrendsResponseItem
|
||||
|
||||
// Len returns the count of items
|
||||
func (s TransactionStatisticTrendsItemSlice) Len() int {
|
||||
func (s TransactionStatisticTrendsResponseItemSlice) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Swap swaps two items
|
||||
func (s TransactionStatisticTrendsItemSlice) Swap(i, j int) {
|
||||
func (s TransactionStatisticTrendsResponseItemSlice) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
// Less reports whether the first item is less than the second one
|
||||
func (s TransactionStatisticTrendsItemSlice) Less(i, j int) bool {
|
||||
func (s TransactionStatisticTrendsResponseItemSlice) Less(i, j int) bool {
|
||||
if s[i].Year != s[j].Year {
|
||||
return s[i].Year < s[j].Year
|
||||
}
|
||||
|
||||
@@ -127,25 +127,25 @@ func TestTransactionInfoResponseSliceLess(t *testing.T) {
|
||||
assert.Equal(t, int64(4), transactionRespSlice[4].Id)
|
||||
}
|
||||
|
||||
func TestTransactionStatisticTrendsItemSliceLess(t *testing.T) {
|
||||
var transactionTrendsSlice TransactionStatisticTrendsItemSlice
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
||||
func TestTransactionStatisticTrendsResponseItemSliceLess(t *testing.T) {
|
||||
var transactionTrendsSlice TransactionStatisticTrendsResponseItemSlice
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||
Year: 2024,
|
||||
Month: 9,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||
Year: 2022,
|
||||
Month: 10,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||
Year: 2023,
|
||||
Month: 1,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||
Year: 2022,
|
||||
Month: 2,
|
||||
})
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||
Year: 2024,
|
||||
Month: 1,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user