|
@@ -7,21 +7,21 @@ import (
|
|
|
|
|
|
|
|
type LightStrategy struct {
|
|
type LightStrategy struct {
|
|
|
ID int `gorm:"primary key" json:"id"` //编号
|
|
ID int `gorm:"primary key" json:"id"` //编号
|
|
|
- LightName string `gorm:"type: varchar(64" json:"lightName"` //策略名称
|
|
|
|
|
|
|
+ LightName string `gorm:"type:varchar(64)" json:"lightName"` //策略名称
|
|
|
LightControlType int `gorm:"type:int" json:"lightControlType"` //灯控类型 设置 1=485,2=nb-iot
|
|
LightControlType int `gorm:"type:int" json:"lightControlType"` //灯控类型 设置 1=485,2=nb-iot
|
|
|
OptoSensorID int `gorm:"type:int" json:"optoSensorID"` //光传感器ID
|
|
OptoSensorID int `gorm:"type:int" json:"optoSensorID"` //光传感器ID
|
|
|
StartTime string `gorm:"type:date" json:"startTime"` //策略期限开始时间
|
|
StartTime string `gorm:"type:date" json:"startTime"` //策略期限开始时间
|
|
|
EndTime string `gorm:"type:date" json:"endTime"` //策略期限结束时间
|
|
EndTime string `gorm:"type:date" json:"endTime"` //策略期限结束时间
|
|
|
IsAllYear int `gorm:"type:int;default 1" json:"isAllYear"` //全年设置2=是,1=否
|
|
IsAllYear int `gorm:"type:int;default 1" json:"isAllYear"` //全年设置2=是,1=否
|
|
|
IsAutomaticRenewal int `gorm:"type:int;default 1" json:"isAutomaticRenewal"` //自动续期设置 2=是,1=否
|
|
IsAutomaticRenewal int `gorm:"type:int;default 1" json:"isAutomaticRenewal"` //自动续期设置 2=是,1=否
|
|
|
- CreateTime time.Time `gorm:"type: datetime" json:"createTime"` //新增时间
|
|
|
|
|
|
|
+ CreateTime time.Time `gorm:"type:datetime" json:"createTime"` //新增时间
|
|
|
CreateUser string `gorm:"type:varchar(60)" json:"createUser"` //新增记录操作用户ID
|
|
CreateUser string `gorm:"type:varchar(60)" json:"createUser"` //新增记录操作用户ID
|
|
|
- UpdateTime time.Time `gorm:"type: datetime" json:"updateTime"` //修改时间
|
|
|
|
|
|
|
+ UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"` //修改时间
|
|
|
UpdateUser string `gorm:"type:varchar(60)" json:"updateUser"` //修改用户
|
|
UpdateUser string `gorm:"type:varchar(60)" json:"updateUser"` //修改用户
|
|
|
IsDeleted int `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
|
|
IsDeleted int `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
|
|
|
Status int `gorm:"type:int;default 1" json:"status"` //状态 0=正常,1=异常
|
|
Status int `gorm:"type:int;default 1" json:"status"` //状态 0=正常,1=异常
|
|
|
TenantID string `gorm:"type:varchar(12)" json:"tenantID"` //租户id
|
|
TenantID string `gorm:"type:varchar(12)" json:"tenantID"` //租户id
|
|
|
- LightSn string `gorm:"type:varchar(64" json:"lightSn"` //策略编码
|
|
|
|
|
|
|
+ LightSn string `gorm:"type:varchar(64)" json:"lightSn"` //策略编码
|
|
|
ManualTime int `gorm:"type:int;default 0" json:"manualTime"` //手动控制时间
|
|
ManualTime int `gorm:"type:int;default 0" json:"manualTime"` //手动控制时间
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -42,13 +42,13 @@ func (c LightStrategy) IsExistedBySN() bool {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (c LightStrategy) IsExistedByNameAndCode() bool {
|
|
func (c LightStrategy) IsExistedByNameAndCode() bool {
|
|
|
- var Strategys []LightStrategy
|
|
|
|
|
|
|
+ var Strategies []LightStrategy
|
|
|
err := Db.Model(&c).Where("gateway_sn = ? and is_deleted = ?",
|
|
err := Db.Model(&c).Where("gateway_sn = ? and is_deleted = ?",
|
|
|
- c.TenantID, c.IsDeleted).Find(&Strategys).Error
|
|
|
|
|
|
|
+ c.TenantID, c.IsDeleted).Find(&Strategies).Error
|
|
|
if gorm.IsRecordNotFoundError(err) {
|
|
if gorm.IsRecordNotFoundError(err) {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
- for _, d := range Strategys {
|
|
|
|
|
|
|
+ for _, d := range Strategies {
|
|
|
if d.ID != c.ID {
|
|
if d.ID != c.ID {
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|