mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
use timestamp instead of timestamptz
This commit is contained in:
@@ -9,8 +9,8 @@ type Subscription struct {
|
|||||||
tableName struct{} `pg:"subscriptions,alias:subscriptions"`
|
tableName struct{} `pg:"subscriptions,alias:subscriptions"`
|
||||||
BaseModel
|
BaseModel
|
||||||
Description string `json:"description" pg:"description"`
|
Description string `json:"description" pg:"description"`
|
||||||
StartDate time.Time `json:"startDate" pg:"start_date"`
|
StartDate time.Time `json:"startDate" pg:"start_date", type:timestamp`
|
||||||
EndDate time.Time `json:"endDate" pg:"end_date"`
|
EndDate time.Time `json:"endDate" pg:"end_date", type:timestamp`
|
||||||
HasEnd bool `json:"hasEnd" pg:"hasEnd"`
|
HasEnd bool `json:"hasEnd" pg:"hasEnd"`
|
||||||
SubscriptionTypeID string `json:"subscriptionTypeId" pg:"subscription_type_id"`
|
SubscriptionTypeID string `json:"subscriptionTypeId" pg:"subscription_type_id"`
|
||||||
SubscriptionType *SubscriptionType `json:"subscriptionType", pg:"rel:has-one, fk:subscription_type_id"`
|
SubscriptionType *SubscriptionType `json:"subscriptionType", pg:"rel:has-one, fk:subscription_type_id"`
|
||||||
@@ -19,7 +19,7 @@ type Subscription struct {
|
|||||||
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
|
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
|
||||||
TransactionTypeID string `json:"transactionTypeId", pg:"transaction_type_id"`
|
TransactionTypeID string `json:"transactionTypeId", pg:"transaction_type_id"`
|
||||||
TransactionType *TransactionType `json:"transactionType", pg:"rel:has-one, fk:transaction_type_id"`
|
TransactionType *TransactionType `json:"transactionType", pg:"rel:has-one, fk:transaction_type_id"`
|
||||||
LastTransactionDate time.Time `json:"lastTransactionDate", pg:"last_transaction_date"`
|
LastTransactionDate time.Time `json:"lastTransactionDate", pg:"last_transaction_date", type:timestamp`
|
||||||
Amount float32 `json:"amount", pg:"amount"`
|
Amount float32 `json:"amount", pg:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type Transaction struct {
|
|||||||
WalletID string `json:"walletId", pg:"wallet_id"`
|
WalletID string `json:"walletId", pg:"wallet_id"`
|
||||||
Amount float32 `json:"amount", pg:"amount"`
|
Amount float32 `json:"amount", pg:"amount"`
|
||||||
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
|
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
|
||||||
TransactionDate time.Time `json:"transactionDate" pg:"transaction_date"`
|
TransactionDate time.Time `json:"transactionDate" pg:"transaction_date, type:timestamp"`
|
||||||
SubscriptionID string `json:"subscriptionId", pg:"subscription_id"`
|
SubscriptionID string `json:"subscriptionId", pg:"subscription_id"`
|
||||||
Subscription *Subscription `json:"subscription", pg:"rel:has-one, fk:subscription_id"`
|
Subscription *Subscription `json:"subscription", pg:"rel:has-one, fk:subscription_id"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ func (as *SubscriptionService) New(body *models.NewSubscriptionBody) *models.Sub
|
|||||||
tm.SubscriptionTypeID = body.SubscriptionTypeID
|
tm.SubscriptionTypeID = body.SubscriptionTypeID
|
||||||
tm.CustomRange = int(customRange)
|
tm.CustomRange = int(customRange)
|
||||||
tm.Description = body.Description
|
tm.Description = body.Description
|
||||||
tm.StartDate = body.StartDate
|
tm.StartDate = body.StartDate.Local()
|
||||||
tm.HasEnd = body.HasEnd
|
tm.HasEnd = body.HasEnd
|
||||||
tm.EndDate = body.EndDate
|
tm.EndDate = body.EndDate.Local()
|
||||||
tm.Amount = float32(math.Round(amount*100) / 100)
|
tm.Amount = float32(math.Round(amount*100) / 100)
|
||||||
|
|
||||||
if body.StartDate.IsZero() {
|
if body.StartDate.IsZero() {
|
||||||
|
|||||||
Reference in New Issue
Block a user