41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package model
|
|
|
|
import (
|
|
"git.inspur.com/sbg-jszt/cfn/cfn-schedule-agent/data"
|
|
"gorm.io/gorm"
|
|
"gorm.io/plugin/soft_delete"
|
|
"time"
|
|
)
|
|
|
|
type PageData struct {
|
|
TotalCount int64
|
|
PageSize int
|
|
PageNumber int
|
|
Data interface{}
|
|
}
|
|
|
|
type BaseModel struct {
|
|
ID string `gorm:"column:id;not null;primarykey" json:"id"`
|
|
CreateTime time.Time `gorm:"column:create_time;type:timestamp;<-:create" json:"createTime"`
|
|
UpdateTime time.Time `gorm:"column:update_time;type:timestamp" json:"updateTime"`
|
|
CreatorID string `gorm:"column:creator_id;type:varchar(64);not null;<-:create" json:"creatorID"`
|
|
Modifier string `gorm:"column:modifier;type:varchar(64);not null;" json:"modifier"`
|
|
}
|
|
|
|
func (model *BaseModel) DB() *gorm.DB {
|
|
return DB()
|
|
}
|
|
|
|
type ContainsDeleteBaseModel struct {
|
|
BaseModel
|
|
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at;type:int(11) unsigned;not null;default:0;index" json:"-"`
|
|
}
|
|
|
|
func DB() *gorm.DB {
|
|
return data.PostgreSqlDB["data"]
|
|
}
|
|
|
|
func DBAuth() *gorm.DB {
|
|
return data.PostgreSqlDB["auth"]
|
|
}
|