field

package
v0.0.0-...-bc9e848 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormat string = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExBool

type ExBool bool

ExBool bool 类型

支持值形式如: "true", 1, true, false, null

若是数字,只支持 0( 包含 "0") 和 1 ( 包含 "1"),若传入数字 2 或者其他值,将报错

func (ExBool) MarshalJSON

func (a ExBool) MarshalJSON() ([]byte, error)

MarshalJSON to "true", "false"

func (ExBool) ToBool

func (a ExBool) ToBool() bool

ToBool 读取值

func (*ExBool) UnmarshalJSON

func (a *ExBool) UnmarshalJSON(b []byte) error

UnmarshalJSON for ExString,

type ExInt64

type ExInt64 int64

ExInt64 扩展的 int64 类型

支持值形式如: 12345, "12345", false(解析为 0), null(解析为 0), "12345.1", "12345.0", 12345.1

"" 空字符串解析为 0
true 解析为 1

func (ExInt64) MarshalJSON

func (a ExInt64) MarshalJSON() ([]byte, error)

MarshalJSON to 12345

func (ExInt64) ToInt64

func (a ExInt64) ToInt64() int64

ToInt64 获取值

func (*ExInt64) UnmarshalJSON

func (a *ExInt64) UnmarshalJSON(b []byte) error

UnmarshalJSON for ExInt64

type ExString

type ExString string

ExString 字符串类型

支持值形式如:"abcde", 12345, true, false, null
若传入为 bool 类型,会获的其字符串形式的值:"true"、"false"
若传入的是 null,会获得其字符串形式的值:"null"
若传入的是数字,如 123,会获的其字符串形式的值: "123"

func (ExString) MarshalJSON

func (a ExString) MarshalJSON() ([]byte, error)

MarshalJSON 编码为 json

func (ExString) ToString

func (a ExString) ToString() string

ToString underlying type

func (*ExString) UnmarshalJSON

func (a *ExString) UnmarshalJSON(b []byte) (e error)

UnmarshalJSON for ExString

type ExStringSlice

type ExStringSlice []string

ExStringSlice 扩展 json 数组类型, 允许格式:"abc"、["avc","def"]、"abc,def"、null、"1,2"、["1","2"]

若字段定义为该类型,在 json.Marshal 的时候,当值为空的时候会编码为 null。

func (*ExStringSlice) StringSlice

func (s *ExStringSlice) StringSlice() []string

StringSlice 返回 []string 的值

func (*ExStringSlice) UnmarshalJSON

func (s *ExStringSlice) UnmarshalJSON(b []byte) error

UnmarshalJSON implement json interface

type IgnoreError

type IgnoreError struct{}

func (IgnoreError) Error

func (ie IgnoreError) Error() string

type JSON

type JSON json.RawMessage

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON Struct 转 Json 数据结构

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON Json 转 Struct 数据结构

func (*JSON) UnmarshalString

func (j *JSON) UnmarshalString(data string) error

UnmarshalString string 转 Struct 数据结构

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type JSONObject

type JSONObject map[string]interface{}

func (JSONObject) MarshalJSON

func (j JSONObject) MarshalJSON() ([]byte, error)

MarshalJSON Struct 转 Json 数据结构

func (*JSONObject) Scan

func (j *JSONObject) Scan(value interface{}) error

Scan 读取db

func (*JSONObject) UnmarshalJSON

func (j *JSONObject) UnmarshalJSON(data []byte) error

UnmarshalJSON 反序列化

func (*JSONObject) UnmarshalString

func (j *JSONObject) UnmarshalString(data string) error

UnmarshalString string 转 Struct 数据结构

func (JSONObject) Value

func (j JSONObject) Value() (driver.Value, error)

Value 写入db

type Time

type Time time.Time

func (Time) GetDefault

func (t Time) GetDefault(context.Context, interface{}) interface{}

GetDefault 获取当前时间,只有这一种可能

func (Time) GetDefaultPrepare

func (t Time) GetDefaultPrepare(rt reflect.Type, value string) (interface{}, error)

GetDefaultPrepare 确定是否合法的default,不是交由后续处理

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON Struct 转 Json 数据结构 格式成符合预期的时间格式字符串后返回,效果与Value一样

func (*Time) Scan

func (t *Time) Scan(value interface{}) error

Scan implements the Scanner interface. 将原始数据进行Struct结构改造

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON Json 转 Struct 数据结构

func (*Time) UnmarshalString

func (t *Time) UnmarshalString(data string) error

UnmarshalString string 转 Struct 数据结构

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value implements the driver Valuer interface. 将值转换为时间字符串

type Timestamp

type Timestamp time.Time

func (Timestamp) GetDefault

func (t Timestamp) GetDefault(context.Context, interface{}) interface{}

GetDefault 获取当前时间,只有这一种可能

func (Timestamp) GetDefaultPrepare

func (t Timestamp) GetDefaultPrepare(rt reflect.Type, value string) (interface{}, error)

GetDefaultPrepare 确定是否合法的default,不是交由后续处理

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON Struct 转 Json 数据结构 格式成符合预期的时间格式字符串后返回,效果与Value一样

func (*Timestamp) Scan

func (t *Timestamp) Scan(value interface{}) error

Scan implements the Scanner interface. 将原始数据进行Struct结构改造

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON Json 转 Struct 数据结构

func (*Timestamp) UnmarshalString

func (t *Timestamp) UnmarshalString(data string) error

UnmarshalString string 转 Struct 数据结构

func (Timestamp) Value

func (t Timestamp) Value() (driver.Value, error)

Value implements the driver Valuer interface. 将值转换为时间字符串

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL