diff --git a/modules/mail/api_readmail.go b/modules/mail/api_readmail.go index 0a1eacff5..85b5d4b15 100644 --- a/modules/mail/api_readmail.go +++ b/modules/mail/api_readmail.go @@ -2,6 +2,7 @@ package mail import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -24,6 +25,7 @@ func (this *apiComp) ReadMail(session comm.IUserSession, req *pb.MailReadMailReq code = this.ReadMailCheck(session, req) // check if code != pb.ErrorCode_Success { + log.Debugf("read mail failed%d", code) return } mail, err = this.module.modelMail.Mail_ReadOneMail(req.ObjID) @@ -31,6 +33,7 @@ func (this *apiComp) ReadMail(session comm.IUserSession, req *pb.MailReadMailReq code = pb.ErrorCode_ReqParameterError return } + log.Debugf("read mail %v", mail) mail.Check = true session.SendMsg(string(this.module.GetType()), "readmail", &pb.MailReadMailResp{Mail: mail}) return diff --git a/sys/db/init_test.go b/sys/db/init_test.go index cbd84fc9e..3a1cfc34c 100644 --- a/sys/db/init_test.go +++ b/sys/db/init_test.go @@ -1,16 +1,21 @@ package db import ( + "fmt" "go_dreamfactory/lego/sys/mgo" + "go_dreamfactory/pb" "log" "os" "testing" + + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" ) var db *DB func TestMain(m *testing.M) { - imgo, err := mgo.NewSys(mgo.SetMongodbUrl("mongodb://admin:123456@10.0.0.9:27018"), mgo.SetMongodbDatabase("dreamfactory")) + imgo, err := mgo.NewSys(mgo.SetMongodbUrl("mongodb://10.0.0.9:10013"), mgo.SetMongodbDatabase("dreamfactory")) if err != nil { log.Fatal(err) } @@ -20,3 +25,15 @@ func TestMain(m *testing.M) { } defer os.Exit(m.Run()) } +func TestMail(t *testing.T) { + mail := &pb.DBMailData{} + err := db.mgo.FindOneAndUpdate( + "mail", + bson.M{"_id": "62e784aa78d6d7bf12fb1f0e"}, + bson.M{"$set": bson.M{ + "check": true, + }}, + options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After), + ).Decode(&mail) + fmt.Printf("%v", err) +}