log.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package search
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "time"
  7. "go-common/app/interface/main/reply/model/adminlog"
  8. "go-common/library/log"
  9. "go-common/library/xstr"
  10. )
  11. type searchAdminLog struct {
  12. ReplyID int64 `json:"rpid"` // 评论id
  13. AdminID int64 `json:"adminid"` // 操作人
  14. State int32 `json:"state"` // 操作人身份
  15. ReplyMid int64 `json:"replymid"` // 评论人
  16. CTime string `json:"ctime"` // 删除时间
  17. }
  18. // LogPaginate paginating the admin logs for size of 'pageSize', and returning the number of reporting, the number of admin logs delete by administrator
  19. func (dao *Dao) LogPaginate(c context.Context, oid int64, tp int, states []int64, curPage, pageSize int, startTime string, now time.Time) (logs []*adminlog.AdminLog, replyCount, reportCount, pageCount, total int64, err error) {
  20. params := url.Values{}
  21. params.Set("appid", "replylog")
  22. params.Set("oid", strconv.FormatInt(oid, 10))
  23. params.Set("type", strconv.Itoa(tp))
  24. params.Set("delstats", xstr.JoinInts(states))
  25. params.Set("start_time", startTime)
  26. params.Set("pagesize", strconv.Itoa(pageSize))
  27. params.Set("page", strconv.Itoa(curPage))
  28. var res struct {
  29. Code int `json:"code"`
  30. Logs []*searchAdminLog `json:"result"`
  31. ReplyCount int64 `json:"adminDeletedNum"`
  32. ReportCount int64 `json:"reportNum"`
  33. Page int64 `json:"page"`
  34. PageSize int64 `json:"pagesize"`
  35. PageCount int64 `json:"pagecount"`
  36. Total int64 `json:"total"`
  37. }
  38. if err = dao.httpCli.Get(c, dao.logURL, "", params, &res); err != nil {
  39. log.Error("adminlog url(%v),err (%v)", dao.logURL+"?"+params.Encode(), err)
  40. return
  41. }
  42. if res.Logs == nil {
  43. logs = make([]*adminlog.AdminLog, 0)
  44. }
  45. for _, log := range res.Logs {
  46. var (
  47. tmp = &adminlog.AdminLog{}
  48. )
  49. tmp.ReplyID = log.ReplyID
  50. tmp.State = log.State
  51. tmp.AdminID = log.AdminID
  52. tmp.CTime = log.CTime
  53. tmp.ReplyMid = log.ReplyMid
  54. logs = append(logs, tmp)
  55. }
  56. replyCount = res.ReplyCount
  57. reportCount = res.ReportCount
  58. pageCount = res.PageCount
  59. total = res.Total
  60. return
  61. }