user_access_record.go 854 B

123456789101112131415161718192021222324252627282930313233
  1. package report
  2. import (
  3. "fmt"
  4. "hongze/hongze_yb/global"
  5. "hongze/hongze_yb/models/tables/user_access_record"
  6. "hongze/hongze_yb/services/user"
  7. "time"
  8. )
  9. // AddUserAccessRecord 新增报告浏览记录
  10. func AddUserAccessRecord(userInfo user.UserInfo, reportId int, classifyName string, reportChapterId int, authOk bool) {
  11. var err error
  12. defer func() {
  13. if err != nil {
  14. global.LOG.Critical(fmt.Sprintf("AddUserAccessRecord: userId=%d, err:%s", userInfo.UserID, err.Error()))
  15. }
  16. }()
  17. if reportId > 0 {
  18. record := new(user_access_record.UserAccessRecord)
  19. record.Uid = int(userInfo.UserID)
  20. record.Token = userInfo.LoginToken
  21. record.CreateTime = time.Now()
  22. record.Remark = "2" // 无权限
  23. if authOk {
  24. record.Remark = "0"
  25. }
  26. record.ReportId = reportId
  27. record.ReportChapterId = reportChapterId
  28. err = record.Create()
  29. }
  30. return
  31. }