| | |
| | | |
| | | // DevicePlc 设备的PLC配置 |
| | | DevicePlc struct { |
| | | gorm.Model |
| | | CommonModel |
| | | DeviceID string `gorm:"column:device_id;type:varchar(255);not null;unique" json:"deviceID"` //设备编号 |
| | | Brand string `gorm:"type:varchar(191)" json:"brand"` |
| | | Method constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"` |
| | |
| | | } |
| | | |
| | | func (slf *DevicePlc) AfterFind(tx *gorm.DB) error { |
| | | details := make([]*DevicePlcAddress, 0) |
| | | err := json.Unmarshal([]byte(slf.Detail), &details) |
| | | if err != nil { |
| | | return err |
| | | if slf.Detail != "" { |
| | | details := make([]*DevicePlcAddress, 0) |
| | | err := json.Unmarshal([]byte(slf.Detail), &details) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.Details = details |
| | | } |
| | | slf.Details = details |
| | | |
| | | return nil |
| | | } |
| | | |