mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
added subscription edit
This commit is contained in:
@@ -4,11 +4,7 @@ import "github.com/gin-gonic/gin"
|
||||
|
||||
type FilteredResponse struct {
|
||||
Items interface{} `json:"items"`
|
||||
SortBy string `json:"sortBy"`
|
||||
Embed string `json:"embed"`
|
||||
Page int `json:"page"`
|
||||
Rpp int `json:"rpp"`
|
||||
TotalRecords int `json:"totalRecords"`
|
||||
Params
|
||||
}
|
||||
|
||||
type ResponseFunc func(*gin.Context) *[]interface{}
|
||||
@@ -16,3 +12,11 @@ type ResponseFunc func(*gin.Context) *[]interface{}
|
||||
type MessageResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type Params struct {
|
||||
SortBy string `json:"sortBy"`
|
||||
Embed string `json:"embed"`
|
||||
Page int `json:"page"`
|
||||
Rpp int `json:"rpp"`
|
||||
TotalRecords int `json:"totalRecords"`
|
||||
}
|
||||
@@ -23,6 +23,16 @@ type Subscription struct {
|
||||
Amount float32 `json:"amount", pg:"amount,default:0"`
|
||||
}
|
||||
|
||||
type SubscriptionEdit struct {
|
||||
tableName struct{} `pg:"subscriptions,alias:subscriptions"`
|
||||
Id string `json:"id" form:"id"`
|
||||
Description string `json:"description" form:"description"`
|
||||
EndDate time.Time `json:"endDate" form:"endDate" `
|
||||
HasEnd bool `json:"hasEnd" form:"hasEnd"`
|
||||
WalletID string `json:"walletId" form:"walletId"`
|
||||
Amount json.Number `json:"amount" form:"amount"`
|
||||
}
|
||||
|
||||
type NewSubscriptionBody struct {
|
||||
WalletID string `json:"walletId" form:"walletId"`
|
||||
TransactionTypeID string `json:"transactionTypeId" form:"transactionTypeId"`
|
||||
@@ -60,7 +70,7 @@ func (cm *Subscription) HasNew() bool {
|
||||
}
|
||||
return false
|
||||
case "weekly":
|
||||
lastDate := time.Now().AddDate(0, 0, -(7*cm.CustomRange))
|
||||
lastDate := time.Now().AddDate(0, 0, -(7 * cm.CustomRange))
|
||||
if cm.LastTransactionDate.Before(lastDate) {
|
||||
return true
|
||||
}
|
||||
@@ -80,4 +90,4 @@ func (cm *Subscription) HasNew() bool {
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user