This commit is contained in:
2023-08-17 12:42:41 +08:00
parent 875a4981a0
commit 449f471c06
4 changed files with 143 additions and 17 deletions

View File

@@ -196,20 +196,11 @@ func ExtDatabaseExecSQL(w http.ResponseWriter, r *http.Request) {
return
}
vars := mux.Vars(r)
tblName := vars["dataObject"]
//vars := mux.Vars(r)
//tblName := vars["dataObject"]
sql = GetUriSQLArray(r)
// select as must, todo ...
if sql == nil {
wc := services.GetUriLocString(r)
if wc == "" {
sql = append(sql, fmt.Sprintf("select * from %s", tblName))
} else {
sql = append(sql, fmt.Sprintf("select * from %s where %s", tblName, wc))
}
}
ls := services.ExtGetUriPageLimitString(r)
// data := make([]map[string]interface{}, 0)
@@ -219,7 +210,7 @@ func ExtDatabaseExecSQL(w http.ResponseWriter, r *http.Request) {
for i, s := range sql {
log.Tracef("SQL[%d]: %s", i, sql[i])
rows := make([]map[string]interface{}, 0)
//rows := make([]map[string]interface{}, 0)
mapRows := make(map[string]interface{})
if s != "" {
@@ -234,7 +225,7 @@ func ExtDatabaseExecSQL(w http.ResponseWriter, r *http.Request) {
querySQL = querySQL + " " + ls
}
log.Debug("querySQL:", querySQL)
rows, err = DbClient.XEngine.QueryInterface(querySQL)
rows, err := DbClient.XEngine.Exec(querySQL)
if err != nil {
log.Error("SQL failed:", err)
services.ResponseInternalServerError500DatabaseOperationFailed(w)