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

generate article yaml

上级 02737589
......@@ -85,6 +85,7 @@ type FieldSimple struct {
LoopIndex int `yaml:"-"`
IsRand bool `yaml:"-"`
IsReferYaml bool `yaml:"-"`
UseLastSameValue bool `yaml:"-"`
}
type FieldWithValues struct {
......@@ -123,4 +124,5 @@ type DefFieldExport struct {
Where string `yaml:"where"`
Rand bool `yaml:"rand"`
Limit int `yaml:"limit"`
UseLastSameValue bool `yaml:"useLastSameValue"`
}
\ No newline at end of file
package main
import (
"fmt"
"github.com/easysoft/zendata/src/model"
constant "github.com/easysoft/zendata/src/utils/const"
fileUtils "github.com/easysoft/zendata/src/utils/file"
......@@ -77,12 +78,28 @@ func createDef(typ, table string) (conf model.DefExport) {
func createField(index int, prefix, exp string) (field model.DefFieldExport) {
field.Field = strconv.Itoa(index)
field.Prefix = prefix
field.Select = getPinyin(exp)
field.Where = "true"
field.Rand = true
field.Limit = 1
// deal with exp like S:名词-姓+名词-名字=F
exp = strings.ToLower(strings.TrimSpace(exp))
expArr := []rune(exp)
if string(expArr[0]) == "s" && (string(expArr[1]) == ":" || string(expArr[1]) == ":") {
exp = string(expArr[2:])
expArr = expArr[2:]
field.UseLastSameValue = true
}
if strings.Index(exp, "=") == len(exp) - 2 {
exp = string(expArr[:len(expArr) - 2])
field.Select = getPinyin(exp)
field.Where = fmt.Sprintf("%s = %s", field.Select, string(expArr[len(expArr) - 1]))
} else {
field.Select = getPinyin(exp)
field.Where = "true"
}
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册