Skip to content

Commit 5da439b

Browse files
authored
Merge pull request #2226 from actiontech/sql-location
Sql location
2 parents 2bbb3b7 + 46285c4 commit 5da439b

File tree

30 files changed

+348
-296
lines changed

30 files changed

+348
-296
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/Masterminds/semver/v3 v3.1.1
88
github.com/actiontech/dms v0.0.0-20231214070254-f5cbf6d30d45
99
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62
10-
github.com/actiontech/mybatis-mapper-2-sql v0.5.0
10+
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240119100929-4c4ddc90b1c2
1111
github.com/agiledragon/gomonkey v2.0.2+incompatible
1212
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
1313
github.com/alibabacloud-go/darabonba-openapi v0.1.18
@@ -181,6 +181,6 @@ replace (
181181
cloud.google.com/go/compute/metadata => cloud.google.com/go/compute/metadata v0.1.0
182182
github.com/labstack/echo/v4 => github.com/labstack/echo/v4 v4.6.1
183183
github.com/pingcap/log => github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9
184-
github.com/pingcap/parser => github.com/sjjian/parser v0.0.0-20231122073510-03e191068cf1
184+
github.com/pingcap/parser => github.com/sjjian/parser v0.0.0-20240119100847-3235e2338d0e
185185
google.golang.org/grpc => google.golang.org/grpc v1.29.0
186186
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ github.com/actiontech/dms v0.0.0-20231214070254-f5cbf6d30d45 h1:/gAzpuj3c5Agdbhp
5252
github.com/actiontech/dms v0.0.0-20231214070254-f5cbf6d30d45/go.mod h1:jG8WjxiSBcUccweOqRPONDx95j88FwZytoa1/PI8I44=
5353
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62 h1:JM7WnLzlvXOGE90KKd+aigi+qUDS+U5dLwQMNpTKZxE=
5454
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62/go.mod h1:adDZHhAf2LRMx2h0JzofPXn12x2XlyQjVE116KXquwo=
55-
github.com/actiontech/mybatis-mapper-2-sql v0.5.0 h1:TGovwZpLT+DUE5W0ZeSNE//LQLpVuQx8ghx0r8rPVBY=
56-
github.com/actiontech/mybatis-mapper-2-sql v0.5.0/go.mod h1:ZMmUEDfbjm8oWxSAZkejqeOzlXa1BWNCfhNIxCMu7lw=
55+
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240119100929-4c4ddc90b1c2 h1:Txeii4CZzDNbvvtGoJSFNcBTHyLD0uR6Sd16waQZSxY=
56+
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240119100929-4c4ddc90b1c2/go.mod h1:ZMmUEDfbjm8oWxSAZkejqeOzlXa1BWNCfhNIxCMu7lw=
5757
github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw=
5858
github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=
5959
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -839,8 +839,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
839839
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
840840
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
841841
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
842-
github.com/sjjian/parser v0.0.0-20231122073510-03e191068cf1 h1:0TrsSYbQFneiCIbZF3YWS0WJD5MP4J/CEoglDGrADUg=
843-
github.com/sjjian/parser v0.0.0-20231122073510-03e191068cf1/go.mod h1:Qq2tnreUXwVo7NAKAHmbWFsgqpDUkxwhJCClY+ZCudA=
842+
github.com/sjjian/parser v0.0.0-20240119100847-3235e2338d0e h1:f17wdoGuuBUt0U/YCidu9NIzZeLkkhooIBpODzIKuGs=
843+
github.com/sjjian/parser v0.0.0-20240119100847-3235e2338d0e/go.mod h1:Qq2tnreUXwVo7NAKAHmbWFsgqpDUkxwhJCClY+ZCudA=
844844
github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM=
845845
github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo=
846846
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=

sqle/api/controller/base.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,26 @@ func JSONOnlySupportForEnterpriseVersionErr(c echo.Context) error {
123123
return c.JSON(http.StatusOK, NewBaseReq(errors.NewOnlySupportForEnterpriseVersion()))
124124
}
125125

126-
// ReadFileContent read content from http body by name if file exist,
126+
// ReadFile read content from http body by name if file exist,
127127
// the name is a http form data key, not file name.
128-
func ReadFileContent(c echo.Context, name string) (content string, fileExist bool, err error) {
128+
func ReadFile(c echo.Context, name string) (fileName, content string, fileExist bool, err error) {
129129
file, err := c.FormFile(name)
130130
if err == http.ErrMissingFile {
131-
return "", false, nil
131+
return "", "", false, nil
132132
}
133133
if err != nil {
134-
return "", false, errors.New(errors.ReadUploadFileError, err)
134+
return "", "", false, errors.New(errors.ReadUploadFileError, err)
135135
}
136136
src, err := file.Open()
137137
if err != nil {
138-
return "", false, errors.New(errors.ReadUploadFileError, err)
138+
return "", "", false, errors.New(errors.ReadUploadFileError, err)
139139
}
140140
defer src.Close()
141141
data, err := ioutil.ReadAll(src)
142142
if err != nil {
143-
return "", false, errors.New(errors.ReadUploadFileError, err)
143+
return "", "", false, errors.New(errors.ReadUploadFileError, err)
144144
}
145-
return string(data), true, nil
145+
return file.Filename, string(data), true, nil
146146
}
147147

148148
// subjectUser should be admin user.

sqle/api/controller/v1/rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ type ParseProjectRuleTemplateFileResDataV1 struct {
12111211
// @router /v1/rule_templates/parse [post]
12121212
func ParseProjectRuleTemplateFile(c echo.Context) error {
12131213
// 读取+解析文件
1214-
file, exist, err := controller.ReadFileContent(c, "rule_template_file")
1214+
_, file, exist, err := controller.ReadFile(c, "rule_template_file")
12151215
if err != nil {
12161216
return controller.JSONBaseErrorReq(c, err)
12171217
}

0 commit comments

Comments
 (0)