EasyAudioEncode/domain/uniqueid/core.go
2025-12-25 17:01:46 +08:00

40 lines
1010 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Code generated by godddx, DO AVOID EDIT.
package uniqueid
// Storer data persistence
type Storer interface {
UniqueID() UniqueIDStorer
}
// Core business domain
type Core struct {
store Storer
m *IDManager
length int
}
// NewCore create business domain
func NewCore(store Storer, length int) Core {
return Core{
store: store,
length: length,
m: NewIDManager(store.UniqueID()),
}
}
// UniqueID 获取全局唯一 ID
// 当创建的 id 并未使用,或允许下次再次使用,请执行 UndoUniqueID
func (c Core) UniqueID(prefix string) string {
return c.m.UniqueID(prefix, c.length)
}
// UniqueIDByCustomLen 获取自定义长度的全局 id
func (c Core) UniqueIDWithCustomLen(prefix string, length int) string {
return c.m.UniqueID(prefix, length)
}
// UndoUniqueID 撤销唯一 id如果 UniqueID 获取的某个 id 并未使用,或者随着数据源的删除可以调用此函数撤销
func (c Core) UndoUniqueID(id string) error {
return c.m.UndoUniqueID(id)
}