refactor product domain models
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DevDeviceBinding 对应 dev_device_binding,保存设备授权绑定。
|
||||
type DevDeviceBinding struct {
|
||||
Entity // 公共实体字段
|
||||
SmartCylinderValveID uint64 `gorm:"column:smart_cylinder_valve_id;not null;index" json:"smart_cylinder_valve_id"` // smart_cylinder_valve_id 业务字段
|
||||
UserAccountID uint64 `gorm:"column:user_account_id;not null;index" json:"user_account_id"` // user_account_id 业务字段
|
||||
EffectiveAt time.Time `gorm:"column:effective_at;type:timestamptz;not null" json:"effective_at"` // effective_at 业务字段
|
||||
ExpiredAt *time.Time `gorm:"column:expired_at;type:timestamptz" json:"expired_at"` // expired_at 业务字段
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&DevDeviceBinding{}) }
|
||||
func (table *DevDeviceBinding) TableName() string { return "dev_device_binding" }
|
||||
@@ -1,15 +0,0 @@
|
||||
package models
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/database"
|
||||
|
||||
// DevSmartCylinderValve 对应 dev_smart_cylinder_valve,保存智能瓶阀档案。
|
||||
type DevSmartCylinderValve struct {
|
||||
Entity // 公共实体字段
|
||||
DeviceNo string `gorm:"column:device_no;type:varchar(64);not null;uniqueIndex" json:"device_no"` // device_no 业务字段
|
||||
Model string `gorm:"column:model;type:varchar(64);not null;default:''" json:"model"` // model 业务字段
|
||||
OnlineStatus string `gorm:"column:online_status;type:varchar(32);not null;default:'offline'" json:"online_status"` // online_status 业务字段
|
||||
OwnerIdentity string `gorm:"column:owner_identity;type:varchar(36);not null;default:'';index" json:"owner_identity"` // owner_identity 业务字段
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&DevSmartCylinderValve{}) }
|
||||
func (table *DevSmartCylinderValve) TableName() string { return "dev_smart_cylinder_valve" }
|
||||
@@ -1,18 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DevTelemetry 对应 dev_telemetry,保存设备遥测摘要。
|
||||
type DevTelemetry struct {
|
||||
Entity // 公共实体字段
|
||||
SmartCylinderValveIdentity string `gorm:"column:smart_cylinder_valve_identity;type:varchar(36);not null;index" json:"smart_cylinder_valve_identity"` // smart_cylinder_valve_identity 业务字段
|
||||
ReportedAt time.Time `gorm:"column:reported_at;type:timestamptz;not null;index" json:"reported_at"` // reported_at 业务字段
|
||||
Payload string `gorm:"column:payload;type:text;not null;default:''" json:"payload"` // payload 业务字段
|
||||
QualityFlag string `gorm:"column:quality_flag;type:varchar(32);not null;default:'normal'" json:"quality_flag"` // quality_flag 业务字段
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&DevTelemetry{}) }
|
||||
func (table *DevTelemetry) TableName() string { return "dev_telemetry" }
|
||||
26
backend/api/internal/models/product_info.go
Normal file
26
backend/api/internal/models/product_info.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
)
|
||||
|
||||
// ProductInfo 对应 product_info,保存一物一码的实体产品档案。
|
||||
type ProductInfo struct {
|
||||
Entity // 公共实体字段
|
||||
Code string `gorm:"column:code;type:varchar(64);not null;uniqueIndex" json:"code"` // 产品唯一标识
|
||||
Name string `gorm:"column:name;type:varchar(128);not null" json:"name"` // 产品名称
|
||||
ProductTypeID uint64 `gorm:"column:product_type_id;not null;index" json:"product_type_id"` // 产品类型自增主键
|
||||
Params string `gorm:"column:params;type:text;not null;default:'{}'" json:"params"` // 产品参数 JSON 对象文本
|
||||
WarehouseID uint64 `gorm:"column:warehouse_id;not null;default:0;index" json:"warehouse_id"` // 当前实际库房自增主键
|
||||
GasBasicID uint64 `gorm:"column:gas_basic_id;not null;default:0;index" json:"gas_basic_id"` // 当前归属气站自增主键
|
||||
DeliveryBasicID uint64 `gorm:"column:delivery_basic_id;not null;default:0;index" json:"delivery_basic_id"` // 当前归属配送站自增主键
|
||||
UserAccountID uint64 `gorm:"column:user_account_id;not null;default:0;index" json:"user_account_id"` // 当前归属用户自增主键
|
||||
ProducedAt time.Time `gorm:"column:produced_at;type:timestamptz;not null" json:"produced_at"` // 生产时间
|
||||
IsEnabled bool `gorm:"column:is_enabled;not null;default:false" json:"is_enabled"` // 是否启用
|
||||
EnabledAt *time.Time `gorm:"column:enabled_at;type:timestamptz" json:"enabled_at"` // 首次启用时间
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&ProductInfo{}) }
|
||||
func (table *ProductInfo) TableName() string { return "product_info" }
|
||||
26
backend/api/internal/models/product_owner.go
Normal file
26
backend/api/internal/models/product_owner.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
)
|
||||
|
||||
// ProductOwner 对应 product_owner,保存产品库房与责任归属的不可变快照。
|
||||
type ProductOwner struct {
|
||||
Entity // 公共实体字段
|
||||
ProductInfoID uint64 `gorm:"column:product_info_id;not null;index" json:"product_info_id"` // 产品档案自增主键
|
||||
WarehouseID uint64 `gorm:"column:warehouse_id;not null;default:0;index" json:"warehouse_id"` // 当前实际库房自增主键快照
|
||||
GasBasicID uint64 `gorm:"column:gas_basic_id;not null;default:0;index" json:"gas_basic_id"` // 当前归属气站自增主键快照
|
||||
DeliveryBasicID uint64 `gorm:"column:delivery_basic_id;not null;default:0;index" json:"delivery_basic_id"` // 当前归属配送站自增主键快照
|
||||
UserAccountID uint64 `gorm:"column:user_account_id;not null;default:0;index" json:"user_account_id"` // 当前归属用户自增主键快照
|
||||
Action string `gorm:"column:action;type:varchar(32);not null" json:"action"` // 归属变更动作
|
||||
OccurredAt time.Time `gorm:"column:occurred_at;type:timestamptz;not null;index" json:"occurred_at"` // 实际发生时间
|
||||
Reason string `gorm:"column:reason;type:text;not null;default:''" json:"reason"` // 变更原因
|
||||
Remark string `gorm:"column:remark;type:text;not null;default:''" json:"remark"` // 备注
|
||||
OperatorIdentity string `gorm:"column:operator_identity;type:varchar(36);not null;default:'';index" json:"operator_identity"` // 操作者业务标识
|
||||
OperatorName string `gorm:"column:operator_name;type:varchar(64);not null;default:''" json:"operator_name"` // 操作者姓名快照
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&ProductOwner{}) }
|
||||
func (table *ProductOwner) TableName() string { return "product_owner" }
|
||||
25
backend/api/internal/models/product_repair.go
Normal file
25
backend/api/internal/models/product_repair.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
)
|
||||
|
||||
// ProductRepair 对应 product_repair,保存产品检修过程与结果。
|
||||
type ProductRepair struct {
|
||||
Entity // 公共实体字段
|
||||
ProductInfoID uint64 `gorm:"column:product_info_id;not null;index" json:"product_info_id"` // 产品档案自增主键
|
||||
RepairNo string `gorm:"column:repair_no;type:varchar(64);not null;uniqueIndex" json:"repair_no"` // 检修单号
|
||||
RepairType string `gorm:"column:repair_type;type:varchar(32);not null" json:"repair_type"` // 检修类型
|
||||
StartedAt time.Time `gorm:"column:started_at;type:timestamptz;not null" json:"started_at"` // 开始时间
|
||||
CompletedAt *time.Time `gorm:"column:completed_at;type:timestamptz" json:"completed_at"` // 完成时间
|
||||
Result string `gorm:"column:result;type:varchar(32);not null;default:'pending'" json:"result"` // 检修结果
|
||||
TargetStatus string `gorm:"column:target_status;type:varchar(32);not null;default:''" json:"target_status"` // 完成后的产品状态
|
||||
Content string `gorm:"column:content;type:text;not null;default:''" json:"content"` // 检修内容
|
||||
Operator string `gorm:"column:operator;type:varchar(64);not null;default:''" json:"operator"` // 检修人员
|
||||
Remark string `gorm:"column:remark;type:text;not null;default:''" json:"remark"` // 备注
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&ProductRepair{}) }
|
||||
func (table *ProductRepair) TableName() string { return "product_repair" }
|
||||
13
backend/api/internal/models/product_type.go
Normal file
13
backend/api/internal/models/product_type.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/database"
|
||||
|
||||
// ProductType 对应 product_type,保存实体产品的类型与规格名称。
|
||||
type ProductType struct {
|
||||
Entity // 公共实体字段
|
||||
Code string `gorm:"column:code;type:varchar(64);not null;uniqueIndex" json:"code"` // 产品类型编码
|
||||
Name string `gorm:"column:name;type:varchar(128);not null" json:"name"` // 产品类型名称
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&ProductType{}) }
|
||||
func (table *ProductType) TableName() string { return "product_type" }
|
||||
17
backend/api/internal/models/product_warehouse.go
Normal file
17
backend/api/internal/models/product_warehouse.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/database"
|
||||
|
||||
// ProductWarehouse 对应 product_warehouse,保存独立库房档案。
|
||||
type ProductWarehouse struct {
|
||||
Entity // 公共实体字段
|
||||
Code string `gorm:"column:code;type:varchar(64);not null;uniqueIndex" json:"code"` // 库房编码
|
||||
Name string `gorm:"column:name;type:varchar(128);not null" json:"name"` // 库房名称
|
||||
Address string `gorm:"column:address;type:varchar(255);not null;default:''" json:"address"` // 库房地址
|
||||
Manager string `gorm:"column:manager;type:varchar(64);not null;default:''" json:"manager"` // 库房负责人
|
||||
Phone string `gorm:"column:phone;type:varchar(32);not null;default:''" json:"phone"` // 联系电话
|
||||
IsEnabled bool `gorm:"column:is_enabled;not null;default:false" json:"is_enabled"` // 是否启用
|
||||
}
|
||||
|
||||
func init() { database.AppendMigrate(&ProductWarehouse{}) }
|
||||
func (table *ProductWarehouse) TableName() string { return "product_warehouse" }
|
||||
Reference in New Issue
Block a user