diff --git a/demo/article.yaml b/demo/article.yaml index 789f09193729edb09beee992c64753e917750801..e7d7c1fc7ce810c292c2f377cefc974be752e1b8 100644 --- a/demo/article.yaml +++ b/demo/article.yaml @@ -10,7 +10,7 @@ fields: fields: - field: title1 type: list - range: "Title" + range: "[标题A,TitleB]" postfix: "-" - field: title2 range: 1-999 diff --git a/src/action/generator.go b/src/action/generator.go index 9f04c78a9ed839956b2c4314d7ecb15dd29f41dc..826e80b8682c251493cca1a2eb2b8ef8acfa1cbf 100644 --- a/src/action/generator.go +++ b/src/action/generator.go @@ -139,6 +139,8 @@ func Print(rows [][]string, format string, table string, colTypes []bool, fields } func RowsToMap(rows [][]string, fieldsToExport []string) (ret map[string]string) { + ret = map[string]string{} + for _, cols := range rows { for j, col := range cols { ret[fieldsToExport[j]] = col diff --git a/src/gen/list.go b/src/gen/list.go index d58c005fb54c8e82af59fb3301ad2212f05667ba..bee1f10f2296cc3b19b87bbc8ed1e313d18184f4 100644 --- a/src/gen/list.go +++ b/src/gen/list.go @@ -128,16 +128,22 @@ func ParseRange(rang string) []string { tagOpen := false temp := "" - for i := 0; i < len(rang); i++ { - c := rang[i] - if int32(c) == constant.RightChar { + runeArr := make([]rune, 0) + for _, c := range rang { + runeArr = append(runeArr, c) + } + + for i := 0; i < len(runeArr); i++ { + c := runeArr[i] + + if c == constant.RightChar { tagOpen = false - } else if int32(c) == constant.LeftChar { + } else if c == constant.LeftChar { tagOpen = true } - if i == len(rang) - 1 { + if i == len(runeArr) - 1 { temp += fmt.Sprintf("%c", c) items = append(items, temp) } else if !tagOpen && c == ',' { diff --git a/src/utils/const/const.go b/src/utils/const/const.go index e2c69fd147e22f986e6e981fd4736b9929725ed0..0edab151f36bb913b97321b089f3b494ee56ee6e 100644 --- a/src/utils/const/const.go +++ b/src/utils/const/const.go @@ -31,8 +31,8 @@ var ( Def = model.DefData{} Res = map[string]map[string][]string{} - LeftChar = '(' - RightChar = ')' + LeftChar rune = '(' + RightChar rune = ')' ResDir = "data/" ResPath = ResDir + "system/buildin.yaml"