mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
[ADD] add debug print
This commit is contained in:
parent
0780e289a3
commit
7501d0812a
@ -25,6 +25,7 @@ import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
"github.com/jinzhu/gorm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
//AddModel AddModel
|
||||
@ -144,12 +145,14 @@ func (c *NotificationEventDaoImpl) AddModel(mo model.Interface) error {
|
||||
result.LastTime = time.Now()
|
||||
result.FirstTime = time.Now()
|
||||
var oldResult model.NotificationEvent
|
||||
if ok := c.DB.Where("hash=?", result.Hash).Find(&oldResult).RecordNotFound(); ok {
|
||||
if ok := c.DB.Where("hash = ?", result.Hash).Find(&oldResult).RecordNotFound(); ok {
|
||||
fmt.Println("=====>没有找到记录",result.Hash)
|
||||
if err := c.DB.Create(result).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("===>创建记录完成")
|
||||
} else {
|
||||
logrus.Infoln("event result is exist")
|
||||
logrus.Infoln("======>event result is exist")
|
||||
return c.UpdateModel(mo)
|
||||
}
|
||||
return nil
|
||||
@ -159,10 +162,12 @@ func (c *NotificationEventDaoImpl) AddModel(mo model.Interface) error {
|
||||
func (c *NotificationEventDaoImpl) UpdateModel(mo model.Interface) error {
|
||||
result := mo.(*model.NotificationEvent)
|
||||
var oldResult model.NotificationEvent
|
||||
if ok := c.DB.Where("hash=?", result.Hash).Find(&oldResult).RecordNotFound(); !ok {
|
||||
if ok := c.DB.Where("hash = ?", result.Hash).Find(&oldResult).RecordNotFound(); !ok {
|
||||
fmt.Println("=====>没找到哈希",result.Hash)
|
||||
result.FirstTime = oldResult.FirstTime
|
||||
result.ID = oldResult.ID
|
||||
}
|
||||
fmt.Println("====>保存")
|
||||
return c.DB.Save(result).Error
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user