@@ -22,8 +22,8 @@ import (
2222 "github.com/360EntSecGroup-Skylar/excelize"
2323 log "github.com/cihub/seelog"
2424 "github.com/infinitbyte/framework/core/pipeline"
25- "strings"
2625 "github.com/infinitbyte/framework/core/util"
26+ "strings"
2727)
2828
2929type ConvertSQLJoint struct {
@@ -36,10 +36,10 @@ func (joint ConvertSQLJoint) Name() string {
3636
3737const excelBytesKey = "excelBytes"
3838
39- var rowFormat pipeline.ParaKey = "row_format"
40- var sheetName pipeline.ParaKey = "sheet_name"
41- var columnName pipeline.ParaKey = "column_name"
42- var dataFromIndex pipeline.ParaKey = "data_start_from_index"
39+ var rowFormatKey pipeline.ParaKey = "row_format"
40+ var sheetNameKey pipeline.ParaKey = "sheet_name"
41+ var columnNameKey pipeline.ParaKey = "column_name"
42+ var dataFromIndexKey pipeline.ParaKey = "data_start_from_index"
4343
4444var sqlKey pipeline.ParaKey = "sql"
4545
@@ -48,7 +48,7 @@ func (joint ConvertSQLJoint) Process(c *pipeline.Context) error {
4848 excelBytes := c .MustGetBytes (excelBytesKey )
4949 r := bytes .NewReader (excelBytes )
5050
51- templates := joint .MustGetStringArray (rowFormat )
51+ templates := joint .MustGetStringArray (rowFormatKey )
5252 log .Debug ("row templates: " , templates )
5353
5454 xlsx , err := excelize .OpenReader (r )
@@ -59,10 +59,12 @@ func (joint ConvertSQLJoint) Process(c *pipeline.Context) error {
5959 sheetMap := xlsx .GetSheetMap ()
6060 log .Debug ("sheets: " , sheetMap )
6161
62- colNames := joint .MustGetStringArray (columnName )
63- dataOffset := joint .MustGetInt (dataFromIndex )
62+ colNames := joint .MustGetStringArray (columnNameKey )
63+ dataOffset := joint .MustGetInt (dataFromIndexKey )
64+
65+ sheetName := joint .MustGetString (sheetNameKey )
6466
65- rows := xlsx .GetRows (joint . MustGetString ( sheetName ) )
67+ rows := xlsx .GetRows (sheetName )
6668
6769 var sqlBuffer bytes.Buffer
6870 for offset , row := range rows {
@@ -100,13 +102,19 @@ func (joint ConvertSQLJoint) Process(c *pipeline.Context) error {
100102 }
101103 }
102104
103- c .Set (sqlKey , sqlBuffer .String ())
105+ sqlMap , ok := c .GetMap (sqlKey )
106+ if ! ok {
107+ sqlMap = map [string ]interface {}{}
108+ }
109+
110+ sqlText := sqlBuffer .String ()
111+ sqlMap [sheetName ] = sqlText
112+ c .Set (sqlKey , sqlMap )
104113
105114 log .Trace (sqlBuffer .String ())
106115 return nil
107116}
108117
109-
110118func formatString (str string ) string {
111119 str = strings .Replace (str , "\" " , "" , - 1 )
112120 str = strings .Replace (str , "'" , "" , - 1 )
0 commit comments