Skip to content

Commit

Permalink
fix: 修复表名大小写问题
Browse files Browse the repository at this point in the history
  • Loading branch information
j2go committed Jan 1, 2023
1 parent c282590 commit ce62b79
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Init(database string, dataSource string) {
for rows.Next() {
var name string
rows.Scan(&name)
name = strings.ToLower(name)
AllTable[name] = TableMeta{Name: name, Columns: loadColumnMeta(name)}
}
logger.Infof("LoadTableMeta END, Table size: %d", len(AllTable))
Expand Down
3 changes: 2 additions & 1 deletion handler/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (n *QueryNode) Result() interface{} {
}
return nil
}

func (n *QueryNode) doQueryData() {
if n.completed {
return
Expand Down Expand Up @@ -257,7 +258,7 @@ func (c *QueryContext) parseByKey(key string) {
func NewQueryNode(c *QueryContext, path, key string, queryMap map[string]interface{}) *QueryNode {
n := &QueryNode{
ctx: c,
Key: key,
Key: strings.ToLower(key),
Path: path,
RequestMap: queryMap,
start: time.Now().UnixNano(),
Expand Down
8 changes: 4 additions & 4 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"github.com/j2go/apijson/logger"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -15,14 +15,14 @@ func commonHandle(w http.ResponseWriter, r *http.Request, bodyHandler func(map[s
w.WriteHeader(http.StatusOK)
return
}
if data, err := ioutil.ReadAll(r.Body); err != nil {
if requestBody, err := io.ReadAll(r.Body); err != nil {
logger.Error("请求参数有问题: " + err.Error())
w.WriteHeader(http.StatusBadRequest)
return
} else {
logger.Infof("request: %s", string(data))
logger.Infof("request: %s", string(requestBody))
var bodyMap map[string]interface{}
if err = json.Unmarshal(data, &bodyMap); err != nil {
if err = json.Unmarshal(requestBody, &bodyMap); err != nil {
logger.Error("请求体 JSON 格式有问题: " + err.Error())
w.WriteHeader(http.StatusBadRequest)
return
Expand Down

0 comments on commit ce62b79

Please sign in to comment.