user_remind.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxUserRemind struct {
  7. Id int `orm:"column(id);pk"`
  8. AdminId int
  9. UserId int
  10. CreateTime time.Time
  11. ModifyTime time.Time
  12. Mobile string `description:"手机号"`
  13. Email string `description:"邮箱"`
  14. CompanyId int `description:"公司id"`
  15. CompanyName string `description:"公司名称"`
  16. RealName string `description:"用户实际名称"`
  17. AdminName string `description:"管理员销售姓名"`
  18. }
  19. // 添加
  20. func AddCygxUserRemind(item *CygxUserRemind) (lastId int64, err error) {
  21. o := orm.NewOrmUsingDB("hz_cygx")
  22. lastId, err = o.Insert(item)
  23. return
  24. }
  25. // AddCygxUserRemindMulti 批量添加
  26. func AddCygxUserRemindMulti(items []*CygxUserRemind) (err error) {
  27. o, err := orm.NewOrmUsingDB("hz_cygx").Begin()
  28. if err != nil {
  29. return
  30. }
  31. defer func() {
  32. if err == nil {
  33. o.Commit()
  34. } else {
  35. o.Rollback()
  36. }
  37. }()
  38. if len(items) > 0 {
  39. //批量添加流水信息
  40. _, err = o.InsertMulti(len(items), items)
  41. }
  42. return
  43. }
  44. type CygxUserRemindResp struct {
  45. Status int `description:"1:添加,2:取消"`
  46. }
  47. func RemoveCygxUserRemind(userId int) (err error) {
  48. o := orm.NewOrmUsingDB("hz_cygx")
  49. sql := `DELETE FROM cygx_user_remind WHERE user_id=? `
  50. _, err = o.Raw(sql, userId).Exec()
  51. return
  52. }
  53. func RemoveCygxUserRemindByCompanyId(companyId int) (err error) {
  54. o := orm.NewOrmUsingDB("hz_cygx")
  55. sql := `DELETE FROM cygx_user_remind WHERE company_id = ? `
  56. _, err = o.Raw(sql, companyId).Exec()
  57. return
  58. }
  59. func GetCygxUserRemindCount(userId int) (count int, err error) {
  60. o := orm.NewOrmUsingDB("hz_cygx")
  61. sql := `SELECT COUNT(1) AS count FROM cygx_user_remind WHERE user_id=? `
  62. err = o.Raw(sql, userId).QueryRow(&count)
  63. return
  64. }
  65. // 列表
  66. func GetCygxUserRemindList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserRemind, err error) {
  67. o := orm.NewOrmUsingDB("hz_cygx")
  68. sql := `SELECT * FROM cygx_user_remind as art WHERE 1= 1 `
  69. if condition != "" {
  70. sql += condition
  71. }
  72. if startSize+startSize > 0 {
  73. sql += ` LIMIT ?,? `
  74. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  75. } else {
  76. _, err = o.Raw(sql, pars).QueryRows(&items)
  77. }
  78. return
  79. }
  80. // 根据公司ID获取列表
  81. func GetCygxUserRemindListByCompanyId(companyId int) (items []*CygxUserRemind, err error) {
  82. o := orm.NewOrmUsingDB("hz_cygx")
  83. sql := `SELECT * FROM cygx_user_remind WHERE 1= 1 AND company_id = ? `
  84. _, err = o.Raw(sql, companyId).QueryRows(&items)
  85. return
  86. }