36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-admin-api/global"
|
||
"time"
|
||
)
|
||
|
||
// AdminAPI 后台-接口表
|
||
type AdminAPI struct {
|
||
Model
|
||
APIID int64 `gorm:"column:api_id;type:bigint(19);primary_key;AUTO_INCREMENT;comment:主键id" json:"api_id"`
|
||
APIName string `gorm:"column:api_name;type:varchar(100);comment:api名称;NOT NULL" json:"api_name"`
|
||
APIPath string `gorm:"column:api_path;type:varchar(255);comment:接口路径(全路径 id为:id);NOT NULL" json:"api_path"`
|
||
APIMethod string `gorm:"column:api_method;type:varchar(10);comment:请求类型(put:修改 post:新增 get:获取 );NOT NULL" json:"api_method"`
|
||
IsAuth int `gorm:"column:is_auth;type:tinyint(1);default:1;comment:是否验证权限(0:否 1:是)" json:"is_auth"`
|
||
}
|
||
|
||
func (m *AdminAPI) TableName() string {
|
||
return "gdxz_admin_api"
|
||
}
|
||
|
||
func (m *AdminAPI) BeforeCreate(tx *gorm.DB) error {
|
||
if m.APIID == 0 {
|
||
m.APIID = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|