code refactor

This commit is contained in:
MaysWind
2021-03-28 19:58:58 +08:00
parent d034661734
commit f9066cb81d
6 changed files with 66 additions and 90 deletions
+20
View File
@@ -119,6 +119,12 @@ type TransactionListInMonthByPageRequest struct {
TrimTag bool `form:"trim_tag"`
}
// TransactionStatisticRequest represents all parameters of transaction statistic request
type TransactionStatisticRequest struct {
StartTime int64 `form:"start_time" binding:"min=0"`
EndTime int64 `form:"end_time" binding:"min=0"`
}
// TransactionGetRequest represents all parameters of transaction getting request
type TransactionGetRequest struct {
Id int64 `form:"id,string" binding:"required,min=1"`
@@ -170,6 +176,20 @@ type TransactionInfoPageWrapperResponse2 struct {
TotalCount int64 `json:"total_count"`
}
// TransactionStatisticResponse represents an item of transaction overview
type TransactionStatisticResponse struct {
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
Items []*TransactionStatisticResponseItem `json:"items"`
}
// TransactionStatisticResponseItem represents total amount item for an response
type TransactionStatisticResponseItem struct {
CategoryId int64 `json:"categoryId,string"`
AccountId int64 `json:"accountId,string"`
TotalAmount int64 `json:"amount"`
}
// IsEditable returns whether this transaction can be edited
func (t *Transaction) IsEditable(currentUser *User, utcOffset int16, account *Account, relatedAccount *Account) bool {
if currentUser == nil || !currentUser.CanEditTransactionByTransactionTime(t.TransactionTime, utcOffset) {