utils

package
v0.0.0-...-561f698 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EBUSY  = 40001
	EBUSYS = "系统繁忙请稍后再试"

	EEXPIRE  = 40002
	EEXPIRES = "您的账号已经过期该部分功能已经被限制"

	EAUTHLOGIN  = 401             //权限错误
	EAUTHLOGINS = "登录已经过期了需要重新登录" //权限错误

	SUCCESS      = 0
	NOFOUNTUSER  = 2
	EUNKNOWN     = 10001 //未知错误
	EDBERR       = 10002 //数据库错误
	EMTHNOTFOUND = 10003 //方法不存在
	EDTNOTFOUND  = 10004 //数据不存在
	ERENDER      = 10008 //渲染出错
	EAUTH        = 10009 //权限错误
	EFORMAT      = 10010 //参数格式错误
	EDATA        = 10011 //数据错误
	EMPLOGIN     = 10012 //登录错误
	EPASSWORD    = 10013 //密码错误

	ELOGINS = 20001
	ELOGINC = 20002
	ECAPT   = 20003
	EECAPT  = 20004
	EPASSWD = 20005
	ELOGIND = 20006

	EECAPTEXP = 20007

	ESYN  = 30001
	ESYNS = "命令发送失败"

	EUNKNOWNS     = "未知错误"
	EDBERRS       = "数据库错误"
	EMTHNOTFOUNDS = "方法不存在"
	EDTNOTFOUNDS  = "数据不存在"

	EAUTHS     = "权限错误"
	EFORMATS   = "数据格式错误"
	EDATAS     = "数据错误"
	SUCCESSS   = "成功"
	SUCCESSSYN = "成功,请等待同步"
	SUCCESSAS  = "添加成功"
	SUCCESSUS  = "修改成功"
	SUCCESSDS  = "删除成功"

	ELOGINSS     = "您已经登录了"
	NOFOUNTUSERS = "用户不存在"
	ELOGINCS     = "请合理使用资源"
	ELOGINDS     = "您的账号被禁用,请联系管理员"
	ECAPTS       = "验证码错误"
	EUSERPASSWDS = "请检查用户名和密码"
	EPASSWORDS   = "密码错误"

	SUCCESSLOGINS = "登陆成功"
	SUCCEPASSWD   = "密码修改成功"
	SUCCCAPT      = "验证码发送成功"

	CFILENOTFOUND = 90001
	CMD5          = 90002
	CTORAGE       = 9004
)

错误代码定义

Variables

View Source
var (
	//Userid 交易模块的雪花ID
	FastId   *id
	NormalId *id
)
View Source
var (
	Cfg *ini.File
)

系统配置参数

Functions

func GenerateNormalId

func GenerateNormalId() int64

Generate creates and returns a unique normalId ID Generate creates and returns a unique normalId ID

func GenerateNormalId6

func GenerateNormalId6() int64

Generate creates and returns a unique normalId ID

func GetRunHTTPPort

func GetRunHTTPPort() (port string)

GetRunHTTPPort 获取Http端口

func LoadConf

func LoadConf(file string) (cfg *ini.File, err error)

LoadConf 加载配置文件

func MD5

func MD5(text string) string

MD5 计算MD5

func NewNormalid

func NewNormalid(workerid int64) (*id, error)

Newnormalid NewNode returns a new normalId worker that can be used to generate normalId IDs

func RandomStr

func RandomStr(size int, Random int) string

RandomStr 随机数生成 size 长度 Random 0: 纯数字; 1: 小写字母 ;2: 大写字母 ;3: 数字、大小写字母

func RandomStr2

func RandomStr2(size int, Random int, stype int) string

RandomStr 随机数生成 size 长度 Random 0: 纯数字; 1: 小写字母 ;2: 大写字母 ;3: 数字、大小写字母 stype 1 纯数字 2 数字、小写字母 3 数字、大小写字母

Types

type Info1

type Info1 struct {
	Name     string `xml:"name"`
	UniqueId string `xml:"unique_id"`
}

type Info2

type Info2 struct {
	Name               string `xml:"name"`
	Code               string `xml:"code"`
	CodeType           int    `xml:"code_type"`
	LegalPersonaWechat string `xml:"legal_persona_wechat"`
	LegalPersonaName   string `xml:"legal_persona_name"`
	ComponentPhone     string `xml:"component_phone"`
}

type Worker

type Worker struct {
	LastStamp    int64 // 记录上一次ID的时间戳
	WorkerID     int64 // 该节点的ID
	DataCenterID int64 // 该节点的 数据中心ID
	Sequence     int64 // 当前毫秒已经生成的ID序列号(从0 开始累加) 1毫秒内最多生成4096个ID
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(workerID, dataCenterID int64) *Worker

分布式情况下,我们应通过外部配置文件或其他方式为每台机器分配独立的id

func (*Worker) NextID

func (w *Worker) NextID() (uint64, error)

type XRegister

type XRegister struct {
	CommentAppID string      `xml:"AppId"` // 第三方平台appid
	CreateTime   string      `xml:"CreateTime"`
	InfoType     string      `xml:"InfoType"`
	AppID        string      `xml:"appid"`
	Status       int         `xml:"status"`
	Msg          string      `xml:"msg"`
	Info         interface{} `xml:"info"`
}

type XRegisterBetaMiniprogram

type XRegisterBetaMiniprogram struct {
	CommentAppID string `xml:"AppId"` // 第三方平台appid
	CreateTime   string `xml:"CreateTime"`
	InfoType     string `xml:"InfoType"`
	AppID        string `xml:"appid"`
	Status       int    `xml:"status"`
	Msg          string `xml:"msg"`
	Info         struct {
		Name     string `xml:"name"`
		UniqueId string `xml:"unique_id"`
	} `xml:"info"`
}

func TestEvent

func TestEvent(result string) (event *XRegisterBetaMiniprogram, err error)

type XRegisterBetaMiniprogram2

type XRegisterBetaMiniprogram2 struct {
	CommentAppID string `xml:"AppId"` // 第三方平台appid
	CreateTime   string `xml:"CreateTime"`
	InfoType     string `xml:"InfoType"`
	AppID        string `xml:"appid"`
	Status       int    `xml:"status"`
	Msg          string `xml:"msg"`
	Info         struct {
		Name               string `xml:"name"`
		Code               string `xml:"code"`
		CodeType           int    `xml:"code_type"`
		LegalPersonaWechat string `xml:"legal_persona_wechat"`
		LegalPersonaName   string `xml:"legal_persona_name"`
		ComponentPhone     string `xml:"component_phone"`
	} `xml:"info"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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