activity_user_search_content.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type CygxActivityUserSearchContent struct {
  8. Id int `orm:"column(id);pk"`
  9. UserId int `description:"用户ID"`
  10. CreateTime time.Time `description:"创建时间"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. ModifyTime time.Time `description:"更新时间"`
  16. ChartPermissionids string `description:"行业id"`
  17. ActivityTypeids string `description:"活动类型id"`
  18. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  19. IsShowJurisdiction int `description:"是否仅展示有权限的,1是,0否"`
  20. }
  21. //更新搜索信息
  22. func AddUserSearchContent(item *CygxActivityUserSearchContent, ttlTime time.Duration) (lastId int64, err error) {
  23. o, err := orm.NewOrm().Begin()
  24. if err != nil {
  25. return
  26. }
  27. defer func() {
  28. fmt.Println(err)
  29. if err == nil {
  30. o.Commit()
  31. } else {
  32. o.Rollback()
  33. }
  34. }()
  35. var count int
  36. sql := `SELECT COUNT(1) AS count FROM cygx_activity_user_search_content WHERE user_id=? `
  37. err = o.Raw(sql, item.UserId).QueryRow(&count)
  38. if err != nil {
  39. return
  40. }
  41. if count > 0 || ttlTime > 0 {
  42. sql := `UPDATE cygx_activity_user_search_content SET chart_permissionids = ?,activity_typeids = ?,active_state = ?,is_show_jurisdiction = ? ,modify_time=NOW() WHERE user_id=? `
  43. _, err = o.Raw(sql, item.ChartPermissionids, item.ActivityTypeids, item.ActiveState, item.IsShowJurisdiction, item.UserId).Exec()
  44. return
  45. } else {
  46. lastId, err = o.Insert(item)
  47. }
  48. return
  49. }
  50. //通过用户ID获取用户搜索条件详情
  51. func GetUserSearchContentByUid(uid int) (item *CygxActivityUserSearchContent, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT * FROM cygx_activity_user_search_content WHERE user_id = ? `
  54. err = o.Raw(sql, uid).QueryRow(&item)
  55. return
  56. }
  57. type ActivityUserSearchContentList struct {
  58. IsShowJurisdiction bool `description:"是否仅展示有权限的,1是,0否"`
  59. ListActivityStaus []ActivityStaus
  60. ListChartPermission []*ActivityChartPermission
  61. ListChartPermission2 []*ActivityChartPermission
  62. ListActivityType []*ActivityType
  63. }
  64. type ActivityStaus struct {
  65. Id int
  66. IsChoose bool `description:"是否选择"`
  67. StatusName string
  68. }
  69. type Arrayse struct {
  70. IsChoose bool
  71. }