mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
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)
|
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 {
|
for yearMonth, monthlyTotalAmounts := range allMonthlyTotalAmounts {
|
||||||
monthlyStatisticResp := &models.TransactionStatisticTrendsItem{
|
monthlyStatisticResp := &models.TransactionStatisticTrendsResponseItem{
|
||||||
Year: yearMonth / 100,
|
Year: yearMonth / 100,
|
||||||
Month: yearMonth % 100,
|
Month: yearMonth % 100,
|
||||||
Items: make([]*models.TransactionStatisticResponseItem, len(monthlyTotalAmounts)),
|
Items: make([]*models.TransactionStatisticResponseItem, len(monthlyTotalAmounts)),
|
||||||
|
|||||||
@@ -311,8 +311,8 @@ type TransactionStatisticResponseItem struct {
|
|||||||
TotalAmount int64 `json:"amount"`
|
TotalAmount int64 `json:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionStatisticTrendsItem represents the data within each statistic interval
|
// TransactionStatisticTrendsResponseItem represents the data within each statistic interval
|
||||||
type TransactionStatisticTrendsItem struct {
|
type TransactionStatisticTrendsResponseItem struct {
|
||||||
Year int32 `json:"year"`
|
Year int32 `json:"year"`
|
||||||
Month int32 `json:"month"`
|
Month int32 `json:"month"`
|
||||||
Items []*TransactionStatisticResponseItem `json:"items"`
|
Items []*TransactionStatisticResponseItem `json:"items"`
|
||||||
@@ -493,21 +493,21 @@ func (s TransactionInfoResponseSlice) Less(i, j int) bool {
|
|||||||
return s[i].Id > s[j].Id
|
return s[i].Id > s[j].Id
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionStatisticTrendsItemSlice represents the slice data structure of TransactionStatisticTrendsItem
|
// TransactionStatisticTrendsResponseItemSlice represents the slice data structure of TransactionStatisticTrendsResponseItem
|
||||||
type TransactionStatisticTrendsItemSlice []*TransactionStatisticTrendsItem
|
type TransactionStatisticTrendsResponseItemSlice []*TransactionStatisticTrendsResponseItem
|
||||||
|
|
||||||
// Len returns the count of items
|
// Len returns the count of items
|
||||||
func (s TransactionStatisticTrendsItemSlice) Len() int {
|
func (s TransactionStatisticTrendsResponseItemSlice) Len() int {
|
||||||
return len(s)
|
return len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap swaps two items
|
// 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]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Less reports whether the first item is less than the second one
|
// 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 {
|
if s[i].Year != s[j].Year {
|
||||||
return 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)
|
assert.Equal(t, int64(4), transactionRespSlice[4].Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTransactionStatisticTrendsItemSliceLess(t *testing.T) {
|
func TestTransactionStatisticTrendsResponseItemSliceLess(t *testing.T) {
|
||||||
var transactionTrendsSlice TransactionStatisticTrendsItemSlice
|
var transactionTrendsSlice TransactionStatisticTrendsResponseItemSlice
|
||||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||||
Year: 2024,
|
Year: 2024,
|
||||||
Month: 9,
|
Month: 9,
|
||||||
})
|
})
|
||||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||||
Year: 2022,
|
Year: 2022,
|
||||||
Month: 10,
|
Month: 10,
|
||||||
})
|
})
|
||||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||||
Year: 2023,
|
Year: 2023,
|
||||||
Month: 1,
|
Month: 1,
|
||||||
})
|
})
|
||||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||||
Year: 2022,
|
Year: 2022,
|
||||||
Month: 2,
|
Month: 2,
|
||||||
})
|
})
|
||||||
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsItem{
|
transactionTrendsSlice = append(transactionTrendsSlice, &TransactionStatisticTrendsResponseItem{
|
||||||
Year: 2024,
|
Year: 2024,
|
||||||
Month: 1,
|
Month: 1,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user