From 43850fdd5d3e95e2650cc48f1a76c761772b680b Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 14 Jun 2022 12:47:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mail_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 modules/mail_test.go diff --git a/modules/mail_test.go b/modules/mail_test.go new file mode 100644 index 000000000..d4b5da355 --- /dev/null +++ b/modules/mail_test.go @@ -0,0 +1,29 @@ +package modules + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/pb" + "testing" + "time" +) + +var ( + obj MComp_DBComp +) + +func TestCreatemoudles(t *testing.T) { + _mail := &pb.DB_MailData{ + + UserId: "uid123", + Title: "系统邮件", + Contex: "恭喜获得专属礼包一份", + CreateTime: uint64(time.Now().Unix()), + DueTime: uint64(time.Now().Unix()) + 30*24*3600, + Check: false, + Reward: false, + } + obj.InsertModelLogs("mail", "uid123", comm.LogHandleType_Insert, _mail) + + log.Debugf("insert : %v", _mail) +} From c63c16a2b7a472b208b92b2883a1e191326e4adc Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 14 Jun 2022 12:54:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/db_comp.go | 12 ++++++------ modules/mail_test.go | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/db_comp.go b/modules/db_comp.go index c419f5a94..3fdbedf59 100644 --- a/modules/db_comp.go +++ b/modules/db_comp.go @@ -36,12 +36,12 @@ func (this *MComp_DBComp) Start() (err error) { return } -func (this *MComp_DBComp) InsertModelLogs(table string, uID string, dbType comm.LogHandleType, where interface{}, target interface{}) (err error) { +func (this *MComp_DBComp) InsertModelLogs(table string, uID string, target interface{}) (err error) { data := &comm.Autogenerated{ ID: primitive.NewObjectID().Hex(), UID: uID, - Act: string(dbType), + Act: string(comm.LogHandleType_Insert), } data.D = append(data.D, table) // D[0] data.D = append(data.D, target) // D[1] @@ -53,12 +53,12 @@ func (this *MComp_DBComp) InsertModelLogs(table string, uID string, dbType comm. return err } -func (this *MComp_DBComp) DeleteModelLogs(table string, uID string, dbType comm.LogHandleType, where interface{}, target interface{}) (err error) { +func (this *MComp_DBComp) DeleteModelLogs(table string, uID string, where interface{}, target interface{}) (err error) { data := &comm.Autogenerated{ ID: primitive.NewObjectID().Hex(), UID: uID, - Act: string(dbType), + Act: string(comm.LogHandleType_Delete), } data.D = append(data.D, table) // D[0] @@ -72,12 +72,12 @@ func (this *MComp_DBComp) DeleteModelLogs(table string, uID string, dbType comm. return err } -func (this *MComp_DBComp) UpdateModelLogs(table string, uID string, dbType comm.LogHandleType, where interface{}, target interface{}) (err error) { +func (this *MComp_DBComp) UpdateModelLogs(table string, uID string, where interface{}, target interface{}) (err error) { data := &comm.Autogenerated{ ID: primitive.NewObjectID().Hex(), UID: uID, - Act: string(dbType), + Act: string(comm.LogHandleType_Update), } data.D = append(data.D, table) // D[0] data.D = append(data.D, where) // D[1] diff --git a/modules/mail_test.go b/modules/mail_test.go index d4b5da355..37f6b3c8a 100644 --- a/modules/mail_test.go +++ b/modules/mail_test.go @@ -1,7 +1,6 @@ package modules import ( - "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "testing" @@ -23,7 +22,7 @@ func TestCreatemoudles(t *testing.T) { Check: false, Reward: false, } - obj.InsertModelLogs("mail", "uid123", comm.LogHandleType_Insert, _mail) + obj.InsertModelLogs("mail", "uid123", _mail) log.Debugf("insert : %v", _mail) }