提交 19668561 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

gen yaml for table fk refer

上级 a3396dfe
......@@ -28,3 +28,4 @@
/yaml/article/chinese/slang/out/
/runtime/protobuf/go
/runtime/protobuf/out/
/users/common/
......@@ -97,4 +97,4 @@ upload_to:
@echo 'upload...'
@find ${QINIU_DIR} -name ".DS_Store" -type f -delete
@qshell qupload2 --src-dir=${QINIU_DIR} --bucket=download --thread-count=10 --log-file=qshell.log \
--skip-path-prefixes=ztf,zmanager --rescan-local --overwrite --check-hash
--skip-path-prefixes=ztf,zmanager,driver --rescan-local --overwrite --check-hash
CREATE TABLE `biz_project` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`name` longtext,
`desc` longtext,
`is_default` longtext,
`disabled` tinyint(1) DEFAULT NULL,
`disabled_at` datetime(3) DEFAULT NULL,
`path` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
CREATE TABLE `biz_task` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`disabled` tinyint(1) DEFAULT '0',
`name` longtext,
`project_id` bigint(20) unsigned NOT NULL,
`project_name` longtext,
`disabled_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_project_id_idx` (`project_id`),
CONSTRAINT `fk_project_id` FOREIGN KEY (`project_id`) REFERENCES `biz_project` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
-- sqlite
CREATE TABLE user (
field_common VARCHAR (500)
);
-- DROP TABLE IF EXISTS `zt_action`;
CREATE TABLE IF NOT EXISTS `zt_action` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`objectType` varchar(30) NOT NULL default '',
`objectID` mediumint(8) unsigned NOT NULL default '0',
`product` varchar(255) NOT NULL,
`project` mediumint(9) NOT NULL,
`actor` varchar(100) NOT NULL default '',
`action` varchar(30) NOT NULL default '',
`date` datetime NOT NULL,
`comment` text NOT NULL,
`extra` text NOT NULL,
`read` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `date` (`date`),
KEY `actor` (`actor`),
KEY `project` (`project`),
KEY `objectID` (`objectID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
......@@ -14,7 +14,7 @@ require (
github.com/denisenkom/go-mssqldb v0.9.0 // indirect
github.com/elazarl/go-bindata-assetfs v1.0.1
github.com/emirpasic/gods v1.12.0
github.com/fatih/color v1.10.0
github.com/fatih/color v1.13.0 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/go-sql-driver/mysql v1.6.0
......@@ -48,7 +48,6 @@ require (
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/sys v0.0.0-20210308170721-88b6017d0656 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.62.0
gopkg.in/yaml.v2 v2.4.0
......
......@@ -57,6 +57,8 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structtag v1.0.0 h1:pTHj65+u3RKWYPSGaU290FpI/dXxTaHdVwVwbcPKmEc=
github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
......@@ -178,11 +180,15 @@ github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
......@@ -377,6 +383,8 @@ golang.org/x/sys v0.0.0-20201126233918-771906719818 h1:f1CIuDlJhwANEC2MM87MBEVMr
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210308170721-88b6017d0656 h1:FuBaiPCiXkq4v+JY5JEGPU/HwEZwpVyDbu/KBz9fU+4=
golang.org/x/sys v0.0.0-20210308170721-88b6017d0656/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
......
......@@ -25,7 +25,7 @@ func Generate(defaultFile string, configFile string, fieldsToExportStr, format,
count := 0
if strings.ToLower(filepath.Ext(configFile)) == "."+constant.FormatProto { //gen from protobuf
buf, pth := gen.GenerateProtobuf(configFile)
buf, pth := gen.GenerateFromProtobuf(configFile)
if vari.Verbose {
logUtils.PrintTo(i118Utils.I118Prt.Sprintf("protobuf_path", pth))
......@@ -40,7 +40,7 @@ func Generate(defaultFile string, configFile string, fieldsToExportStr, format,
fieldsToExport = strings.Split(fieldsToExportStr, ",")
}
rows, colIsNumArr, err := gen.GenerateOnTopLevel(defaultFile, configFile, &fieldsToExport)
rows, colIsNumArr, err := gen.GenerateFromYaml(defaultFile, configFile, &fieldsToExport)
if err != nil {
return
}
......
......@@ -15,9 +15,11 @@ import (
func ParseSql(file string, out string) {
startTime := time.Now().Unix()
statements := getCreateStatement(file)
for tableName, statement := range statements {
columns := getColumnsFromCreateStatement(statement)
statementMap, keyMap := getCreateStatement(file)
for tableName, statement := range statementMap {
createStr := statement
columns := getColumnsFromCreateStatement(createStr)
def := model.DefSimple{}
def.Init(tableName, "automated export", "", "1.0")
......@@ -25,6 +27,14 @@ func ParseSql(file string, out string) {
for _, col := range columns {
field := model.FieldSimple{Range: "-"}
field.Init(col)
a, ok := keyMap[col]
if ok {
field.FkDef = a[0] + ".yaml"
field.FkField = a[1]
field.FkRelation = ":1"
}
def.Fields = append(def.Fields, field)
}
......@@ -41,16 +51,17 @@ func ParseSql(file string, out string) {
}
entTime := time.Now().Unix()
logUtils.PrintTo(i118Utils.I118Prt.Sprintf("generate_yaml", len(statements), out, entTime-startTime))
logUtils.PrintTo(i118Utils.I118Prt.Sprintf("generate_yaml", len(statementMap), out, entTime-startTime))
}
func getCreateStatement(file string) map[string]string {
statements := map[string]string{}
func getCreateStatement(file string) (statementMap map[string]string, keyMap map[string][2]string) {
statementMap = map[string]string{}
keyMap = map[string][2]string{}
content, err := ioutil.ReadFile(file)
if err != nil {
logUtils.PrintTo(i118Utils.I118Prt.Sprintf("fail_to_read_file", file))
return statements
return
}
re := regexp.MustCompile("(?siU)(CREATE TABLE.*;)")
......@@ -61,13 +72,22 @@ func getCreateStatement(file string) map[string]string {
arr2 := re.FindAllStringSubmatch(firstLine, -1)
if len(arr2) > 0 && len(arr2[0]) > 1 {
re3 := regexp.MustCompile("(?i)FOREIGN KEY \\(`(.+)`\\) REFERENCES `(.+)` \\(`(.+)`\\)")
arr3 := re3.FindAllStringSubmatch(item, -1)
if len(arr3) > 0 {
for _, childArr := range arr3 {
keyMap[childArr[1]] = [2]string{childArr[2], childArr[3]}
}
}
tableName := arr2[0][1]
tableName = strings.ReplaceAll(tableName, "`", "")
statements[tableName] = item
statementMap[tableName] = item
}
}
return statements
return
}
func getColumnsFromCreateStatement(sent string) []string {
......
......@@ -20,7 +20,7 @@ import (
"time"
)
func GenerateOnTopLevel(defaultFile, configFile string, fieldsToExport *[]string) (
func GenerateFromYaml(defaultFile, configFile string, fieldsToExport *[]string) (
rows [][]string, colIsNumArr []bool, err error) {
vari.DefaultFileDir = fileUtils.GetAbsDir(defaultFile)
......@@ -46,13 +46,13 @@ func GenerateOnTopLevel(defaultFile, configFile string, fieldsToExport *[]string
}
}
// 为被引用的资源生成数据
vari.ResLoading = true // not to use placeholder when loading res
vari.Res = LoadResDef(*fieldsToExport)
vari.ResLoading = false
// 迭代fields生成值列表
topLevelFieldNameToValuesMap := map[string][]string{}
// 为每个field生成值列表
for index, field := range vari.Def.Fields {
if !stringUtils.StrInArr(field.Field, *fieldsToExport) {
continue
......@@ -61,7 +61,7 @@ func GenerateOnTopLevel(defaultFile, configFile string, fieldsToExport *[]string
if field.Use != "" && field.From == "" {
field.From = vari.Def.From
}
values := GenerateForField(&field, true)
values := GenerateForFieldRecursive(&field, true)
vari.Def.Fields[index].Precision = field.Precision
......@@ -111,26 +111,26 @@ func GenerateOnTopLevel(defaultFile, configFile string, fieldsToExport *[]string
return
}
func GenerateForField(field *model.DefField, withFix bool) (values []string) {
func GenerateForFieldRecursive(field *model.DefField, withFix bool) (values []string) {
if len(field.Fields) > 0 { // sub fields
fieldNameToValuesMap := map[string][]string{} // refer field name to values
fieldNameToValuesMap := map[string][]string{} // refer field name to values
fieldMap := map[string]model.DefField{}
// 1. prepare referred values
for _, child := range field.Fields {
if child.From == "" {
child.From = field.From
}
child.FileDir = field.FileDir
childValues := GenerateForField(&child, withFix)
childValues := GenerateForFieldRecursive(&child, withFix)
fieldNameToValuesMap[child.Field] = childValues
fieldMap[child.Field] = child
}
// 2. generate values for sub fields
arrOfArr := make([][]string, 0) // 2 dimension arr for child, [ [a,b,c], [1,2,3] ]
for _, child := range field.Fields {
childValues := fieldNameToValuesMap[child.Field]
if child.Value != "" {
......@@ -139,6 +139,7 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
arrOfArr = append(arrOfArr, childValues)
}
// 3. get combined values for parent field
count := vari.Total
count = getRecordCount(arrOfArr)
if count > vari.Total {
......@@ -161,7 +162,7 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
}
child.FileDir = field.FileDir
childValues := GenerateForField(&child, withFix)
childValues := GenerateForFieldRecursive(&child, withFix)
unionValues = append(unionValues, childValues...)
}
......@@ -242,7 +243,7 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
values = loopFieldValues(field, values, vari.Total, true)
} else { // leaf field
values = GenerateFieldValuesForDef(field)
values = GenerateValuesForField(field)
}
if field.Rand && field.Type != constant.FieldTypeArticle {
......@@ -252,7 +253,7 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
return values
}
func GenerateFieldValuesForDef(field *model.DefField) []string {
func GenerateValuesForField(field *model.DefField) []string {
values := make([]string, 0)
fieldWithValues := CreateField(field)
......
......@@ -305,7 +305,7 @@ func CreateValuesFromYaml(field *model.DefField, yamlFile, stepStr string, repea
configFile := fileUtils.ComputerReferFilePath(yamlFile, field)
fieldsToExport := make([]string, 0) // set to empty to use all fields
rows, colIsNumArr, _ := GenerateOnTopLevel("", configFile, &fieldsToExport)
rows, colIsNumArr, _ := GenerateFromYaml("", configFile, &fieldsToExport)
if field.Rand {
rows = randomValuesArr(rows)
}
......
......@@ -17,7 +17,7 @@ const (
bufFile = "data.bin"
)
func GenerateProtobuf(protoFile string) (content, pth string) {
func GenerateFromProtobuf(protoFile string) (content, pth string) {
outputDir := generateCls(protoFile)
convertFile := generateConverter(outputDir)
......
......@@ -25,12 +25,12 @@ func LoadResDef(fieldsToExport []string) (res map[string]map[string][]string) {
field.From = vari.Def.From
vari.Def.Fields[index].From = vari.Def.From
}
loadResForField(&field, &res)
loadResForFieldRecursive(&field, &res)
}
return
}
func loadResForField(field *model.DefField, res *map[string]map[string][]string) {
func loadResForFieldRecursive(field *model.DefField, res *map[string]map[string][]string) {
if len(field.Fields) > 0 { // sub fields
for _, child := range field.Fields {
if child.Use != "" && child.From == "" {
......@@ -38,7 +38,7 @@ func loadResForField(field *model.DefField, res *map[string]map[string][]string)
}
child.FileDir = field.FileDir
loadResForField(&child, res)
loadResForFieldRecursive(&child, res)
}
} else if len(field.Froms) > 0 { // multiple from
for _, child := range field.Froms {
......@@ -47,10 +47,10 @@ func loadResForField(field *model.DefField, res *map[string]map[string][]string)
}
child.FileDir = field.FileDir
loadResForField(&child, res)
loadResForFieldRecursive(&child, res)
}
} else if field.From != "" && field.Type != constant.FieldTypeArticle { // refer to res
} else if field.From != "" && field.Type != constant.FieldTypeArticle { // from a res
var valueMap map[string][]string
resFile, resType, sheet := fileUtils.GetResProp(field.From, field.FileDir) // relate to current file
valueMap, _ = getResValue(resFile, resType, sheet, field)
......@@ -67,7 +67,7 @@ func loadResForField(field *model.DefField, res *map[string]map[string][]string)
(*res)[field.From][resKey] = val
}
} else if field.Config != "" { // refer to config
} else if field.Config != "" { // from a config
resFile, resType, _ := fileUtils.GetResProp(field.Config, field.FileDir)
values, _ := getResValue(resFile, resType, "", field)
(*res)[field.Config] = values
......@@ -94,7 +94,7 @@ func getResFromExcel(resFile, sheet string, field *model.DefField) map[string][]
}
func getResFromYaml(resFile string) (valueMap map[string][]string) { // , resName string) {
if vari.CacheResFileToMap[resFile] != nil {
if vari.CacheResFileToMap[resFile] != nil { // already cached
valueMap = vari.CacheResFileToMap[resFile]
//resName = vari.CacheResFileToName[resFile]
return
......@@ -147,7 +147,7 @@ func getResFromInstances(insts model.ResInstances) (groupedValue map[string][]st
// gen values
fieldFromInsts := convertInstantToField(insts, inst)
group := inst.Instance
groupedValue[group] = GenerateForField(&fieldFromInsts, false)
groupedValue[group] = GenerateForFieldRecursive(&fieldFromInsts, false)
}
return groupedValue
......@@ -159,7 +159,7 @@ func getResFromRanges(ranges model.ResRanges) map[string][]string {
for group, expression := range ranges.Ranges {
field := convertRangesToField(ranges, expression)
groupedValue[group] = GenerateForField(&field, false)
groupedValue[group] = GenerateForFieldRecursive(&field, false)
}
return groupedValue
......@@ -195,7 +195,7 @@ func prepareNestedInstanceRes(insts model.ResInstances, inst model.ResInstancesI
// gen values
group := referencedInst.Instance
groupedValueReferenced[group] = GenerateForField(&field, false)
groupedValueReferenced[group] = GenerateForFieldRecursive(&field, false)
}
}
......@@ -267,7 +267,7 @@ func getResForConfig(configRes model.DefField) map[string][]string {
groupedValue := map[string][]string{}
// config field is a standard field
groupedValue["all"] = GenerateForField(&configRes, false)
groupedValue["all"] = GenerateForFieldRecursive(&configRes, false)
return groupedValue
}
......
......@@ -228,7 +228,7 @@ func incrementUnit(originalVal int64, incNum int, unit string) (ret int64) {
case "D":
start = start.AddDate(0, 0, incNum)
case "w":
start = start.AddDate(0, 0, incNum * 7)
start = start.AddDate(0, 0, incNum*7)
case "h":
start = start.Add(time.Hour * time.Duration(incNum))
case "m":
......@@ -254,13 +254,13 @@ func increment(originalVal int64, incrementStr string) (ret int64) {
return
}
func GenerateTimeItems(start int64, end int64, step int, unit string, repeat int, repeatTag string) []interface{}{
func GenerateTimeItems(start int64, end int64, step int, unit string, repeat int, repeatTag string) []interface{} {
arr := make([]interface{}, 0)
total := 0
if repeatTag == "" {
for i := 0; true; {
val := incrementUnit(start, i * step, unit)
val := incrementUnit(start, i*step, unit)
//val := start + int64(i*step)
if (val >= end && step > 0) || (val <= end && step < 0) {
break
......
......@@ -73,11 +73,11 @@ type FieldBase struct {
FieldSimple `yaml:",inline"`
Config string `yaml:"config,omitempty"`
Use string `yaml:"use,omitempty"`
From string `yaml:"from,omitempty"`
Select string `yaml:"select,omitempty"`
Where string `yaml:"where,omitempty"`
Limit int `yaml:"limit,omitempty"`
Use string `yaml:"use,omitempty"`
IsNumb bool `yaml:"isNumb,omitempty"`
Expect string `yaml:"expect,omitempty"`
......@@ -103,11 +103,14 @@ type FieldSimple struct {
Type string `yaml:"type,omitempty"`
Mode string `yaml:"mode,omitempty"`
LoopStart int `yaml:"-"`
LoopEnd int `yaml:"-"`
LoopIndex int `yaml:"-"`
IsRand bool `yaml:"-"`
ReferToAnotherYaml bool `yaml:"-"`
LoopStart int `yaml:"-"`
LoopEnd int `yaml:"-"`
LoopIndex int `yaml:"-"`
IsRand bool `yaml:"-"`
ReferToAnotherYaml bool `yaml:"-"`
FkDef string `yaml:"fkDef,omitempty"`
FkField string `yaml:"fkField,omitempty"`
FkRelation string `yaml:"fkRelation,omitempty"`
}
type FieldWithValues struct {
......@@ -142,14 +145,17 @@ type DefExport struct {
XFields []DefFieldExport `yaml:"xfields,flow"` // control orders
}
type DefFieldExport struct {
Field string `yaml:"field"`
Prefix string `yaml:"prefix,omitempty"`
Postfix string `yaml:"postfix,omitempty"`
Divider string `yaml:"divider,omitempty"`
Select string `yaml:"select,omitempty"`
Where string `yaml:"where,omitempty"`
Rand bool `yaml:"rand"`
Limit int `yaml:"limit,omitempty"`
Field string `yaml:"field"`
Prefix string `yaml:"prefix,omitempty"`
Postfix string `yaml:"postfix,omitempty"`
Divider string `yaml:"divider,omitempty"`
Select string `yaml:"select,omitempty"`
Where string `yaml:"where,omitempty"`
Rand bool `yaml:"rand"`
Limit int `yaml:"limit,omitempty"`
FkFile string `gorm:"column:fkFile" json:"fkFile" yaml:"fkFile,omitempty"`
FkField string `gorm:"column:fkField" json:"fkField" yaml:"fkField,omitempty"`
FkRelation string `gorm:"column:fkRelation" json:"fkRelation" yaml:"fkRelation,omitempty"`
}
type Article struct {
Title string `yaml:"title"`
......
......@@ -35,25 +35,28 @@ type ZdField struct {
Field string `gorm:"column:field" json:"field"`
Note string `gorm:"column:note" json:"note"`
Range string `gorm:"column:range" json:"range"`
Prefix string `gorm:"column:prefix" json:"prefix"`
Postfix string `gorm:"column:postfix" json:"postfix"`
Divider string `gorm:"column:divider" json:"divider"`
Loop string `gorm:"column:loop" json:"loop"`
Loopfix string `gorm:"column:loopfix" json:"loopfix"`
Format string `gorm:"column:format" json:"format"`
Type string `gorm:"column:type" json:"type"`
Mode string `gorm:"column:mode" json:"mode"`
Length int `gorm:"column:length" json:"length"`
LeftPad string `gorm:"column:leftPad" json:"leftPad"`
RightPad string `gorm:"column:rightPad" json:"rightPad"`
Rand bool `gorm:"column:rand" json:"rand"`
Config string `gorm:"column:config" json:"config"`
Use string `gorm:"column:use" json:"use"`
From string `gorm:"column:fromCol" json:"fromCol"`
Select string `gorm:"column:selectCol" json:"selectCol"`
Where string `gorm:"column:whereCol" json:"whereCol"`
Limit int `gorm:"column:limitCol" json:"limitCol"`
Range string `gorm:"column:range" json:"range"`
Prefix string `gorm:"column:prefix" json:"prefix"`
Postfix string `gorm:"column:postfix" json:"postfix"`
Divider string `gorm:"column:divider" json:"divider"`
Loop string `gorm:"column:loop" json:"loop"`
Loopfix string `gorm:"column:loopfix" json:"loopfix"`
Format string `gorm:"column:format" json:"format"`
Type string `gorm:"column:type" json:"type"`
Mode string `gorm:"column:mode" json:"mode"`
Length int `gorm:"column:length" json:"length"`
LeftPad string `gorm:"column:leftPad" json:"leftPad"`
RightPad string `gorm:"column:rightPad" json:"rightPad"`
Rand bool `gorm:"column:rand" json:"rand"`
Config string `gorm:"column:config" json:"config"`
Use string `gorm:"column:use" json:"use"`
From string `gorm:"column:fromCol" json:"fromCol"`
Select string `gorm:"column:selectCol" json:"selectCol"`
Where string `gorm:"column:whereCol" json:"whereCol"`
Limit int `gorm:"column:limitCol" json:"limitCol"`
FkFile string `gorm:"column:fkFile" json:"fkFile" yaml:"fkFile,omitempty"`
FkField string `gorm:"column:fkField" json:"fkField" yaml:"fkField,omitempty"`
FkRelation string `gorm:"column:fkRelation" json:"fkRelation" yaml:"fkRelation,omitempty"`
// refer to yaml or text by using range prop
Step string `gorm:"column:step" json:"step"`
......@@ -209,12 +212,15 @@ type ZdInstancesItem struct {
RightPad string `gorm:"column:rightPad" json:"rightPad" yaml:"rightPad,omitempty"`
Rand bool `gorm:"column:rand" json:"rand" yaml:"rand,omitempty"`
Config string `gorm:"column:config" json:"config" yaml:"config,omitempty"`
Use string `gorm:"column:use" json:"use" yaml:"use,omitempty"`
From string `gorm:"column:fromCol" json:"fromCol" yaml:"from,omitempty"`
Select string `gorm:"column:selectCol" json:"selectCol" yaml:"select,omitempty"`
Where string `gorm:"column:whereCol" json:"whereCol" yaml:"where,omitempty"`
Limit int `gorm:"column:limitCol" json:"limitCol" yaml:"limit,omitempty"`
Config string `gorm:"column:config" json:"config" yaml:"config,omitempty"`
Use string `gorm:"column:use" json:"use" yaml:"use,omitempty"`
From string `gorm:"column:fromCol" json:"fromCol" yaml:"from,omitempty"`
Select string `gorm:"column:selectCol" json:"selectCol" yaml:"select,omitempty"`
Where string `gorm:"column:whereCol" json:"whereCol" yaml:"where,omitempty"`
Limit int `gorm:"column:limitCol" json:"limitCol" yaml:"limit,omitempty"`
FkFile string `gorm:"column:fkFile" json:"fkFile" yaml:"fkFile,omitempty"`
FkField string `gorm:"column:fkField" json:"fkField" yaml:"fkField,omitempty"`
FkRelation string `gorm:"column:fkRelation" json:"fkRelation" yaml:"fkRelation,omitempty"`
Exp string `gorm:"column:exp" json:"exp" yaml:"exp,omitempty"`
InstancesID uint `gorm:"column:instancesID" json:"instancesID" yaml:"-"`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册