timeline_log.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hongze_clpt/utils"
  5. "time"
  6. )
  7. type CygxTimelineLog struct {
  8. Id int `orm:"column(id);pk"`
  9. IndustrialManagementId int `description:"产业D"`
  10. UserId int `description:"用户ID"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. CreateTime time.Time `description:"创建时间"`
  16. ModifyTime time.Time `description:"更新时间"`
  17. RealName string `description:"用户实际名称"`
  18. }
  19. // 判断用户是否阅读过该产业下的时间线
  20. func GetCygxTimelineLogCountByUser(userId, industrialManagementId int) (count int, err error) {
  21. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_timeline_log as a WHERE user_id= ? AND industrial_management_id = ? `
  22. o := orm.NewOrm()
  23. err = o.Raw(sqlCount, userId, industrialManagementId).QueryRow(&count)
  24. return
  25. }
  26. // 新增
  27. func AddCygxTimelineLog(item *CygxTimelineLog) (lastId int64, err error) {
  28. o := orm.NewOrm()
  29. lastId, err = o.Insert(item)
  30. return
  31. }
  32. // UpdateCygxTimelineLogModifyTime 更新用户阅读过该产业下的时间线的时间
  33. func UpdateCygxTimelineLogModifyTime(userId, industrialManagementId int) (err error) {
  34. o := orm.NewOrm()
  35. sql := `UPDATE cygx_timeline_log SET modify_time = ? WHERE user_id= ? AND industrial_management_id = ? `
  36. _, err = o.Raw(sql, time.Now(), userId, industrialManagementId).Exec()
  37. return
  38. }
  39. //func GetCygxTimelineLogCount(userId int, date string) (items []*CygxPageHistoryRecord, err error) {
  40. // o := orm.NewOrm()
  41. // sql := `SELECT * FROM cygx_timeline_log WHERE user_id=? `
  42. // _, err = o.Raw(sql, userId, date).QueryRows(&items)
  43. // return
  44. //}
  45. func GetCygxTimelineLogCount(userId int, industrialIdArr []int) (items []*CygxTimelineLog, err error) {
  46. if len(industrialIdArr) == 0 {
  47. return
  48. }
  49. o := orm.NewOrm()
  50. sql := `SELECT * FROM cygx_timeline_log WHERE user_id=? AND industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)`
  51. _, err = o.Raw(sql, userId, industrialIdArr).QueryRows(&items)
  52. return
  53. }