uniqueid

package
v1.3.21 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Code generated by godddx, DO AVOID EDIT.

Code generated by godddx, DO AVOID EDIT.

Code generated by godddx, DO AVOID EDIT.

Index

Constants

View Source
const (
	// 删除 o 和 i 的字符集,避免视觉混淆
	LetterBytes36NoOI = "abcdefghjklmnpqrstuvwxyz0123456789"

	LetterBytes72      = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	LetterBytes36      = "abcdefghijklmnopqrstuvwxyz0123456789" // default
	LetterBytes36Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
)

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(letterBytes string, length int) string

GenerateRandomString 生成随机字符串

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

Core business domain

func NewCore

func NewCore(store Storer, length int) Core

NewCore create business domain

func (Core) UndoUniqueID added in v1.2.2

func (c Core) UndoUniqueID(id string) error

UndoUniqueID 撤销唯一 id,如果 UniqueID 获取的某个 id 并未使用,或者随着数据源的删除可以调用此函数撤销

func (Core) UniqueID

func (c Core) UniqueID(prefix string) string

UniqueID 获取全局唯一 ID 当创建的 id 并未使用,或允许下次再次使用,请执行 UndoUniqueID

func (Core) UniqueIDWithCustomLen added in v1.2.2

func (c Core) UniqueIDWithCustomLen(prefix string, length int) string

UniqueIDByCustomLen 获取自定义长度的全局 id

type IDManager

type IDManager struct {
	// contains filtered or unexported fields
}

func NewIDManager

func NewIDManager(store UniqueIDStorer) *IDManager

func (*IDManager) SetLetterBytes added in v1.2.11

func (m *IDManager) SetLetterBytes(letterBytes string)

SetLetterBytes 设置随机字符串字符集

func (*IDManager) UndoUniqueID added in v1.2.2

func (m *IDManager) UndoUniqueID(id string) error

UndoUniqueID 删除唯一 id

func (*IDManager) UniqueID

func (m *IDManager) UniqueID(prefix string, length int) string

UniqueID 获取唯一 id

type Storer

type Storer interface {
	UniqueID() UniqueIDStorer
}

Storer data persistence

type UniqueID

type UniqueID struct {
	ID        string   `gorm:"primaryKey" json:"id"`                                                               // 唯一 id
	CreatedAt orm.Time `gorm:"column:created_at;notNull;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
}

UniqueID domain model

func (*UniqueID) TableName

func (*UniqueID) TableName() string

TableName database table name

type UniqueIDStorer

UniqueIDStorer Instantiation interface

Directories

Path Synopsis
store
uniqueiddb
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.

Jump to

Keyboard shortcuts

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