调整sql语句构建

This commit is contained in:
Mr.Li 2023-04-23 17:08:56 +08:00
parent 5898e5a15d
commit 7047dd5bb1
1 changed files with 3 additions and 2 deletions

View File

@ -86,7 +86,8 @@ func (t Task) GetSql(params map[string]interface{}) string {
m := regexp.MustCompile("({[a-zA-Z0-9]+})") m := regexp.MustCompile("({[a-zA-Z0-9]+})")
if strings.Trim(t.Elt, " ") != "" { if strings.Trim(t.Elt, " ") != "" {
wehre := m.ReplaceAllFunc([]byte(t.Elt), func(b []byte) []byte { sql = sql + " where " + t.Elt
build := m.ReplaceAllFunc([]byte(sql), func(b []byte) []byte {
field := string(b[1 : len(b)-1]) field := string(b[1 : len(b)-1])
if val, ok := params[field]; ok { if val, ok := params[field]; ok {
@ -95,7 +96,7 @@ func (t Task) GetSql(params map[string]interface{}) string {
return b return b
}) })
sql = sql + " where " + string(wehre) sql = string(build)
} }
if strings.Trim(t.Order, " ") != "" { if strings.Trim(t.Order, " ") != "" {