mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 02:59:16 +08:00
feat: 改软删除为硬删除
This commit is contained in:
parent
3c770ce63b
commit
5b9372a148
9
backend/app/model/base.go
Normal file
9
backend/app/model/base.go
Normal file
@ -0,0 +1,9 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type BaseModel struct {
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Command struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
Name string `gorm:"type:varchar(64);unique;not null" json:"name"`
|
||||
Command string `gorm:"type:varchar(256);not null" json:"command"`
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Group struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
Name string `gorm:"type:varchar(64);not null" json:"name"`
|
||||
Type string `gorm:"type:varchar(16);not null" json:"type"`
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Host struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
GroupBelong string `gorm:"type:varchar(64);not null" json:"groupBelong"`
|
||||
Name string `gorm:"type:varchar(64);unique;not null" json:"name"`
|
||||
Addr string `gorm:"type:varchar(16);unique;not null" json:"addr"`
|
||||
|
@ -2,12 +2,10 @@ package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type OperationLog struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
Group string `gorm:"type:varchar(64)" json:"group"`
|
||||
Source string `gorm:"type:varchar(64)" json:"source"`
|
||||
Action string `gorm:"type:varchar(64)" json:"action"`
|
||||
|
@ -15,7 +15,7 @@ var InitTable = &gormigrate.Migration{
|
||||
}
|
||||
|
||||
var user = model.User{
|
||||
Name: "admin", Email: "admin@fit2cloud.com", Password: "Calong@2015",
|
||||
Name: "admin", Email: "admin@fit2cloud.com", Password: "5WYEZ4XcitdomVvAyimt9WwJwBJJSbTTHncZoqyOraQ=",
|
||||
}
|
||||
|
||||
var AddData = &gormigrate.Migration{
|
||||
@ -44,6 +44,12 @@ var AddTableHost = &gormigrate.Migration{
|
||||
if err := tx.AutoMigrate(&model.Command{}); err != nil {
|
||||
return err
|
||||
}
|
||||
group := model.Group{
|
||||
Name: "default", Type: "host",
|
||||
}
|
||||
if err := tx.Create(&group).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user