From f58abf7425ddbeb52cbf09495e1761c9195c0090 Mon Sep 17 00:00:00 2001 From: hupeh Date: Tue, 3 Jan 2023 02:02:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E7=AE=A1=E7=90=86=E5=91=98=E8=B4=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/db.go b/app/db.go index 1be0154..d5262b8 100644 --- a/app/db.go +++ b/app/db.go @@ -17,7 +17,22 @@ func ConfigGormDB() { if err != nil { panic(err) } - if err = DB.AutoMigrate(&User{}, &Goods{}, &Price{}); err != nil { + if err = DB.AutoMigrate(&User{}, &UserToken{}, &Goods{}, &Price{}); err != nil { + panic(err) + } + hash, err := HashPassword("123456") + if err != nil { + panic(err) + } + admin := User{ + Model: gorm.Model{ID: 1}, + Name: "超级管理员", + PhoneNumber: "18982052224", + Password: hash, + Admin: true, + } + err = DB.Save(&admin).Error + if err != nil { panic(err) } }