ifms_go/internal/mods/autocontrol/schema/device_control_log.go

80 lines
4.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package schema
import (
"time"
"ifms/pkg/util"
)
// 设备操作日志表
type DeviceControlLog 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:"index;comment:操作人ID;"` // 操作人ID
Operator string `json:"operator" gorm:"size:32;comment:操作人;"` // 操作人
Command string `json:"command" gorm:"type:text;comment:下达指令;"` // 下达指令
CommandStatus bool `json:"command_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 `DeviceControlLog` struct.
type DeviceControlLogQueryParam struct {
util.PaginationParam
Type *int `form:"type"` // 设备类型1增氧机、2投喂机、3水循环
DeviceName string `form:"device_name"` // 设备名称(模糊查询)
}
// Defining the query options for the `DeviceControlLog` struct.
type DeviceControlLogQueryOptions struct {
util.QueryOptions
}
// Defining the query result for the `DeviceControlLog` struct.
type DeviceControlLogQueryResult struct {
Data DeviceControlLogs
PageResult *util.PaginationResult
}
// Defining the slice of `DeviceControlLog` struct.
type DeviceControlLogs []*DeviceControlLog
// Defining the data structure for creating a `DeviceControlLog` struct.
type DeviceControlLogForm 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"` // 操作人
Command string `json:"command" binding:"required"` // 下达指令
CommandStatus bool `json:"command_status" binding:"required"` // 指令状态true=成功false=失败)
Type int `json:"type" binding:"required"` // 设备类型1增氧机、2投喂机、3水循环
}
// A validation function for the `DeviceControlLogForm` struct.
func (a *DeviceControlLogForm) Validate() error {
return nil
}
// Convert `DeviceControlLogForm` to `DeviceControlLog` object.
func (a *DeviceControlLogForm) FillTo(deviceControlLog *DeviceControlLog) error {
deviceControlLog.DeviceID = a.DeviceID
deviceControlLog.DeviceModel = a.DeviceModel
deviceControlLog.DeviceName = a.DeviceName
deviceControlLog.RelatedPondIds = a.RelatedPondIds
deviceControlLog.RelatedPond = a.RelatedPond
deviceControlLog.OperatorUserID = a.OperatorUserID
deviceControlLog.Operator = a.Operator
deviceControlLog.Command = a.Command
deviceControlLog.CommandStatus = a.CommandStatus
deviceControlLog.Type = a.Type
return nil
}