|
@@ -25,8 +25,8 @@ type Screens struct {
|
|
|
Status int `gorm:"type:int;default:0" json:"status"` //在线状态 0=离线,1=在线
|
|
|
DayBright int `gorm:"type:int;default:100" json:"dayBright"` //白天亮度
|
|
|
NightBright int `gorm:"type:int;default:10" json:"nightBright"` //晚上亮度
|
|
|
- LastOnlineTime time.Time `gorm:"type:datetime;default:NULL" json:"lastOnlineTime"` //最近在线时间
|
|
|
- LastOfflineTime time.Time `gorm:"type:datetime;default:NULL" json:"lastOfflineTime"` //最近离线时间
|
|
|
+ LastOnlineTime *time.Time `gorm:"type:datetime;default:NULL" json:"lastOnlineTime"` //最近在线时间
|
|
|
+ LastOfflineTime *time.Time `gorm:"type:datetime;default:NULL" json:"lastOfflineTime"` //最近离线时间
|
|
|
IsLogin int `gorm:"type:int;default:0" json:"isLogin"` //是否登录 0=未登录,1=登录
|
|
|
SwitchSn string `gorm:"type:varchar(25)" json:"switchSn"` //时控开关sn
|
|
|
AudioOn string `gorm:"type:varchar(10);default:'00:00'" json:"audioOn"` //声音开时间
|
|
@@ -58,23 +58,26 @@ func (s Screens) AddScreens() error {
|
|
|
|
|
|
func (s Screens) UpdateScreens() error {
|
|
|
err := global.GVA_DB.Model(&s).
|
|
|
- Select("screens_name", "screens_code", "sn", "network", "gateway_id", "screens_brand", "screens_model", "ip_address", "install_time", "shunt", "shunt_describe", "resolution_id", "screens_size_id", "switch_sn").
|
|
|
+ Select("screens_name", "screens_code", "sn", "network", "gateway_id", "screens_brand", "screens_model", "ip_address", "install_time", "shunt", "shunt_describe", "resolution_id", "screens_size_id", "switch_sn", "status", "last_online_time", "Last_offline_time").
|
|
|
Where("id=?", s.ID).
|
|
|
Updates(map[string]interface{}{
|
|
|
- "screens_name": s.ScreensName,
|
|
|
- "screens_code": s.ScreensCode,
|
|
|
- "sn": s.Sn,
|
|
|
- "network": s.Network,
|
|
|
- "gateway_id": s.GatewayId,
|
|
|
- "screens_brand": s.ScreensBrand,
|
|
|
- "screens_model": s.ScreensModel,
|
|
|
- "ip_address": s.IPAddress,
|
|
|
- "install_time": s.InstallTime,
|
|
|
- "shunt": s.Shunt,
|
|
|
- "shunt_describe": s.ShuntDescribe,
|
|
|
- "resolution_id": s.ResolutionId,
|
|
|
- "screens_size_id": s.ScreensSizeId,
|
|
|
- "switch_sn": s.SwitchSn,
|
|
|
+ "screens_name": s.ScreensName,
|
|
|
+ "screens_code": s.ScreensCode,
|
|
|
+ "sn": s.Sn,
|
|
|
+ "network": s.Network,
|
|
|
+ "gateway_id": s.GatewayId,
|
|
|
+ "screens_brand": s.ScreensBrand,
|
|
|
+ "screens_model": s.ScreensModel,
|
|
|
+ "ip_address": s.IPAddress,
|
|
|
+ "install_time": s.InstallTime,
|
|
|
+ "shunt": s.Shunt,
|
|
|
+ "shunt_describe": s.ShuntDescribe,
|
|
|
+ "resolution_id": s.ResolutionId,
|
|
|
+ "screens_size_id": s.ScreensSizeId,
|
|
|
+ "switch_sn": s.SwitchSn,
|
|
|
+ "status": s.Status,
|
|
|
+ "last_online_time": s.LastOnlineTime,
|
|
|
+ "Last_offline_time": s.LastOfflineTime,
|
|
|
}).Error
|
|
|
return err
|
|
|
}
|
|
@@ -115,20 +118,20 @@ func QueryScreensToDetail(id int) (screensList []Screens, err error) {
|
|
|
// return err
|
|
|
//}
|
|
|
|
|
|
-func UpdateScreensStatusAndOnline(code string, sta int) error {
|
|
|
+func UpdateScreensStatusAndOnline(sn string, sta int) error {
|
|
|
var screens Screens
|
|
|
return global.GVA_DB.Model(&screens).Select("status", "last_online_time", "is_login").
|
|
|
- Where("screens_code = ?", code).Updates(map[string]interface{}{
|
|
|
+ Where("sn = ?", sn).Updates(map[string]interface{}{
|
|
|
"status": sta,
|
|
|
"last_online_time": time.Now(),
|
|
|
"is_login": 999,
|
|
|
}).Error
|
|
|
}
|
|
|
|
|
|
-func UpdateScreensStatusAndOffline(code string, sta int) error {
|
|
|
+func UpdateScreensStatusAndOffline(sn string, sta int) error {
|
|
|
var screens Screens
|
|
|
return global.GVA_DB.Model(&screens).Select("status", "last_offline_time", "is_login").
|
|
|
- Where("screens_code = ?", code).Updates(map[string]interface{}{
|
|
|
+ Where("sn = ?", sn).Updates(map[string]interface{}{
|
|
|
"status": sta,
|
|
|
"last_offline_time": time.Now(),
|
|
|
"is_login": 999,
|
|
@@ -175,6 +178,6 @@ func (s Screens) QueryOnlineScreens() (screensList []Screens, err error) {
|
|
|
}
|
|
|
|
|
|
func QueryAllScreens() (screensList []Screens, err error) {
|
|
|
- err = global.GVA_DB.Model(&Screens{}).Debug().Find(&screensList).Error
|
|
|
+ err = global.GVA_DB.Model(&Screens{}).Find(&screensList).Error
|
|
|
return
|
|
|
}
|