Documentation
¶
Index ¶
- func BlobDbDataType(db *gorm.DB, _ *schema.Field) string
- func CheckVersionSupportsJSON(versionStr string) bool
- func DriverScanWithInt[T constraints.Integer](val any, dst *T) error
- func DriverScanWithJson[T any](val any, dst *T) error
- func DriverValueWithJson(val any) (driver.Value, error)
- func HelperStringGormDBDataType(db *gorm.DB, field *schema.Field, length int) string
- func HelperStringScan[T ~string](val any, dst *T) error
- func JsonDbDataType(db *gorm.DB, _ *schema.Field) string
- func MapGormValue(data string, db *gorm.DB) clause.Expr
- type AnyArray
- type Array
- type Binary
- type Bool
- func (b Bool) Bool() bool
- func (b *Bool) Equals(b2 Bool) bool
- func (b *Bool) GobDecode(data []byte) error
- func (b Bool) GobEncode() ([]byte, error)
- func (Bool) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (b Bool) GormDataType() string
- func (b Bool) Int() int
- func (b Bool) MarshalJSON() ([]byte, error)
- func (b *Bool) Resverse()
- func (b *Bool) Scan(value any) error
- func (b *Bool) Set(b2 Bool)
- func (b *Bool) SetBool(b2 bool)
- func (b *Bool) SetInt(i int)
- func (b *Bool) SetString(s string)
- func (b *Bool) UnmarshalJSON(data []byte) error
- func (b Bool) Value() (driver.Value, error)
- type Byte
- type ContentType
- type CustomDate
- func (CustomDate) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (c CustomDate) GormDataType() string
- func (c CustomDate) MarshalJSON() ([]byte, error)
- func (c *CustomDate) Scan(value interface{}) (err error)
- func (c CustomDate) String() string
- func (c *CustomDate) UnmarshalJSON(b []byte) (err error)
- func (c CustomDate) Value() (driver.Value, error)
- type CustomTime
- func (c *CustomTime) AdjustTimezoneIfNeeded()
- func (CustomTime) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (c CustomTime) GormDataType() string
- func (c CustomTime) IsZero() bool
- func (c CustomTime) MarshalJSON() ([]byte, error)
- func (c *CustomTime) Scan(value interface{}) (err error)
- func (c CustomTime) String() string
- func (c CustomTime) ToPtr() *CustomTime
- func (c CustomTime) ToTime() time.Time
- func (c *CustomTime) UnmarshalJSON(b []byte) (err error)
- func (c CustomTime) Value() (driver.Value, error)
- type DynamicTime
- type IntString
- func (i IntString[T]) Equals(other IntString[T]) bool
- func (i IntString[T]) GetJsonAsString() bool
- func (i *IntString[T]) GetValid() bool
- func (i IntString[T]) GetValue() T
- func (i *IntString[T]) GobDecode(data []byte) error
- func (i IntString[T]) GobEncode() ([]byte, error)
- func (i IntString[T]) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (i IntString[T]) IsValid() bool
- func (i IntString[T]) IsZero() bool
- func (i IntString[T]) MarshalJSON() ([]byte, error)
- func (i *IntString[T]) Scan(val any) error
- func (i *IntString[T]) SetJsonAsString(asString bool)
- func (i *IntString[T]) SetValue(v T)
- func (i IntString[T]) String() string
- func (i *IntString[T]) UnmarshalJSON(data []byte) error
- func (i *IntString[T]) UnmarshalText(text []byte) error
- func (i IntString[T]) Value() (driver.Value, error)
- type JSONMap
- func (JSONMap) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (m JSONMap) GormDataType() string
- func (jm JSONMap) GormValue(_ context.Context, db *gorm.DB) clause.Expr
- func (m JSONMap) MarshalJSON() ([]byte, error)
- func (m *JSONMap) Scan(val any) error
- func (m *JSONMap) UnmarshalJSON(b []byte) error
- func (m JSONMap) Value() (driver.Value, error)
- type JSONRaw
- func (JSONRaw) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (JSONRaw) GormDataType() string
- func (js JSONRaw) GormValue(ctx context.Context, db *gorm.DB) clause.Expr
- func (js JSONRaw) MarshalJSON() ([]byte, error)
- func (j *JSONRaw) Scan(value interface{}) error
- func (js *JSONRaw) UnmarshalJSON(b []byte) error
- func (j JSONRaw) Value() (driver.Value, error)
- type SessionValue
- type String
- type StringArray
- type Timestamp
- func (t *Timestamp) Format(layout string) string
- func (t Timestamp) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (t Timestamp) GormDataType() string
- func (t *Timestamp) IsZero() bool
- func (t *Timestamp) MarshalJSON() ([]byte, error)
- func (t *Timestamp) Scan(value interface{}) error
- func (t *Timestamp) SetFormat(format string)
- func (t *Timestamp) SetTime(time time.Time)
- func (t *Timestamp) String() string
- func (t *Timestamp) Time() time.Time
- func (t *Timestamp) Unix() int64
- func (t *Timestamp) UnixMicro() int64
- func (t *Timestamp) UnixMilli() int64
- func (t *Timestamp) UnixNano() int64
- func (t *Timestamp) UnmarshalJSON(data []byte) error
- func (t Timestamp) Value() (driver.Value, error)
- type Uint64
- func (u *Uint64) Equals(other Uint64) bool
- func (u *Uint64) EqualsInt(other int) bool
- func (u *Uint64) EqualsUint64(other uint64) bool
- func (u *Uint64) GetValue() uint64
- func (u Uint64) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (u *Uint64) Scan(value any) error
- func (u *Uint64) SetValue(v uint64)
- func (u Uint64) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckVersionSupportsJSON ¶
CheckVersionSupportsJSON 检查版本是否支持JSON mysql版本高于 5.7.8 ,才支持json
func DriverScanWithInt ¶
func DriverScanWithInt[T constraints.Integer](val any, dst *T) error
func DriverScanWithJson ¶
DriverScanWithJson 解析json
func HelperStringScan ¶
HelperStringScan 通用的 string 自定义类型 SCAN函数
func MapGormValue ¶
MapGormValue 下面的操作是借鉴的 https://github.com/go-gorm/datatypes/blob/master/json_map.go#L94
Types ¶
type AnyArray ¶
type AnyArray[T any] []T
AnyArray 泛型版本的数组
func (AnyArray[T]) GormDBDataType ¶
noinspection all
type Array ¶
type Array []any
func (Array) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
type Binary ¶
type Binary []byte
func (Binary) GormDBDataType ¶
GormDBDataType 返回数据库特定的数据类型名称 noinspection all
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool 注意当使用这个类型时,在定义模型时,默认值需要带上括号。不然pg数据库会报错。
func (Bool) GormDBDataType ¶
noinspection all
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type ContentType ¶
type ContentType int
ContentType 表示检测到的内容类型
const ( Unknown ContentType = iota JSON PlainText CSV Excel )
func DetectContentType ¶
func DetectContentType(header http.Header) ContentType
DetectContentType 从 HTTP 请求头中检测内容类型
func (ContentType) GormDBDataType ¶
noinspection all
func (ContentType) String ¶
func (ct ContentType) String() string
String 返回内容类型的字符串表示 noinspection all
type CustomDate ¶
func (CustomDate) GormDBDataType ¶
noinspection all
func (*CustomDate) UnmarshalJSON ¶
func (c *CustomDate) UnmarshalJSON(b []byte) (err error)
noinspection all
type CustomTime ¶
func NewCustomTime ¶
func NewCustomTime(t time.Time) CustomTime
func NewCustomTimeNow ¶
func NewCustomTimeNow() CustomTime
func (*CustomTime) AdjustTimezoneIfNeeded ¶
func (c *CustomTime) AdjustTimezoneIfNeeded()
AdjustTimezoneIfNeeded 调整时区 noinspection all
func (CustomTime) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
func (CustomTime) GormDataType ¶
func (c CustomTime) GormDataType() string
GormDataType 这个时间自定义字段,只能用time类型,不然当表中设置有 autoUpdateTime控制属性时会有问题。 使用Update方法,只有DataType是time的时候,才会生成time.Time类型, 其他类型都会转成时间戳。 noinspection all
func (CustomTime) MarshalJSON ¶
func (c CustomTime) MarshalJSON() ([]byte, error)
MarshalJSON 序列化至json字符串 noinspection all
func (*CustomTime) UnmarshalJSON ¶
func (c *CustomTime) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON 反序列化 noinspection all
type DynamicTime ¶
func (DynamicTime) MarshalJSON ¶
func (dt DynamicTime) MarshalJSON() ([]byte, error)
type IntString ¶
type IntString[T constraints.Integer] struct { // contains filtered or unexported fields }
func NewIntString ¶
func NewIntString[T constraints.Integer](v T) IntString[T]
NewIntString 添加一些便利方法
func NewIntStringAsNumber ¶
func NewIntStringAsNumber[T constraints.Integer](v T) IntString[T]
func StringToIntString ¶
func StringToIntString[T constraints.Integer](v string) (IntString[T], error)
func ZeroIntString ¶
func ZeroIntString[T constraints.Integer]() IntString[T]
ZeroIntString 零值(未设置值)
func (IntString[T]) GetJsonAsString ¶
func (IntString[T]) GormDBDataType ¶
noinspection all
func (IntString[T]) MarshalJSON ¶
noinspection all
func (*IntString[T]) SetJsonAsString ¶
SetJsonAsString 或者使用方法设置 noinspection all
func (*IntString[T]) UnmarshalJSON ¶
noinspection all
func (*IntString[T]) UnmarshalText ¶
UnmarshalText 实现 TextMarshaler 接口 这个主要是从query参数中进行提取,所以这里统一处理为字符串 noinspection all
type JSONMap ¶
JSONMap defined JSON data type, need to implements driver.Valuer, sql.Scanner interface noinspection all
func (JSONMap) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
func (JSONMap) GormDataType ¶
GormDataType gorm common data type noinspection all
func (JSONMap) MarshalJSON ¶
MarshalJSON to output non base64 encoded []byte noinspection all
func (*JSONMap) Scan ¶
Scan scan value into Jsonb, implements sql.Scanner interface noinspection all
func (*JSONMap) UnmarshalJSON ¶
UnmarshalJSON to deserialize []byte 这个函数很重要,Scan的时候 序列化通用函数会用到这个 noinspection all
type JSONRaw ¶
type JSONRaw json.RawMessage
func (JSONRaw) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
func (JSONRaw) GormDataType ¶
GormDataType gorm common data type. noinspection all
func (JSONRaw) MarshalJSON ¶
MarshalJSON to output non base64 encoded []byte noinspection all
func (*JSONRaw) UnmarshalJSON ¶
UnmarshalJSON to deserialize []byte noinspection all
type SessionValue ¶
type SessionValue struct {
Val any
}
noinspection all
func NewSessionValue ¶
func NewSessionValue(val any) SessionValue
func (SessionValue) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
func (SessionValue) GormDataType ¶
func (s SessionValue) GormDataType() string
type String ¶
type String string
func (String) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
type StringArray ¶
type StringArray []string
func (StringArray) GormDBDataType ¶
noinspection all
type Timestamp ¶
type Timestamp struct {
// contains filtered or unexported fields
}
func (Timestamp) GormDBDataType ¶
GormDBDataType gorm db data type noinspection all
func (Timestamp) GormDataType ¶
GormDataType gorm db data type noinspection all
func (*Timestamp) MarshalJSON ¶
MarshalJSON 实现 JSON 序列化接口 noinspection all
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON 实现 JSON 反序列化接口 noinspection all
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
func (*Uint64) EqualsUint64 ¶
func (Uint64) GormDBDataType ¶
noinspection all