tracking.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package models
  2. // 操作埋点记录表
  3. type TrackingRecord struct {
  4. BaseModel
  5. UserID int `gorm:"type:int;not null;comment:用户ID" json:"user_id"`
  6. ApiPath string `gorm:"type:varchar(255);not null;comment:接口路径" json:"api_path"`
  7. ApiName string `gorm:"type:varchar(255);not null;comment:接口名称" json:"api_name"`
  8. Method string `gorm:"type:varchar(10);not null;comment:请求方法" json:"method"`
  9. UserAgent string `gorm:"type:varchar(500);comment:用户代理" json:"user_agent"`
  10. IpAddress string `gorm:"type:varchar(50);comment:IP地址" json:"ip_address"`
  11. RequestId string `gorm:"type:varchar(100);comment:请求ID" json:"request_id"`
  12. Status int `gorm:"type:tinyint;default:1;comment:状态 1:成功 0:失败" json:"status"`
  13. Duration int64 `gorm:"type:bigint;comment:请求耗时(毫秒)" json:"duration"`
  14. ExtraData string `gorm:"type:text;comment:额外数据" json:"extra_data"`
  15. }
  16. // TableName 指定表名
  17. func (TrackingRecord) TableName() string {
  18. return "tracking_record"
  19. }
  20. // 接口路径映射表
  21. type ApiPathMapping struct {
  22. BaseModel
  23. ApiPath string `gorm:"type:varchar(255);not null;uniqueIndex;comment:接口路径" json:"api_path"`
  24. ApiName string `gorm:"type:varchar(255);not null;comment:接口名称" json:"api_name"`
  25. ApiDesc string `gorm:"type:varchar(500);comment:接口描述" json:"api_desc"`
  26. Status int `gorm:"type:tinyint;default:1;comment:状态 1:启用 0:禁用" json:"status"`
  27. }
  28. // TableName 指定表名
  29. func (ApiPathMapping) TableName() string {
  30. return "api_path_mapping"
  31. }