diff --git a/model.go b/model.go index 51d9a5e..b913dc6 100644 --- a/model.go +++ b/model.go @@ -42,7 +42,7 @@ type TypeMap struct { } func Migrate() { - if err := DB.Debug().AutoMigrate(&Service{}, &IAndC{}, &FieldTag{}, &TypeMap{}, &Post{}, &Category{}, &PostCategory{}, &Box{}); err != nil { + if err := DB.Debug().AutoMigrate(&Blog{}, &Service{}, &IAndC{}, &FieldTag{}, &TypeMap{}, &Post{}, &Category{}, &PostCategory{}, &Box{}); err != nil { log.Fatal(err) } } @@ -279,3 +279,32 @@ func CustomSerializer() { DB.First(newPaper, paper.ID) fmt.Printf("%+v\n", newPaper) } + +// 用于处理Blog新增的请求模型 +type BlogPost struct { + BlogBasic +} + +// 用于更新 +type BlogPut struct { + ID uint + BlogBasic +} + +// 用于DB表交互的模型 +type Blog struct { + gorm.Model + + BlogBasic + Author `gorm:"embeddedPrefix:author_"` +} + +type BlogBasic struct { + Subject string + Summary string + Content string +} +type Author struct { + Name string + Emaile string +}