activity_restrict_signup.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hz_crm_api/utils"
  5. "time"
  6. )
  7. type CygxActivityRestrictSignup 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. IsRestrict int `description:"是否限制报名,1是,0否"`
  16. }
  17. // 添加
  18. func AddCygxActivityRestrictSignup(item *CygxActivityRestrictSignup) (err error) {
  19. o := orm.NewOrmUsingDB("hz_cygx")
  20. _, err = o.Insert(item)
  21. return
  22. }
  23. // 批量添加
  24. func AddCygxActivityRestrictSignupList(items []*CygxActivityRestrictSignup) (lastId int64, err error) {
  25. lenitems := len(items)
  26. if lenitems == 0 {
  27. return
  28. }
  29. o := orm.NewOrmUsingDB("hz_cygx")
  30. _, err = o.InsertMulti(1, items)
  31. return
  32. }
  33. // 删除
  34. func DeleteCygxActivityRestrictSignup(uid int) (err error) {
  35. o := orm.NewOrmUsingDB("hz_cygx")
  36. sql := ` DELETE FROM cygx_activity_restrict_signup WHERE user_id=?`
  37. _, err = o.Raw(sql, uid).Exec()
  38. return
  39. }
  40. // 删除
  41. func DeleteCygxActivityRestrictSignupByUserIds(userIdDelArr []int) (err error) {
  42. if len(userIdDelArr) == 0 {
  43. return
  44. }
  45. o := orm.NewOrmUsingDB("hz_cygx")
  46. sql := ` DELETE FROM cygx_activity_restrict_signup WHERE 1= 1 AND user_id IN (` + utils.GetOrmInReplace(len(userIdDelArr)) + `)`
  47. _, err = o.Raw(sql, userIdDelArr).Exec()
  48. return
  49. }
  50. // 获取某一用户是否被限制报名
  51. func GetUserRestrictCount(mobile string) (count int, err error) {
  52. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_restrict_signup WHERE is_restrict=1 AND mobile=? `
  53. o := orm.NewOrmUsingDB("hz_cygx")
  54. err = o.Raw(sqlCount, mobile).QueryRow(&count)
  55. return
  56. }
  57. // 获取用户是否被限制报名
  58. func GetRestrictSignupCountByUid(uid int) (count int, err error) {
  59. sqlCount := `SELECT COUNT( 1 ) count FROM cygx_activity_restrict_signup WHERE user_id = ?`
  60. o := orm.NewOrmUsingDB("hz_cygx")
  61. err = o.Raw(sqlCount, uid).QueryRow(&count)
  62. return
  63. }
  64. // 列表
  65. func GetCygxActivityRestrictSignupList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityRestrictSignup, err error) {
  66. o := orm.NewOrmUsingDB("hz_cygx")
  67. sql := `SELECT * FROM cygx_activity_restrict_signup as art WHERE 1= 1 `
  68. if condition != "" {
  69. sql += condition
  70. }
  71. sql += ` LIMIT ?,? `
  72. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  73. return
  74. }