hospital-admin-api/api/model/AdminApiRequest.go

37 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// AdminApiRequest 后台api请求记录
type AdminApiRequest struct {
RequestId int64 `gorm:"column:request_id;type:bigint(19);primary_key;comment:主键id" json:"request_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:后台用户id" json:"user_id"`
ApiName string `gorm:"column:api_name;type:varchar(100);comment:api名称" json:"api_name"`
ApiPath string `gorm:"column:api_path;type:varchar(255);comment: 接口路径(全路径 id为:id" json:"api_path"`
ApiMethod string `gorm:"column:api_method;type:varchar(10);comment:请求类型put:修改 post:新增 get:获取 " json:"api_method"`
RequestTime LocalTime `gorm:"column:request_time;type:datetime;comment:请求时间" json:"request_time"`
Model
}
func (m *AdminApiRequest) TableName() string {
return "gdxz_admin_api_request"
}
func (m *AdminApiRequest) BeforeCreate(tx *gorm.DB) error {
if m.RequestId == 0 {
m.RequestId = 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
}