log.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. type SapApiLog struct {
  25. ID int `gorm:"column:id" `
  26. Flag int `gorm:"column:flag"`
  27. Name string `gorm:"column:name"`
  28. Request string `gorm:"column:request"`
  29. Response string `gorm:"column:response"`
  30. Url string `gorm:"column:url"`
  31. Status string `gorm:"column:status"`
  32. MsgText string `gorm:"column:msgText"`
  33. Param string `gorm:"column:param"`
  34. CreatedAt time.Time `gorm:"column:created_at"`
  35. }
  36. func SapLogTime(name string) time.Time {
  37. sql := "select created_at from saplog where name=@name and flag=1 order by id desc limit 1"
  38. c := util.NewMap("name", name)
  39. var t time.Time
  40. d.Raw(sql, c, &t)
  41. if t.IsZero() {
  42. return time.Now().Add(-24 * time.Hour)
  43. }
  44. return t
  45. }