activity_restrict_signup.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hongze_cygx/utils"
  5. )
  6. // 批量添加
  7. func AddCygxActivityRestrictSignupList(items []*CygxActivityRestrictSignup) (lastId int64, err error) {
  8. lenitems := len(items)
  9. if lenitems == 0 {
  10. return
  11. }
  12. o := orm.NewOrm()
  13. _, err = o.InsertMulti(1, items)
  14. return
  15. }
  16. // 删除
  17. func DeleteCygxActivityRestrictSignupByUserIds(userIdDelArr []int) (err error) {
  18. if len(userIdDelArr) == 0 {
  19. return
  20. }
  21. o := orm.NewOrm()
  22. sql := ` DELETE FROM cygx_activity_restrict_signup WHERE 1= 1 AND user_id IN (` + utils.GetOrmInReplace(len(userIdDelArr)) + `)`
  23. _, err = o.Raw(sql, userIdDelArr).Exec()
  24. return
  25. }
  26. // 列表
  27. func GetCygxActivityRestrictSignupList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityRestrictSignup, err error) {
  28. o := orm.NewOrm()
  29. sql := `SELECT * FROM cygx_activity_restrict_signup as art WHERE 1= 1 `
  30. if condition != "" {
  31. sql += condition
  32. }
  33. sql += ` LIMIT ?,? `
  34. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  35. return
  36. }