modify name

This commit is contained in:
MaysWind
2020-11-08 20:01:35 +08:00
parent 69798b88df
commit 234b5a7465
3 changed files with 17 additions and 17 deletions
+9 -9
View File
@@ -10,14 +10,14 @@ const (
SYSTEM_SUBCATEGORY_SETTING = 1 SYSTEM_SUBCATEGORY_SETTING = 1
SYSTEM_SUBCATEGORY_DATABASE = 2 SYSTEM_SUBCATEGORY_DATABASE = 2
NORMAL_SUBCATEGORY_GLOBAL = 0 NORMAL_SUBCATEGORY_GLOBAL = 0
NORMAL_SUBCATEGORY_USER = 1 NORMAL_SUBCATEGORY_USER = 1
NORMAL_SUBCATEGORY_TOKEN = 2 NORMAL_SUBCATEGORY_TOKEN = 2
NORMAL_SUBCATEGORY_TWOFACTOR = 3 NORMAL_SUBCATEGORY_TWOFACTOR = 3
NORMAL_SUBCATEGORY_ACCOUNT = 4 NORMAL_SUBCATEGORY_ACCOUNT = 4
NORMAL_SUBCATEGORY_JOURNAL = 5 NORMAL_SUBCATEGORY_TRANSACTION = 5
NORMAL_SUBCATEGORY_CATEGORY = 6 NORMAL_SUBCATEGORY_CATEGORY = 6
NORMAL_SUBCATEGORY_TAG = 7 NORMAL_SUBCATEGORY_TAG = 7
) )
type Error struct { type Error struct {
@@ -73,6 +73,6 @@ func Or(err error, defaultErr *Error) *Error {
} }
func IsCustomError(err error) bool { func IsCustomError(err error) bool {
_, ok := err.(*Error); _, ok := err.(*Error)
return ok return ok
} }
+2 -2
View File
@@ -14,7 +14,7 @@ import (
func TestGenerateUuid(t *testing.T) { func TestGenerateUuid(t *testing.T) {
expectedUnixTime := time.Now().Unix() expectedUnixTime := time.Now().Unix()
expectedUuidServerId := uint8(90) expectedUuidServerId := uint8(90)
expectedUuidType := UUID_TYPE_JOURNAL expectedUuidType := UUID_TYPE_TRANSACTION
generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: expectedUuidServerId}) generator, _ := NewInternalUuidGenerator(&settings.Config{UuidServerId: expectedUuidServerId})
uuid := generator.GenerateUuid(expectedUuidType) uuid := generator.GenerateUuid(expectedUuidType)
@@ -48,7 +48,7 @@ func TestGenerateUuid_MultiType(t *testing.T) {
actualSeqId = uuidInfo.SequentialId actualSeqId = uuidInfo.SequentialId
assert.Equal(t, uint32(expectedSeqId), actualSeqId) assert.Equal(t, uint32(expectedSeqId), actualSeqId)
uuid = generator.GenerateUuid(UUID_TYPE_JOURNAL) uuid = generator.GenerateUuid(UUID_TYPE_TRANSACTION)
uuidInfo = generator.ParseUuidInfo(uuid) uuidInfo = generator.ParseUuidInfo(uuid)
actualSeqId = uuidInfo.SequentialId actualSeqId = uuidInfo.SequentialId
assert.Equal(t, uint32(expectedSeqId), actualSeqId) assert.Equal(t, uint32(expectedSeqId), actualSeqId)
+6 -6
View File
@@ -3,10 +3,10 @@ package uuid
type UuidType uint8 type UuidType uint8
const ( const (
UUID_TYPE_DEFAULT UuidType = 0 UUID_TYPE_DEFAULT UuidType = 0
UUID_TYPE_USER UuidType = 1 UUID_TYPE_USER UuidType = 1
UUID_TYPE_ACCOUNT UuidType = 2 UUID_TYPE_ACCOUNT UuidType = 2
UUID_TYPE_JOURNAL UuidType = 3 UUID_TYPE_TRANSACTION UuidType = 3
UUID_TYPE_CATEGORY UuidType = 4 UUID_TYPE_CATEGORY UuidType = 4
UUID_TYPE_TAG UuidType = 5 UUID_TYPE_TAG UuidType = 5
) )