mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
add transaction detail page
This commit is contained in:
@@ -59,7 +59,7 @@ type TransactionModifyRequest struct {
|
||||
|
||||
// TransactionListByMaxTimeRequest represents all parameters of transaction listing by max time request
|
||||
type TransactionListByMaxTimeRequest struct {
|
||||
MaxTime int64 `form:"max_time" binding:"required,min=1"`
|
||||
MaxTime int64 `form:"max_time" binding:"min=0"`
|
||||
Count int `form:"count" binding:"required,min=1,max=50"`
|
||||
}
|
||||
|
||||
@@ -134,5 +134,9 @@ func (c TransactionInfoResponseSlice) Swap(i, j int) {
|
||||
|
||||
// Less reports whether the first item is less than the second one
|
||||
func (c TransactionInfoResponseSlice) Less(i, j int) bool {
|
||||
return c[i].Time < c[j].Time
|
||||
if c[i].Time != c[j].Time {
|
||||
return c[i].Time > c[j].Time
|
||||
}
|
||||
|
||||
return c[i].Id > c[j].Id
|
||||
}
|
||||
|
||||
@@ -42,7 +42,13 @@ func (s *TransactionService) GetTransactionsByMaxTime(uid int64, maxTime int64,
|
||||
}
|
||||
|
||||
var transactions []*models.Transaction
|
||||
err := s.UserDataDB(uid).Where("uid=? AND deleted=? AND transaction_time<=?", uid, false, maxTime).Limit(count, 0).OrderBy("transaction_time desc").Find(&transactions)
|
||||
var err error
|
||||
|
||||
if maxTime > 0 {
|
||||
err = s.UserDataDB(uid).Where("uid=? AND deleted=? AND transaction_time<=?", uid, false, maxTime).Limit(count, 0).OrderBy("transaction_time desc").Find(&transactions)
|
||||
} else {
|
||||
err = s.UserDataDB(uid).Where("uid=? AND deleted=?", uid, false).Limit(count, 0).OrderBy("transaction_time desc").Find(&transactions)
|
||||
}
|
||||
|
||||
return transactions, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user