Skip to content
Permalink
Browse files

replace time to zone

Signed-off-by: Toby Yan <me@tobyan.com>
  • Loading branch information...
toby1991 committed May 15, 2019
1 parent e216325 commit fbbad3c1ca94dd7d7ebb13baba6167c6369dcde0
@@ -2,7 +2,6 @@ package middleware

import (
"log"
"time"

"github.com/gin-gonic/gin"

@@ -21,7 +20,7 @@ func Example() gin.HandlerFunc {
c.Next()

// after request
latency := time.Since(t)
latency := zone.Since(t)
log.Print(latency)

// access the status we are sending
@@ -1,10 +1,10 @@
package models

import (
"time"

"github.com/gin-gonic/gin"

"github.com/totoval/framework/helpers/zone"

"github.com/totoval/framework/helpers/m"
"github.com/totoval/framework/helpers/pb"
"github.com/totoval/framework/model"
@@ -19,15 +19,15 @@ type FailedQueue struct {
Topic *string `gorm:"column:failed_queue_topic_name;type:varchar(100);not null"`
Channel *string `gorm:"column:failed_queue_channel_name;type:varchar(100);not null"`
DataProto *[]byte `gorm:"column:failed_queue_data;type:varbinary"`
PushedAt *time.Time `gorm:"column:failed_queue_pushed_at;not null"`
Delay *time.Duration `gorm:"column:failed_queue_delay;type:bigint;not null"`
PushedAt *zone.Time `gorm:"column:failed_queue_pushed_at;not null"`
Delay *zone.Duration `gorm:"column:failed_queue_delay;type:bigint;not null"`
Retries *uint32 `gorm:"column:failed_queue_retries;type:integer unsigned;not null"`
Tried *uint32 `gorm:"column:failed_queue_tried;type:integer unsigned;not null"`
Err *string `gorm:"column:failed_queue_err;size:65535"`

CreatedAt *time.Time `gorm:"column:failed_queue_created_at"`
UpdatedAt time.Time `gorm:"column:failed_queue_updated_at"`
DeletedAt *time.Time `gorm:"column:failed_queue_deleted_at"`
CreatedAt *zone.Time `gorm:"column:failed_queue_created_at"`
UpdatedAt zone.Time `gorm:"column:failed_queue_updated_at"`
DeletedAt *zone.Time `gorm:"column:failed_queue_deleted_at"`
model.BaseModel
}

@@ -46,7 +46,7 @@ func (fq *FailedQueue) RetryRetries() uint32 {
return *fq.Retries
}

func (fq *FailedQueue) RetryDelay() time.Duration {
func (fq *FailedQueue) RetryDelay() zone.Duration {
return *fq.Delay
}

@@ -1,11 +1,10 @@
package models

import (
"time"

"github.com/gin-gonic/gin"

"github.com/totoval/framework/helpers/m"
"github.com/totoval/framework/helpers/zone"
"github.com/totoval/framework/model"
)

@@ -14,9 +13,9 @@ type User struct {
Name *string `gorm:"column:user_name;type:varchar(100)"`
Email *string `gorm:"column:user_email;type:varchar(100);unique_index;not null"`
Password *string `gorm:"column:user_password;type:varchar(100);not null"`
CreatedAt *time.Time `gorm:"column:user_created_at"`
UpdatedAt time.Time `gorm:"column:user_updated_at"`
DeletedAt *time.Time `gorm:"column:user_deleted_at"`
CreatedAt *zone.Time `gorm:"column:user_created_at"`
UpdatedAt zone.Time `gorm:"column:user_updated_at"`
DeletedAt *zone.Time `gorm:"column:user_deleted_at"`
model.BaseModel
}

@@ -4,13 +4,13 @@ import (
"errors"
"fmt"
"math"
"time"

"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"

"github.com/totoval/framework/helpers/debug"
"github.com/totoval/framework/helpers/ptr"
"github.com/totoval/framework/helpers/zone"

"github.com/totoval/framework/model/helper"

@@ -29,9 +29,9 @@ type UserAffiliation struct {
Left *uint `gorm:"column:uaff_left_id;type:int unsigned;not null"`
Right *uint `gorm:"column:uaff_right_id;type:int unsigned;not null"`
Level *uint `gorm:"column:uaff_level;type:int unsigned;not null"`
CreatedAt *time.Time `gorm:"column:user_created_at"`
UpdatedAt time.Time `gorm:"column:user_updated_at"`
DeletedAt *time.Time `gorm:"column:user_deleted_at"`
CreatedAt *zone.Time `gorm:"column:user_created_at"`
UpdatedAt zone.Time `gorm:"column:user_updated_at"`
DeletedAt *zone.Time `gorm:"column:user_deleted_at"`
model.BaseModel
}

@@ -4,9 +4,8 @@ import (
"github.com/jinzhu/gorm"

"github.com/totoval/framework/database/migration"
"github.com/totoval/framework/helpers/zone"
"github.com/totoval/framework/model"

"time"
)

func init() {
@@ -20,15 +19,15 @@ type FailedQueue struct {
Topic *string `gorm:"column:failed_queue_topic_name;type:varchar(100);not null"`
Channel *string `gorm:"column:failed_queue_channel_name;type:varchar(100);not null"`
DataProto *[]byte `gorm:"column:failed_queue_data;type:varbinary(2048)"`
PushedAt *time.Time `gorm:"column:failed_queue_pushed_at;not null"`
Delay *time.Duration `gorm:"column:failed_queue_delay;type:bigint unsigned;not null"`
PushedAt *zone.Time `gorm:"column:failed_queue_pushed_at;not null"`
Delay *zone.Duration `gorm:"column:failed_queue_delay;type:bigint unsigned;not null"`
Retries *uint32 `gorm:"column:failed_queue_retries;type:integer unsigned;not null"`
Tried *uint32 `gorm:"column:failed_queue_tried;type:integer unsigned;not null"`
Err *string `gorm:"column:failed_queue_err;size:65535"`

CreatedAt *time.Time `gorm:"column:failed_queue_created_at"`
UpdatedAt time.Time `gorm:"column:failed_queue_updated_at"`
DeletedAt *time.Time `gorm:"column:failed_queue_deleted_at"`
CreatedAt *zone.Time `gorm:"column:failed_queue_created_at"`
UpdatedAt zone.Time `gorm:"column:failed_queue_updated_at"`
DeletedAt *zone.Time `gorm:"column:failed_queue_deleted_at"`
model.BaseModel
}

@@ -1,11 +1,10 @@
package migrations

import (
"time"

"github.com/jinzhu/gorm"

"github.com/totoval/framework/database/migration"
"github.com/totoval/framework/helpers/zone"
"github.com/totoval/framework/model"
)

@@ -22,9 +21,9 @@ type UserAffiliation struct {
Left *uint `gorm:"column:uaff_left_id;type:int unsigned;not null"`
Right *uint `gorm:"column:uaff_right_id;type:int unsigned;not null"`
Level *uint `gorm:"column:uaff_level;type:int unsigned;not null"`
CreatedAt *time.Time `gorm:"column:user_created_at"`
UpdatedAt time.Time `gorm:"column:user_updated_at"`
DeletedAt *time.Time `gorm:"column:user_deleted_at"`
CreatedAt *zone.Time `gorm:"column:user_created_at"`
UpdatedAt zone.Time `gorm:"column:user_updated_at"`
DeletedAt *zone.Time `gorm:"column:user_deleted_at"`
model.BaseModel
}

@@ -4,9 +4,8 @@ import (
"github.com/jinzhu/gorm"

"github.com/totoval/framework/database/migration"
"github.com/totoval/framework/helpers/zone"
"github.com/totoval/framework/model"

"time"
)

func init() {
@@ -18,9 +17,9 @@ type User struct {
Name *string `gorm:"column:user_name;type:varchar(100)"` //@cautions struct member must be pointer when member could be null
Email *string `gorm:"column:user_email;type:varchar(100);unique_index;not null"`
Password *string `gorm:"column:user_password;type:varchar(100);not null"`
CreatedAt *time.Time `gorm:"column:user_created_at"`
UpdatedAt time.Time `gorm:"column:user_updated_at"`
DeletedAt *time.Time `gorm:"column:user_deleted_at"`
CreatedAt *zone.Time `gorm:"column:user_created_at"`
UpdatedAt zone.Time `gorm:"column:user_updated_at"`
DeletedAt *zone.Time `gorm:"column:user_deleted_at"`
model.BaseModel
}

2 go.mod
@@ -9,7 +9,7 @@ require (
github.com/go-playground/universal-translator v0.16.0
github.com/golang/protobuf v1.3.1
github.com/jinzhu/gorm v1.9.2
github.com/totoval/framework v0.5.2
github.com/totoval/framework v0.5.2-hotfix-2
github.com/ugorji/go/codec v0.0.0-20190204201341-e444a5086c43 // indirect
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd // indirect
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect

0 comments on commit fbbad3c

Please sign in to comment.
You can’t perform that action at this time.