Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
e329ceb3
Z
zendata
项目概览
易企天创
/
zendata
10 个月 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e329ceb3
编写于
3月 28, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gen ulid
上级
bb7e145c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
3 deletion
+63
-3
demo/29_uuid.yaml
demo/29_uuid.yaml
+8
-2
demo/t.yaml
demo/t.yaml
+7
-1
src/gen/field.go
src/gen/field.go
+2
-0
src/gen/timestampVar.go
src/gen/timestampVar.go
+20
-0
src/utils/const/const.go
src/utils/const/const.go
+1
-0
yaml/ulid/v1.yaml
yaml/ulid/v1.yaml
+12
-0
yaml/uuid/v2.yaml
yaml/uuid/v2.yaml
+13
-0
未找到文件。
demo/29_uuid.yaml
浏览文件 @
e329ceb3
fields
:
-
field
:
field_uuid
format
:
"
uuid(-)"
-
field
:
f1
from
:
uuid.v2.yaml
use
:
by_format
postfix
:
"
\t
"
-
field
:
f2
from
:
ulid.v1.yaml
use
:
ulid{3}
demo/t.yaml
浏览文件 @
e329ceb3
...
...
@@ -6,4 +6,10 @@ version: 1.0
fields
:
-
field
:
f1
format
:
"
uuid(-
)"
from
:
uuid.v2.yaml
use
:
by_format
postfix
:
"
\t
"
-
field
:
f2
from
:
ulid.v1.yaml
use
:
ulid{3}
\ No newline at end of file
src/gen/field.go
浏览文件 @
e329ceb3
...
...
@@ -22,6 +22,8 @@ func CreateField(field *model.DefField) model.FieldWithValues {
CreateListField
(
field
,
&
fieldWithValue
)
}
else
if
field
.
Type
==
constant
.
FieldTypeTimestamp
{
CreateTimestampField
(
field
,
&
fieldWithValue
)
}
else
if
field
.
Type
==
constant
.
FieldTypeUlid
{
CreateUlidField
(
field
,
&
fieldWithValue
)
}
else
if
field
.
Type
==
constant
.
FieldTypeArticle
{
CreateArticleField
(
field
,
&
fieldWithValue
)
}
...
...
src/gen/timestampVar.go
浏览文件 @
e329ceb3
...
...
@@ -5,6 +5,9 @@ import (
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"github.com/easysoft/zendata/src/utils/vari"
"github.com/oklog/ulid/v2"
"math/rand"
"strconv"
"strings"
"time"
...
...
@@ -30,6 +33,23 @@ func CreateTimestampField(field *model.DefField, fieldWithValue *model.FieldWith
fieldWithValue
.
Values
=
values
}
func
CreateUlidField
(
field
*
model
.
DefField
,
fieldWithValue
*
model
.
FieldWithValues
)
{
count
:=
0
t
:=
time
.
Unix
(
1000000
,
0
)
entropy
:=
ulid
.
Monotonic
(
rand
.
New
(
rand
.
NewSource
(
t
.
UnixNano
())),
0
)
for
true
{
val
:=
ulid
.
MustNew
(
ulid
.
Timestamp
(
t
),
entropy
)
.
String
()
fieldWithValue
.
Values
=
append
(
fieldWithValue
.
Values
,
val
)
count
++
if
count
>=
constant
.
MaxNumb
||
count
>
vari
.
Total
{
break
}
}
}
func
convertTmFormat
(
field
*
model
.
DefField
)
{
// to 2006-01-02 15:04:05
format
:=
field
.
Format
...
...
src/utils/const/const.go
浏览文件 @
e329ceb3
...
...
@@ -56,6 +56,7 @@ var (
FieldTypeList
=
"list"
FieldTypeTimestamp
=
"timestamp"
FieldTypeUlid
=
"ulid"
FieldTypeArticle
=
"article"
LeftBrackets
rune
=
'('
...
...
yaml/ulid/v1.yaml
0 → 100644
浏览文件 @
e329ceb3
title
:
ULID
desc
:
通用唯一词典分类标识符。
author
:
wwccss
version
:
1.0
field
:
ulid
instances
:
-
instance
:
ulid
note
:
标准26位长度,按字母升序排序。
fields
:
-
field
:
part1
type
:
ulid
\ No newline at end of file
yaml/uuid/v2.yaml
0 → 100644
浏览文件 @
e329ceb3
title
:
UUID
desc
:
通用唯一识别码。
author
:
wwccss
version
:
1.0
field
:
uuid
instances
:
-
instance
:
by_format
note
:
以-为分隔符的随机UUID
fields
:
-
field
:
part1
range
:
1-9
format
:
"
uuid(-)"
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录