package global import ( "github.com/redis/go-redis/v9" "github.com/songzhibin97/gkit/cache/local_cache" "golang.org/x/sync/singleflight" "gorm.io/gorm" "lcfns/config" "time" ) var ( Db *gorm.DB GVA_REDIS *redis.Client BlackCache local_cache.Cache Config = config.Config GVA_Concurrency_Control = &singleflight.Group{} ) type GVA_MODEL struct { ID uint `gorm:"primarykey"` // 主键ID CreatedAt time.Time // 创建时间 UpdatedAt time.Time // 更新时间 DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间 } type DateTimeString time.Time const DateTimeFormatCN = "2006-01-02 15:04:05" func (t *DateTimeString) UnmarshalJSON(data []byte) (err error) { now, err := time.ParseInLocation(`"`+DateTimeFormatCN+`"`, string(data), time.Local) *t = DateTimeString(now) return } func (t *DateTimeString) MarshalJSON() ([]byte, error) { b := make([]byte, 0, len(DateTimeFormatCN)+2) b = append(b, '"') b = time.Time(*t).AppendFormat(b, DateTimeFormatCN) b = append(b, '"') return b, nil }