Skip to content

Commit ce62b79

Browse files
committed
fix: 修复表名大小写问题
1 parent c282590 commit ce62b79

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

db/db.go

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func Init(database string, dataSource string) {
5050
for rows.Next() {
5151
var name string
5252
rows.Scan(&name)
53+
name = strings.ToLower(name)
5354
AllTable[name] = TableMeta{Name: name, Columns: loadColumnMeta(name)}
5455
}
5556
logger.Infof("LoadTableMeta END, Table size: %d", len(AllTable))

handler/get.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func (n *QueryNode) Result() interface{} {
151151
}
152152
return nil
153153
}
154+
154155
func (n *QueryNode) doQueryData() {
155156
if n.completed {
156157
return
@@ -257,7 +258,7 @@ func (c *QueryContext) parseByKey(key string) {
257258
func NewQueryNode(c *QueryContext, path, key string, queryMap map[string]interface{}) *QueryNode {
258259
n := &QueryNode{
259260
ctx: c,
260-
Key: key,
261+
Key: strings.ToLower(key),
261262
Path: path,
262263
RequestMap: queryMap,
263264
start: time.Now().UnixNano(),

handler/handler.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"github.com/j2go/apijson/logger"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
)
1010

@@ -15,14 +15,14 @@ func commonHandle(w http.ResponseWriter, r *http.Request, bodyHandler func(map[s
1515
w.WriteHeader(http.StatusOK)
1616
return
1717
}
18-
if data, err := ioutil.ReadAll(r.Body); err != nil {
18+
if requestBody, err := io.ReadAll(r.Body); err != nil {
1919
logger.Error("请求参数有问题: " + err.Error())
2020
w.WriteHeader(http.StatusBadRequest)
2121
return
2222
} else {
23-
logger.Infof("request: %s", string(data))
23+
logger.Infof("request: %s", string(requestBody))
2424
var bodyMap map[string]interface{}
25-
if err = json.Unmarshal(data, &bodyMap); err != nil {
25+
if err = json.Unmarshal(requestBody, &bodyMap); err != nil {
2626
logger.Error("请求体 JSON 格式有问题: " + err.Error())
2727
w.WriteHeader(http.StatusBadRequest)
2828
return

0 commit comments

Comments
 (0)