diff --git a/studio/studio.go b/studio/studio.go new file mode 100644 index 00000000..6c2ab6ef --- /dev/null +++ b/studio/studio.go @@ -0,0 +1,3 @@ +package studio + +// Yao Studio diff --git a/table/process.go b/table/process.go index 279a8a74..cab31d05 100644 --- a/table/process.go +++ b/table/process.go @@ -9,6 +9,7 @@ import ( "strings" "time" + jsoniter "github.com/json-iterator/go" "github.com/yaoapp/gou" "github.com/yaoapp/kun/any" "github.com/yaoapp/kun/log" @@ -344,6 +345,7 @@ func ProcessSelect(process *gou.Process) interface{} { // Export query result to Excel func ProcessExport(process *gou.Process) interface{} { + debug := os.Getenv("YAO_EXPORT_DEBUG") != "" process.ValidateArgNums(1) name := process.ArgsString(0) table := Select(name) @@ -372,6 +374,11 @@ func ProcessExport(process *gou.Process) interface{} { pagesize = process.ArgsInt(3, api.DefaultInt(1)) } + if debug { + bytes, _ := jsoniter.Marshal(param) + log.Info("[Export] %s %s %d %d Params: %s", api.Process, filename, page, pagesize, string(bytes)) + } + // 查询数据 response := gou.NewProcess(api.Process, param, page, pagesize). WithGlobal(process.Global). @@ -381,6 +388,11 @@ func ProcessExport(process *gou.Process) interface{} { // After Hook response = table.After(table.Hooks.AfterSearch, response, []interface{}{param, page, pagesize}, process.Sid) + if debug { + bytes, _ := jsoniter.Marshal(response) + log.Info("[Export] %s %d %d Prepare: %s", filename, page, pagesize, string(bytes)) + } + res, ok := response.(map[string]interface{}) if !ok { res, ok = response.(maps.MapStrAny) diff --git a/table/process_test.go b/table/process_test.go index c984fbb0..05c9e188 100644 --- a/table/process_test.go +++ b/table/process_test.go @@ -9,7 +9,6 @@ import ( "github.com/yaoapp/gou" "github.com/yaoapp/kun/any" "github.com/yaoapp/kun/maps" - "github.com/yaoapp/kun/utils" "github.com/yaoapp/xun/capsule" "github.com/yaoapp/yao/config" "github.com/yaoapp/yao/flow" @@ -58,7 +57,7 @@ func TestTableProcessSearchWithHook(t *testing.T) { args := []interface{}{"hooks.search"} response := gou.NewProcess("xiang.table.Search", args...).Run() - utils.Dump(response) + // utils.Dump(response) assert.NotNil(t, response) res := any.Of(response).Map() diff --git a/table/table.go b/table/table.go index 39b24125..452abd71 100644 --- a/table/table.go +++ b/table/table.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/gin-gonic/gin" + jsoniter "github.com/json-iterator/go" "github.com/xuri/excelize/v2" "github.com/yaoapp/gou" "github.com/yaoapp/gou/helper" @@ -350,6 +351,13 @@ func (table *Table) loadColumns() { // Export Export query result to Excel func (table *Table) Export(filename string, data interface{}, page int, chunkSize int) error { + debug := os.Getenv("YAO_EXPORT_DEBUG") != "" + + if debug { + bytes, _ := jsoniter.Marshal(data) + log.Info("[Export] %s %d %d Before: %s", filename, page, chunkSize, string(bytes)) + } + rows := []maps.MapStr{} if values, ok := data.([]maps.MapStrAny); ok { for _, row := range values { @@ -365,6 +373,11 @@ func (table *Table) Export(filename string, data interface{}, page int, chunkSiz } } + if debug { + bytes, _ := jsoniter.Marshal(rows) + log.Info("[Export] %s %d %d After: %s", filename, page, chunkSize, string(bytes)) + } + columns, err := table.exportSetting() if err != nil { return err