From 5f0c222a21871591214988569e86ea86403f3f8f Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 13 Sep 2022 17:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A3=85=E5=A4=87=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E6=95=B0=E6=8D=AE=E6=A0=A1=E9=AA=8C=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=20=E5=8D=B4=E8=BF=94=E5=9B=9E=E6=AD=A3=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/db/dbconn.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index 4bd5ec27a..7cf6cd1df 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -582,12 +582,15 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er c *mongo.Cursor keys map[string]string tempdata map[string]string + isfound bool ) keys = make(map[string]string) if err = this.Redis.HGetAll(this.ukeylist(uid, id), data); err != nil && err != lgredis.RedisNil { return } + isfound = true if err == lgredis.RedisNil { + isfound = false if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil { return err } else { @@ -611,6 +614,7 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er if tempdata, err = json.MarshalMap(data); err != nil { return } + isfound = true } key := this.ukeylist(uid, _id) pipe.HMSetForMap(key, tempdata) @@ -622,7 +626,10 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er } } } - + if !isfound { + err = fmt.Errorf("no found data table:%s uid:%s id:%s", this.TableName, uid, id) + return + } if this.Expired > 0 { childs := make(map[string]struct{}, len(keys)) for _, v := range keys {