修复日志参数问题,用户请求的bug
This commit is contained in:
parent
5befe12ae6
commit
bfde7176eb
|
|
@ -47,7 +47,8 @@ func ScanUUID(c *gin.Context) {
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
res := worker.SetHash(id.String(), map[string]interface{}{"status": "0", "address": ReqData.Address, "ip": c.ClientIP()})
|
res := worker.SetHash(id.String(), map[string]interface{}{"status": "0", "address": ReqData.Address, "ip": c.ClientIP()})
|
||||||
if res {
|
if res {
|
||||||
c.JSON(200, gin.H{"code": 0, "message": "success", "data": id.String()})
|
data := worker.GetHashAll(id.String())
|
||||||
|
c.JSON(200, gin.H{"code": 0, "message": data, "data": id.String()})
|
||||||
} else {
|
} else {
|
||||||
c.JSON(200, gin.H{"code": 8, "message": "qr code invalid", "data": "1"})
|
c.JSON(200, gin.H{"code": 8, "message": "qr code invalid", "data": "1"})
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +57,10 @@ func ScanUUID(c *gin.Context) {
|
||||||
func SetQRStatus(c *gin.Context) {
|
func SetQRStatus(c *gin.Context) {
|
||||||
var qrsetReq QRReq
|
var qrsetReq QRReq
|
||||||
if err := c.ShouldBind(&qrsetReq); err == nil || qrsetReq.UUID != "" {
|
if err := c.ShouldBind(&qrsetReq); err == nil || qrsetReq.UUID != "" {
|
||||||
|
if worker.IsContainKey(qrsetReq.UUID) == false {
|
||||||
|
c.JSON(200, gin.H{"code": 18, "message": "uuid not found", "data": "0"})
|
||||||
|
return
|
||||||
|
}
|
||||||
res := worker.SetHashWithField(qrsetReq.UUID, "status", "1")
|
res := worker.SetHashWithField(qrsetReq.UUID, "status", "1")
|
||||||
if res {
|
if res {
|
||||||
data := worker.GetHashAll(qrsetReq.UUID)
|
data := worker.GetHashAll(qrsetReq.UUID)
|
||||||
|
|
|
||||||
7
main.go
7
main.go
|
|
@ -36,7 +36,12 @@ func writeLogger(c *gin.Context) {
|
||||||
params = c.Request.URL.RawQuery
|
params = c.Request.URL.RawQuery
|
||||||
}
|
}
|
||||||
if method == "POST" {
|
if method == "POST" {
|
||||||
params = c.Request.PostForm.Encode()
|
var data interface{}
|
||||||
|
err := c.ShouldBind(&data)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("bind json failed")
|
||||||
|
}
|
||||||
|
params = fmt.Sprintf("%v", data)
|
||||||
}
|
}
|
||||||
res := dao.InsertLogToDB(path, ip, method, params)
|
res := dao.InsertLogToDB(path, ip, method, params)
|
||||||
if res == 0 {
|
if res == 0 {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ func CloseRedis() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainKey(key string) bool {
|
func IsContainKey(key string) bool {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
val, err := redisClient.Exists(ctx, key).Result() // 检查键是否存在, 如果存在则返回 1, 否则返回 0
|
val, err := redisClient.Exists(ctx, key).Result() // 检查键是否存在, 如果存在则返回 1, 否则返回 0
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue