This commit is contained in:
ycc 2022-05-20 14:05:54 +02:00
parent cb39a76dd9
commit 37f4990252
3 changed files with 12 additions and 2 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@
# Dependency directories (remove the comment below to include it)
# vendor/
sqldb-ws

View File

@ -104,12 +104,21 @@ func (t *TableController) GetAllTable() {
data, err := db.Table(table).GetAssociativeArray(columns, restriction, sortkeys, dir)
if err != nil {
log.Error().Msg(err.Error())
t.Data["json"] = map[string]string{"error": err.Error()}
t.Ctx.Output.SetStatus(http.StatusBadRequest)
} else {
t.Data["json"] = data
}
t.ServeJSON()
str, err := json.Marshal(data)
if err != nil {
log.Error().Msg(err.Error())
t.Ctx.Output.SetStatus(http.StatusBadRequest)
}
strToByte := []byte(strings.ReplaceAll(string(str), "\"\\u003cnil\\u003e\"", "null"))
t.Ctx.Output.Header("Content-Type", "application/json")
t.Ctx.Output.Body(strToByte)
t.Ctx.Output.SetStatus(http.StatusOK)
db.Close()
t.Ctx.Output.Body(strToByte)
}
// @Title GetAllTableColumn

BIN
sqldb-ws

Binary file not shown.