id

package
v0.0.0-...-21f96e3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DistributedId

type DistributedId int64

func (DistributedId) MarshalJSON

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

MarshalJSON *

  • @Description: 重写MarshalJSON方法
  • @receiver t
  • @return []byte
  • @return error

func (*DistributedId) Scan

func (t *DistributedId) Scan(v interface{}) error

Scan 将数据库中取出的数据,赋值给目标类型

func (*DistributedId) UnmarshalJSON

func (t *DistributedId) UnmarshalJSON(b []byte) error

UnmarshalJSON *

  • @Description: 重写UnmarshalJSON方法
  • @receiver t
  • @param b
  • @return error

func (DistributedId) Value

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

Value 写入数据库之前,对数据做类型转换

type DistributedIdGenerator

type DistributedIdGenerator struct {
	TenantId string
	Node     *snowflake.Node
}

func InitDistributedIdGenerator

func InitDistributedIdGenerator(tenantId string, node int64) (generator *DistributedIdGenerator, err error)

InitDistributedIdGenerator *

  • @Description: 初始化分布式ID生成器
  • @param tenantId
  • @param node
  • @return generator
  • @return err

func (*DistributedIdGenerator) CreateId

func (generator *DistributedIdGenerator) CreateId() DistributedId

CreateId *

  • @Description: 创建一个分布式ID(雪花ID)
  • @return DistributedId

type Model

type Model struct {
	ID         DistributedId `json:"id"                     form:"id"     gorm:"column:id;primary_key;type:bigint"`
	CreateTime string        `json:"createTime"             form:"-"       gorm:"column:create_time;index;type:varchar(20)"`
	UpdateTime string        `json:"updateTime,omitempty"   form:"-"       gorm:"column:update_time;type:varchar(20)"`
}

Jump to

Keyboard shortcuts

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