|
@@ -50,24 +50,24 @@ func (c *GatewayRelation) Update(gatewayId int64) error {
|
|
|
//sql = strings.ReplaceAll(sql, "@id", string(gatewayId))
|
|
|
//fmt.Printf("sql = %v", sql)
|
|
|
//Db.Model(&c).Debug().Exec(sql, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId).Scan(&relation)
|
|
|
- Db.Model(&c).Debug().Exec(sql).Scan(&relation)
|
|
|
+ Db.Debug().Model(&c).Exec(sql).Scan(&relation)
|
|
|
fmt.Printf("relation1 = %v", relation)
|
|
|
return nil
|
|
|
- relation.Total = relation.CameraCount + relation.LightControlCount + relation.InfoBoardCount +
|
|
|
- relation.OptoSensorCount + relation.ZigbeeCount + relation.AlarmTerminalCount +
|
|
|
- relation.CaptureUnitCount + relation.IpBroadcastCount + relation.CurveSensorCount
|
|
|
- fmt.Printf("relation2 = %v", relation)
|
|
|
- //return nil
|
|
|
- var count int64
|
|
|
- _ = Db.Debug().Model(&c).Where(" id = ? ", gatewayId).Count(&count)
|
|
|
- fmt.Printf("count = %v", count)
|
|
|
- if count > 0 {
|
|
|
- relation.UpdateTime = time.Now()
|
|
|
- return Db.Debug().Model(&c).Where(" id = ? ", gatewayId).Updates(&relation).Error
|
|
|
- } else {
|
|
|
- relation.ID = int(gatewayId)
|
|
|
- relation.UpdateTime = time.Now()
|
|
|
- relation.CreateTime = time.Now()
|
|
|
- return Db.Debug().Model(&c).Create(&relation).Error
|
|
|
- }
|
|
|
+ //relation.Total = relation.CameraCount + relation.LightControlCount + relation.InfoBoardCount +
|
|
|
+ // relation.OptoSensorCount + relation.ZigbeeCount + relation.AlarmTerminalCount +
|
|
|
+ // relation.CaptureUnitCount + relation.IpBroadcastCount + relation.CurveSensorCount
|
|
|
+ //fmt.Printf("relation2 = %v", relation)
|
|
|
+ ////return nil
|
|
|
+ //var count int64
|
|
|
+ //_ = Db.Debug().Model(&c).Where(" id = ? ", gatewayId).Count(&count)
|
|
|
+ //fmt.Printf("count = %v", count)
|
|
|
+ //if count > 0 {
|
|
|
+ // relation.UpdateTime = time.Now()
|
|
|
+ // return Db.Debug().Model(&c).Where(" id = ? ", gatewayId).Updates(&relation).Error
|
|
|
+ //} else {
|
|
|
+ // relation.ID = int(gatewayId)
|
|
|
+ // relation.UpdateTime = time.Now()
|
|
|
+ // relation.CreateTime = time.Now()
|
|
|
+ // return Db.Debug().Model(&c).Create(&relation).Error
|
|
|
+ //}
|
|
|
}
|