audit.go 791 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package api
  2. import (
  3. "Gwen/model"
  4. "strconv"
  5. )
  6. type AuditConnForm struct {
  7. Action string `json:"action"`
  8. ConnId int64 `json:"conn_id"`
  9. Id string `json:"id"`
  10. Peer []string `json:"peer"`
  11. Ip string `json:"ip"`
  12. SessionId float64 `json:"session_id"`
  13. Type int `json:"type"`
  14. Uuid string `json:"uuid"`
  15. }
  16. func (a *AuditConnForm) ToAuditConn() *model.AuditConn {
  17. fp := ""
  18. fn := ""
  19. if len(a.Peer) >= 1 {
  20. fp = a.Peer[0]
  21. if len(a.Peer) == 2 {
  22. fn = a.Peer[1]
  23. }
  24. }
  25. ssid := strconv.FormatFloat(a.SessionId, 'f', -1, 64)
  26. return &model.AuditConn{
  27. Action: a.Action,
  28. ConnId: a.ConnId,
  29. PeerId: a.Id,
  30. FromPeer: fp,
  31. FromName: fn,
  32. Ip: a.Ip,
  33. SessionId: ssid,
  34. Type: a.Type,
  35. Uuid: a.Uuid,
  36. }
  37. }