提交 371b6d26 编写于 作者: 陈琦

close task#36575 服务模式下支持-T参数 #2

上级 565e60f1
......@@ -4,3 +4,5 @@ version: 1.0
fields:
- field: first # 字段名
range: 1-5, 30 # 1,2,3,4,5,30,1,2,3,4,5
prefix: "=="
postfix: "--"
\ No newline at end of file
......@@ -6,14 +6,16 @@ import (
"github.com/easysoft/zendata/src/utils/vari"
"net/http"
"strconv"
"strings"
)
func ParseGenParams(req *http.Request) (defaultFile, configFile, fields string, count int,
format, table string, decode bool, input, output string) {
format string, trim bool, table string, decode bool, input, output string) {
query := req.URL.Query()
defaultFile = ParserGetParams(query, "default", "d")
configFile = ParserGetParams(query, "config", "c")
trimStr := ParserGetParams(query, "trim", "T")
countStr := ParserGetParams(query, "lines", "n")
if countStr == "" {
countStr = "10"
......@@ -27,9 +29,10 @@ func ParseGenParams(req *http.Request) (defaultFile, configFile, fields string,
if req.Method == http.MethodPost {
req.ParseForm()
countStr = ParserPostParams(req, "lines", "n", countStr, false)
defaultDefContent := ParserPostParams(req, "default", "d", "", true)
configDefContent := ParserPostParams(req, "config", "c", "", true)
trimStr = ParserPostParams(req, "trim", "T", trimStr, false)
countStr = ParserPostParams(req, "lines", "n", countStr, false)
if defaultDefContent != "" {
defaultFile = vari.ZdPath + "tmp" + constant.PthSep + ".default.yaml"
......@@ -41,9 +44,14 @@ func ParseGenParams(req *http.Request) (defaultFile, configFile, fields string,
}
}
countFromPForm, err := strconv.Atoi(countStr)
trimStr = strings.ToLower(strings.TrimSpace(trimStr))
if trimStr == "t" || trimStr == "true" {
trim = true
}
countFromForm, err := strconv.Atoi(countStr)
if err == nil {
count = countFromPForm
count = countFromForm
}
return
......
......@@ -263,7 +263,7 @@ func DataHandler(writer http.ResponseWriter, req *http.Request) {
logUtils.HttpWriter = writer
defaultFile, configFile, fields, vari.Total,
format, table, decode, input, output = serverUtils.ParseGenParams(req)
format, vari.Trim, table, decode, input, output = serverUtils.ParseGenParams(req)
if decode {
gen.Decode(defaultFile, configFile, fields, input, output)
......
......@@ -75,6 +75,7 @@ export default {
},
watch: {
id: function() {
console.log('watch id ' + this.id)
this.loadData();
}
},
......
......@@ -127,7 +127,7 @@ instances:
note: 字母和数字混合的域名
fields:
- field: numbers_and_letters
range: "[a-z,0-9]:R"
range: "[a-z,0-9]"
loop: 5-8
postfix: "."
- field: domain_postfix
......@@ -173,4 +173,4 @@ instances:
postfix: "."
- field: domain_postfix
from: domain.postfix.v1.yaml
use: new
\ No newline at end of file
use: cn
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册