80 lines
3.8 KiB
Go
80 lines
3.8 KiB
Go
package schema
|
||
|
||
import (
|
||
"time"
|
||
|
||
"ifms/pkg/util"
|
||
)
|
||
|
||
// 设备运行日志表
|
||
type DeviceRunLog struct {
|
||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement;comment:Unique ID;"` // Unique ID
|
||
TenantID string `json:"tenant_id" gorm:"size:32;"` // Tenant ID
|
||
DeviceID int64 `json:"device_id" gorm:"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:操作人;"` // 操作人
|
||
Content string `json:"content" gorm:"type:text;comment:内容;"` // 内容
|
||
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 {
|
||
TenantID string `json:"tenant_id"` // 租户ID
|
||
DeviceID int64 `json:"device_id" binding:"required"` // 设备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"` // 操作人
|
||
Content string `json:"content" gorm:"type:text;comment:内容;"` // 内容
|
||
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.TenantID = a.TenantID
|
||
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.Content = a.Content
|
||
deviceRunLog.Type = a.Type
|
||
return nil
|
||
}
|