identity

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package identity 提供安装时固定的可逆用户编号,不作为认证凭证。

Index

Constants

View Source
const (
	// SettingKey 是仅供服务端读取的安装配置组,不提供后台编辑。
	SettingKey = "__user_identity"
)

Variables

This section is empty.

Functions

func Install

func Install(ctx context.Context, db *gorm.DB) error

Install 只在首次安装生成编号密钥,已有配置永不覆盖。

Types

type Codec

type Codec struct {
	Key string `json:"key"`
}

Codec的密钥属于安装配置,创建用户后不得改变。

func Load

func Load(ctx context.Context, db *gorm.DB) (*Codec, error)

Load 复用配置分组缓存,未命中才查询固定配置,绝不生成新密钥。

func (*Codec) Big2ID

func (c *Codec) Big2ID(value string) (int64, error)

Big2ID 还原非零int64,拒绝非法或超出档位的编号;编号不能作为认证凭证。

func (*Codec) ID2Big

func (c *Codec) ID2Big(id int64) (string, error)

ID2Big 可逆转换非零int64;7位起按区间升位,无前导0、不含4,中间位奇正偶负。

Jump to

Keyboard shortcuts

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