diff --git a/demo/test.yaml b/demo/test.yaml index 5a0c47c82587e5b1488dc41c15ff37584d9b7016..a3a9b963923eef252bee75cae735211d4be916db 100644 --- a/demo/test.yaml +++ b/demo/test.yaml @@ -21,7 +21,7 @@ fields: postfix: "]" # 特殊字符加引号,否则无法解析 - field: field_nested_range # 引用的range使用多层嵌套的use定义 - from: system.misc.number.yaml # 引用data/system/misc/number.yaml + from: custom.number.v1.yaml # 引用data/system/misc/number.yaml use: all # 使用该文件中定义的privateC和privateB两个实例。 prefix: "[" # 复写前缀 postfix: "]" # 特殊字符加引号,否则无法解析 diff --git a/res/en/messages.json b/res/en/messages.json index 570acd0289f54af50d35206c8a3a02f7333e3629..5c9419ba961cc002dccc6ec73fadfe05974e82bb 100644 --- a/res/en/messages.json +++ b/res/en/messages.json @@ -95,7 +95,15 @@ }, { "id": "start_server", - "translation": "Success yo start zendata http service, press CTRL+C to exist. \nYou may use http://%s:%s to retrieve the data,for example: \n curl http://%s:%s/?default=demo/default.yaml&config=demo/test.yaml&lines=100." + "translation": "Success yo start zendata http service, press CTRL+C to exist. \nYou may use http://%s:%s to retrieve the data,for example: \ncurl http://%s:%s/?config=demo/default.yaml&F=field_common&lines=10." + }, + { + "id": "server_request", + "translation": "\nGot %s request %s." + }, + { + "id": "server_response", + "translation": "\nCreate %d records in %d sec." }, { "id": "excel_data", diff --git a/res/zh/messages.json b/res/zh/messages.json index 6e13d5a449707ebb7f260dcecc2c5be55886c8c6..433c4d1b21b631363ec08f219bc7b5227fc43ab9 100644 --- a/res/zh/messages.json +++ b/res/zh/messages.json @@ -86,7 +86,15 @@ }, { "id": "start_server", - "translation": "zendata http服务已经成功运行,按CTRL+C键推出。\n您可以通过http://%s:%s地址来调用,比如:\n curl http://%s:%s/?default=demo/default.yaml&config=demo/test.yaml&lines=100." + "translation": "zendata http服务已经成功运行,按CTRL+C键推出。\n您可以通过http://%s:%s地址来调用,比如:\ncurl http://%s:%s/?config=demo/default.yaml&F=field_common&lines=10。" + }, + { + "id": "server_request", + "translation": "\n收到%s请求 %s." + }, + { + "id": "server_response", + "translation": "生成%d条记录,耗时%d秒" }, { "id": "excel_data", diff --git a/src/action/generator.go b/src/action/generator.go index 5b45e4d3a711bf3a107927b0dca97a67b9d26f5b..7182f389bf6072d5cf0cab51b42f17e51a2ec801 100644 --- a/src/action/generator.go +++ b/src/action/generator.go @@ -7,13 +7,15 @@ import ( "github.com/easysoft/zendata/src/gen" "github.com/easysoft/zendata/src/model" constant "github.com/easysoft/zendata/src/utils/const" + i118Utils "github.com/easysoft/zendata/src/utils/i118" logUtils "github.com/easysoft/zendata/src/utils/log" "github.com/easysoft/zendata/src/utils/vari" "strings" + "time" ) func Generate(defaultFile string, configFile string, total int, fieldsToExportStr string, out string, format string, table string) { - //startTime := time.Now().Unix() + startTime := time.Now().Unix() if defaultFile != "" && configFile == "" { configFile = defaultFile @@ -35,8 +37,10 @@ func Generate(defaultFile string, configFile string, total int, fieldsToExportSt WriteToFile(out, content) } - //entTime := time.Now().Unix() - //logUtils.Screen(i118Utils.I118Prt.Sprintf("generate_records", len(rows), out, entTime - startTime )) + entTime := time.Now().Unix() + if vari.RunMode == constant.RunModeServerRequest { + logUtils.PrintTo(i118Utils.I118Prt.Sprintf("server_response", len(rows), entTime - startTime)) + } } func Print(rows [][]string, format string, table string, colTypes []bool, fields []string) (string, string) { @@ -51,7 +55,9 @@ func Print(rows [][]string, format string, table string, colTypes []bool, fields line += vari.HeadSep } } - logUtils.Screen(fmt.Sprintf("%s", line)) + if vari.RunMode != constant.RunModeServerRequest { + logUtils.Screen(fmt.Sprintf("%s", line)) + } content += line + "\n" } @@ -82,7 +88,9 @@ func Print(rows [][]string, format string, table string, colTypes []bool, fields content = content + line + "\n" } - logUtils.Screen(fmt.Sprintf("%s", line)) + if vari.RunMode != constant.RunModeServerRequest { + logUtils.Screen(fmt.Sprintf("%s", line)) + } testData.Table.Rows = append(testData.Table.Rows, row) diff --git a/src/zd.go b/src/zd.go index edf8adf083355845130dcfc4584ee1a5ff85ced6..c09e74fab48d9adbe41c00ee58ae57d75b781c0d 100644 --- a/src/zd.go +++ b/src/zd.go @@ -194,6 +194,8 @@ func StartServer() { } func DataHandler(w http.ResponseWriter, req *http.Request) { + + root, defaultFile, configFile, fields, count, vari.HeadSep, format, table, decode, input, output = service.ParseRequestParams(req) @@ -202,6 +204,7 @@ func DataHandler(w http.ResponseWriter, req *http.Request) { fmt.Fprintln(w, vari.JsonResp) } else if defaultFile != "" || configFile != "" { vari.RunMode = constant.RunModeServerRequest + logUtils.PrintTo(i118Utils.I118Prt.Sprintf("server_request", req.Method, req.URL)) toGen() fmt.Fprintln(w, vari.JsonResp) }