use timestamp instead of timestamptz

This commit is contained in:
Fran Jurmanović
2021-06-27 10:29:22 +02:00
parent 2dded0a932
commit 5c6aad39cd
3 changed files with 6 additions and 6 deletions

View File

@@ -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"`
} }

View File

@@ -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"`
} }

View File

@@ -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() {