Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/Masterminds/semver/v3 v3.1.1
github.com/actiontech/dms v0.0.0-20231214070254-f5cbf6d30d45
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62
github.com/actiontech/mybatis-mapper-2-sql v0.5.0
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240119100929-4c4ddc90b1c2
github.com/agiledragon/gomonkey v2.0.2+incompatible
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/alibabacloud-go/darabonba-openapi v0.1.18
Expand Down Expand Up @@ -181,6 +181,6 @@ replace (
cloud.google.com/go/compute/metadata => cloud.google.com/go/compute/metadata v0.1.0
github.com/labstack/echo/v4 => github.com/labstack/echo/v4 v4.6.1
github.com/pingcap/log => github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9
github.com/pingcap/parser => github.com/sjjian/parser v0.0.0-20231122073510-03e191068cf1
github.com/pingcap/parser => github.com/sjjian/parser v0.0.0-20240119100847-3235e2338d0e
google.golang.org/grpc => google.golang.org/grpc v1.29.0
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ github.com/actiontech/dms v0.0.0-20231214070254-f5cbf6d30d45 h1:/gAzpuj3c5Agdbhp
github.com/actiontech/dms v0.0.0-20231214070254-f5cbf6d30d45/go.mod h1:jG8WjxiSBcUccweOqRPONDx95j88FwZytoa1/PI8I44=
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62 h1:JM7WnLzlvXOGE90KKd+aigi+qUDS+U5dLwQMNpTKZxE=
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62/go.mod h1:adDZHhAf2LRMx2h0JzofPXn12x2XlyQjVE116KXquwo=
github.com/actiontech/mybatis-mapper-2-sql v0.5.0 h1:TGovwZpLT+DUE5W0ZeSNE//LQLpVuQx8ghx0r8rPVBY=
github.com/actiontech/mybatis-mapper-2-sql v0.5.0/go.mod h1:ZMmUEDfbjm8oWxSAZkejqeOzlXa1BWNCfhNIxCMu7lw=
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240119100929-4c4ddc90b1c2 h1:Txeii4CZzDNbvvtGoJSFNcBTHyLD0uR6Sd16waQZSxY=
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240119100929-4c4ddc90b1c2/go.mod h1:ZMmUEDfbjm8oWxSAZkejqeOzlXa1BWNCfhNIxCMu7lw=
github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw=
github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -839,8 +839,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sjjian/parser v0.0.0-20231122073510-03e191068cf1 h1:0TrsSYbQFneiCIbZF3YWS0WJD5MP4J/CEoglDGrADUg=
github.com/sjjian/parser v0.0.0-20231122073510-03e191068cf1/go.mod h1:Qq2tnreUXwVo7NAKAHmbWFsgqpDUkxwhJCClY+ZCudA=
github.com/sjjian/parser v0.0.0-20240119100847-3235e2338d0e h1:f17wdoGuuBUt0U/YCidu9NIzZeLkkhooIBpODzIKuGs=
github.com/sjjian/parser v0.0.0-20240119100847-3235e2338d0e/go.mod h1:Qq2tnreUXwVo7NAKAHmbWFsgqpDUkxwhJCClY+ZCudA=
github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM=
github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down
14 changes: 7 additions & 7 deletions sqle/api/controller/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,26 @@ func JSONOnlySupportForEnterpriseVersionErr(c echo.Context) error {
return c.JSON(http.StatusOK, NewBaseReq(errors.NewOnlySupportForEnterpriseVersion()))
}

// ReadFileContent read content from http body by name if file exist,
// ReadFile read content from http body by name if file exist,
// the name is a http form data key, not file name.
func ReadFileContent(c echo.Context, name string) (content string, fileExist bool, err error) {
func ReadFile(c echo.Context, name string) (fileName, content string, fileExist bool, err error) {
file, err := c.FormFile(name)
if err == http.ErrMissingFile {
return "", false, nil
return "", "", false, nil
}
if err != nil {
return "", false, errors.New(errors.ReadUploadFileError, err)
return "", "", false, errors.New(errors.ReadUploadFileError, err)
}
src, err := file.Open()
if err != nil {
return "", false, errors.New(errors.ReadUploadFileError, err)
return "", "", false, errors.New(errors.ReadUploadFileError, err)
}
defer src.Close()
data, err := ioutil.ReadAll(src)
if err != nil {
return "", false, errors.New(errors.ReadUploadFileError, err)
return "", "", false, errors.New(errors.ReadUploadFileError, err)
}
return string(data), true, nil
return file.Filename, string(data), true, nil
}

// subjectUser should be admin user.
Expand Down
2 changes: 1 addition & 1 deletion sqle/api/controller/v1/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ type ParseProjectRuleTemplateFileResDataV1 struct {
// @router /v1/rule_templates/parse [post]
func ParseProjectRuleTemplateFile(c echo.Context) error {
// 读取+解析文件
file, exist, err := controller.ReadFileContent(c, "rule_template_file")
_, file, exist, err := controller.ReadFile(c, "rule_template_file")
if err != nil {
return controller.JSONBaseErrorReq(c, err)
}
Expand Down
Loading