Skip to content

Commit 50b0200

Browse files
authored
Merge pull request #18 from j2go/master
fix: 修复表名大小写问题
2 parents 056676c + ce62b79 commit 50b0200

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
@@ -258,7 +259,7 @@ func (c *QueryContext) parseByKey(key string) {
258259
func NewQueryNode(c *QueryContext, path, key string, queryMap map[string]interface{}) *QueryNode {
259260
n := &QueryNode{
260261
ctx: c,
261-
Key: key,
262+
Key: strings.ToLower(key),
262263
Path: path,
263264
RequestMap: queryMap,
264265
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
"strings"
1010
)
@@ -16,14 +16,14 @@ func commonHandle(w http.ResponseWriter, r *http.Request, bodyHandler func(map[s
1616
w.WriteHeader(http.StatusOK)
1717
return
1818
}
19-
if data, err := ioutil.ReadAll(r.Body); err != nil {
19+
if requestBody, err := io.ReadAll(r.Body); err != nil {
2020
logger.Error("请求参数有问题: " + err.Error())
2121
w.WriteHeader(http.StatusBadRequest)
2222
return
2323
} else {
24-
logger.Infof("request: %s", string(data))
24+
logger.Infof("request: %s", string(requestBody))
2525
var bodyMap map[string]interface{}
26-
if err = json.Unmarshal(data, &bodyMap); err != nil {
26+
if err = json.Unmarshal(requestBody, &bodyMap); err != nil {
2727
logger.Error("请求体 JSON 格式有问题: " + err.Error())
2828
w.WriteHeader(http.StatusBadRequest)
2929
return

0 commit comments

Comments
 (0)