86 lines
4.6 KiB
Go
86 lines
4.6 KiB
Go
|
package schema
|
|||
|
|
|||
|
import (
|
|||
|
"time"
|
|||
|
|
|||
|
"ifms/pkg/util"
|
|||
|
)
|
|||
|
|
|||
|
// 设备运行日志表
|
|||
|
type DeviceRunLog struct {
|
|||
|
ID int64 `json:"id" gorm:"primaryKey;autoIncrement;comment:Unique ID;"` // Unique ID
|
|||
|
DeviceID string `json:"device_id" gorm:"size:32;index;comment:设备ID;"` // 设备ID
|
|||
|
DeviceModel string `json:"device_model" gorm:"size:64;comment:设备型号;"` // 设备型号
|
|||
|
DeviceName string `json:"device_name" gorm:"size:64;comment:设备名称;"` // 设备名称
|
|||
|
RelatedPondIds string `json:"related_pond_ids" gorm:"type:text;comment:关联鱼池/车间ID;"` // 关联鱼池/车间ID
|
|||
|
RelatedPond string `json:"related_pond" gorm:"type:text;comment:关联鱼池/车间;"` // 关联鱼池/车间
|
|||
|
OperatorUserID int `json:"operator_user_id" gorm:"comment:操作人ID;"` // 操作人ID
|
|||
|
Operator string `json:"operator" gorm:"size:32;comment:操作人;"` // 操作人
|
|||
|
DeviceLevel string `json:"device_level" gorm:"size:16;comment:设备档位;"` // 设备档位
|
|||
|
OxygenContent float64 `json:"oxygen_content" gorm:"type:decimal(10,2);comment:溶解氧含量mg/l;"` // 溶解氧含量mg/l
|
|||
|
DeviceStatus bool `json:"device_status" gorm:"comment:设备状态(true=在线,false=离线);"` // 设备状态(true=在线,false=离线)
|
|||
|
SwitchStatus bool `json:"switch_status" gorm:"comment:开关状态(true=开,false=关);"` // 开关状态(true=开,false=关)
|
|||
|
Type int `json:"type" gorm:"comment:设备类型(1增氧机、2投喂机、3水循环);"` // 设备类型(1增氧机、2投喂机、3水循环)
|
|||
|
CreatedAt time.Time `json:"created_at" gorm:"index;comment:Create time;"` // Create time
|
|||
|
UpdatedAt time.Time `json:"updated_at" gorm:"index;comment:Update time;"` // Update time
|
|||
|
}
|
|||
|
|
|||
|
// Defining the query parameters for the `DeviceRunLog` struct.
|
|||
|
type DeviceRunLogQueryParam struct {
|
|||
|
util.PaginationParam
|
|||
|
Type *int `form:"type"` // 设备类型(1增氧机、2投喂机、3水循环)
|
|||
|
DeviceName string `form:"device_name"` // 设备名称(模糊查询)
|
|||
|
}
|
|||
|
|
|||
|
// Defining the query options for the `DeviceRunLog` struct.
|
|||
|
type DeviceRunLogQueryOptions struct {
|
|||
|
util.QueryOptions
|
|||
|
}
|
|||
|
|
|||
|
// Defining the query result for the `DeviceRunLog` struct.
|
|||
|
type DeviceRunLogQueryResult struct {
|
|||
|
Data DeviceRunLogs
|
|||
|
PageResult *util.PaginationResult
|
|||
|
}
|
|||
|
|
|||
|
// Defining the slice of `DeviceRunLog` struct.
|
|||
|
type DeviceRunLogs []*DeviceRunLog
|
|||
|
|
|||
|
// Defining the data structure for creating a `DeviceRunLog` struct.
|
|||
|
type DeviceRunLogForm struct {
|
|||
|
DeviceID string `json:"device_id" binding:"required,max=32"` // 设备ID
|
|||
|
DeviceModel string `json:"device_model" binding:"required,max=64"` // 设备型号
|
|||
|
DeviceName string `json:"device_name" binding:"required,max=64"` // 设备名称
|
|||
|
RelatedPondIds string `json:"related_pond_ids" binding:"required"` // 关联鱼池/车间ID
|
|||
|
RelatedPond string `json:"related_pond" binding:"required"` // 关联鱼池/车间
|
|||
|
OperatorUserID int `json:"operator_user_id" binding:"required"` // 操作人ID
|
|||
|
Operator string `json:"operator" binding:"required,max=32"` // 操作人
|
|||
|
DeviceLevel string `json:"device_level" binding:"required,max=16"` // 设备档位
|
|||
|
OxygenContent float64 `json:"oxygen_content" binding:"required"` // 溶解氧含量mg/l
|
|||
|
DeviceStatus bool `json:"device_status" binding:"required"` // 设备状态(true=在线,false=离线)
|
|||
|
SwitchStatus bool `json:"switch_status" binding:"required"` // 开关状态(true=开,false=关)
|
|||
|
Type int `json:"type" binding:"required"` // 设备类型(1增氧机、2投喂机、3水循环)
|
|||
|
}
|
|||
|
|
|||
|
// A validation function for the `DeviceRunLogForm` struct.
|
|||
|
func (a *DeviceRunLogForm) Validate() error {
|
|||
|
return nil
|
|||
|
}
|
|||
|
|
|||
|
// Convert `DeviceRunLogForm` to `DeviceRunLog` object.
|
|||
|
func (a *DeviceRunLogForm) FillTo(deviceRunLog *DeviceRunLog) error {
|
|||
|
deviceRunLog.DeviceID = a.DeviceID
|
|||
|
deviceRunLog.DeviceModel = a.DeviceModel
|
|||
|
deviceRunLog.DeviceName = a.DeviceName
|
|||
|
deviceRunLog.RelatedPondIds = a.RelatedPondIds
|
|||
|
deviceRunLog.RelatedPond = a.RelatedPond
|
|||
|
deviceRunLog.OperatorUserID = a.OperatorUserID
|
|||
|
deviceRunLog.Operator = a.Operator
|
|||
|
deviceRunLog.DeviceLevel = a.DeviceLevel
|
|||
|
deviceRunLog.OxygenContent = a.OxygenContent
|
|||
|
deviceRunLog.DeviceStatus = a.DeviceStatus
|
|||
|
deviceRunLog.SwitchStatus = a.SwitchStatus
|
|||
|
deviceRunLog.Type = a.Type
|
|||
|
return nil
|
|||
|
}
|