From db75431fe7a401ac3509bf41c2f9c405bb07a408 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 13 六月 2024 20:17:00 +0800 Subject: [PATCH] add field define --- models/attribute.go | 6 +++--- conf/config.yaml | 2 +- models/attribute_value.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index 4664ec9..ffb9178 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -11,7 +11,7 @@ companyName: jialian db: # dsn: root:c++java123@tcp(192.168.20.119:3306)/wms?charset=utf8&parseTime=True&loc=Local - dsn: root:c++java123@tcp(192.168.20.119:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local + dsn: root:c++java123@tcp(127.0.0.1:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local logMode: true maxIdleCon: 20 maxOpenCon: 100 diff --git a/models/attribute.go b/models/attribute.go index cd342fa..fde8381 100644 --- a/models/attribute.go +++ b/models/attribute.go @@ -10,9 +10,9 @@ // Attribute 鍔ㄦ�佸睘鎬ц〃 Attribute struct { gorm.Model - Name string `json:"name"` - DataType DataType `json:"data_type"` - Value string `json:"value" gorm:"-"` + Name string `gorm:"type:varchar(100);not null;default:''" json:"name"` //灞炴�у悕绉� + DataType DataType `gorm:"type:tinyint;not null;default:0" json:"dataType"` //缁欒皝鐢ㄧ殑 1 鐗╂枡锛堜骇鍝侊級 + Value string `json:"value" gorm:"-"` //浠嶢ttributeValue鍙栧埌鐨剉alue } AttributeSearch struct { diff --git a/models/attribute_value.go b/models/attribute_value.go index 3b8ad53..f6bca8b 100644 --- a/models/attribute_value.go +++ b/models/attribute_value.go @@ -10,9 +10,9 @@ // AttributeValue 灞炴�у�煎拰瀵硅薄 AttributeValue struct { gorm.Model - EntityID string `gorm:"primaryKey"` - AttributeID uint `gorm:"primaryKey"` - Value string `json:"value"` + EntityID string `gorm:"uniqueIndex:entity_id_attr_id;type:varchar(100);not null;default:''" json:"entityID"` + AttributeID uint `gorm:"uniqueIndex:entity_id_attr_id;type:int;not null;default:0" json:"attributeID"` + Value string `gorm:"type:varchar(255);not null;default:''" json:"value"` } AttributeValueSearch struct { -- Gitblit v1.8.0