From 810a59b3fe2ac29ddceb5459d3335f360067bf16 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Sun, 9 Jan 2022 05:04:24 +0800 Subject: [PATCH] update --- attribute/attribute.go | 4 +++- attribute/attribute_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/attribute/attribute.go b/attribute/attribute.go index a6608d7..12db61c 100644 --- a/attribute/attribute.go +++ b/attribute/attribute.go @@ -12,6 +12,7 @@ type Attribute struct { ID uint `gorm:"primaryKey"` Key string `gorm:"unique;not null"` + Name string Description string Value string Default string @@ -33,7 +34,7 @@ func Init() { } } -func Add(Key, Description, Default string) error { +func Add(Key, Name, Description, Default string) error { ctr := 0 store.DB.Raw(`select count(*) from "attributes" where "key" = ?`, Key). Scan(&ctr) @@ -42,6 +43,7 @@ func Add(Key, Description, Default string) error { } a := &Attribute{ Key: Key, + Name: Name, Description: Description, Default: Default, Value: Default, diff --git a/attribute/attribute_test.go b/attribute/attribute_test.go index 40a5af1..b59fec7 100644 --- a/attribute/attribute_test.go +++ b/attribute/attribute_test.go @@ -13,10 +13,10 @@ func TestAttr(t *testing.T) { viper.Set("db.type", "sqlite") store.Setup() Init() - fmt.Println(Add("test", "", "1")) - fmt.Println(Add("test1", "", "2")) - fmt.Println(Add("test2", "", "2")) - fmt.Println(Add("test3", "", "2")) + fmt.Println(Add("test", "test", "", "1")) + fmt.Println(Add("test1", "test1", "", "2")) + fmt.Println(Add("test1", "test2", "", "2")) + fmt.Println(Add("test1", "test3", "", "2")) fmt.Println(Set("test", "reset")) fmt.Println(Get("test")) }