log.go 999 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package model
  2. import (
  3. "time"
  4. "kpt.xdmy/pkg/util"
  5. )
  6. type SapLog struct {
  7. ID int `gorm:"column:id" `
  8. Flag int `gorm:"column:Flag"`
  9. SysName string `gorm:"column:SysName"`
  10. Name string `gorm:"column:Name"`
  11. Url string `gorm:"column:Url"`
  12. Status string `gorm:"column:Status"`
  13. MsgText string `gorm:"column:MsgText"`
  14. Param string `gorm:"column:Param"`
  15. CreatedAt time.Time `gorm:"column:Created_At"`
  16. }
  17. type SapDetailLog struct {
  18. ID int `gorm:"column:id " `
  19. Name string `gorm:"column:name"`
  20. Code string `gorm:"column:code"`
  21. ErrorText string `gorm:"column:error_text"`
  22. CreatedAt time.Time `gorm:"column:created_at"`
  23. }
  24. func SapLogTime(name string) time.Time {
  25. sql := "select created_at from saplog where name=@name and flag=1 order by id desc limit 1"
  26. c := util.NewMap("name", name)
  27. var t time.Time
  28. d.Raw(sql, c, &t)
  29. if t.IsZero() {
  30. return time.Now().Add(-24 * time.Hour)
  31. }
  32. return t
  33. }