audit_log.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package search
  2. import (
  3. "fmt"
  4. "net/url"
  5. "strconv"
  6. "strings"
  7. "go-common/app/admin/main/workflow/model"
  8. "go-common/library/xstr"
  9. )
  10. // AuditLogGroupSearchCond is the common condition model to send challenge search request
  11. type AuditLogGroupSearchCond struct {
  12. Group []string
  13. UNames []string
  14. Uids []int64
  15. Businesses []int64
  16. Type []int64
  17. Oids []int64
  18. Actions []string
  19. CTimeFrom string
  20. CTimeTo string
  21. Int0 []int64
  22. Int0From int64
  23. Int0To int64
  24. Int1 []int64
  25. Int1From int64
  26. Int1To int64
  27. Int2 []int64
  28. Int2From int64
  29. Int2To int64
  30. Str0 string
  31. Str1 string
  32. Str2 string
  33. PN int64
  34. PS int64
  35. Order string
  36. Sort string
  37. }
  38. // AuditLogSearchResult is the model to parse search challenge common result
  39. type AuditLogSearchResult struct {
  40. Code int `json:"code"`
  41. Message string `json:"message"`
  42. TTL int32 `json:"ttl"`
  43. Data struct {
  44. Order string `json:"order"`
  45. Sort string `json:"sort"`
  46. Page model.Page `json:"page"`
  47. Result []struct {
  48. Action string `json:"action"`
  49. Business int64 `json:"business"`
  50. CTime string `json:"ctime"`
  51. ExtraData string `json:"extra_data"`
  52. Str0 string `json:"str_0"`
  53. Str1 string `json:"str_1"`
  54. Str2 string `json:"str_2"`
  55. Oid int64 `json:"oid"`
  56. Type int64 `json:"type"`
  57. UID int64 `json:"uid"`
  58. UName string `json:"uname"`
  59. } `json:"result"`
  60. } `json:"data"`
  61. }
  62. // ArchiveAuditLogExtra archive audit log extra message
  63. type ArchiveAuditLogExtra struct {
  64. Content struct {
  65. ID int64 `json:"id"` //oid
  66. UID int64 `json:"uid"`
  67. UName string `json:"uname"`
  68. Note string `json:"note"`
  69. Content string `json:"content"`
  70. } `json:"content"`
  71. Diff string `json:"diff"`
  72. }
  73. // Query make query for AuditLogGroupSearchCond
  74. func (alsc *AuditLogGroupSearchCond) Query() (uv url.Values) {
  75. uv = url.Values{}
  76. // AppID
  77. uv.Set("appid", _auditLogSrhComID)
  78. // Common
  79. uv.Set("pn", "1")
  80. uv.Set("ps", "20")
  81. uv.Set("order", "ctime")
  82. uv.Set("sort", "desc")
  83. if alsc.PN != 0 {
  84. uv.Set("pn", fmt.Sprintf("%d", alsc.PN))
  85. }
  86. if alsc.PS != 0 {
  87. uv.Set("ps", fmt.Sprintf("%d", alsc.PS))
  88. }
  89. if alsc.Order != "" {
  90. uv.Set("order", alsc.Order)
  91. }
  92. if alsc.Sort != "" {
  93. uv.Set("sort", alsc.Sort)
  94. }
  95. if alsc.Int0From != 0 {
  96. uv.Set("int_0_from", strconv.FormatInt(alsc.Int0From, 10))
  97. }
  98. if alsc.Int0To != 0 {
  99. uv.Set("int_0_to", strconv.FormatInt(alsc.Int0To, 10))
  100. }
  101. if alsc.Int1From != 0 {
  102. uv.Set("int_1_from", strconv.FormatInt(alsc.Int1From, 10))
  103. }
  104. if alsc.Int1To != 0 {
  105. uv.Set("int_1_to", strconv.FormatInt(alsc.Int1To, 10))
  106. }
  107. if alsc.Int2From != 0 {
  108. uv.Set("int_2_from", strconv.FormatInt(alsc.Int2From, 10))
  109. }
  110. if alsc.Int2To != 0 {
  111. uv.Set("int_2_to", strconv.FormatInt(alsc.Int2To, 10))
  112. }
  113. // Group related
  114. uv.Set("group", strings.Join(alsc.Group, ","))
  115. uv.Set("uname", strings.Join(alsc.UNames, ","))
  116. uv.Set("uid", xstr.JoinInts(alsc.Uids))
  117. uv.Set("business", xstr.JoinInts(alsc.Businesses))
  118. uv.Set("type", xstr.JoinInts(alsc.Type))
  119. uv.Set("oid", xstr.JoinInts(alsc.Oids))
  120. uv.Set("action", strings.Join(alsc.Actions, ","))
  121. uv.Set("ctime_from", alsc.CTimeFrom)
  122. uv.Set("ctime_to", alsc.CTimeTo)
  123. uv.Set("int_0", xstr.JoinInts(alsc.Int0))
  124. uv.Set("int_1", xstr.JoinInts(alsc.Int1))
  125. uv.Set("int_2", xstr.JoinInts(alsc.Int2))
  126. uv.Set("str_0", alsc.Str0)
  127. uv.Set("str_1", alsc.Str1)
  128. uv.Set("str_2", alsc.Str2)
  129. return uv
  130. }