user_admin_share_code.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxUserAdminShareCode struct {
  7. UserAdminCodeId int `orm:"column(user_admin_share_code_id);pk";comment:"主键ID"`
  8. SellerName string `comment:"所属销售"`
  9. SellerId int `comment:"所属销售id"`
  10. Mobile string `comment:"手机号"`
  11. CreateTime time.Time `comment:"创建时间"`
  12. ModifyTime time.Time `comment:"修改时间"`
  13. ShareCode string `comment:"分享码,对seller_id进行MD5加密的结果"`
  14. }
  15. // 获取数量
  16. func GetCygxUserAdminShareCodeByShareCodeCount(chareCode string) (count int, err error) {
  17. o := orm.NewOrm()
  18. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_user_admin_share_code WHERE share_code = ? `
  19. err = o.Raw(sqlCount, chareCode).QueryRow(&count)
  20. return
  21. }
  22. func AddCygxUserAdminShareCode(item *CygxUserAdminShareCode) (err error) {
  23. o := orm.NewOrm()
  24. _, err = o.Insert(item)
  25. return
  26. }
  27. func GetUserAdminShareCodeByShareCode(shareCode string) (item *CygxUserAdminShareCode, err error) {
  28. o := orm.NewOrm()
  29. sql := ` SELECT * FROM cygx_user_admin_share_code WHERE share_code = ? `
  30. err = o.Raw(sql, shareCode).QueryRow(&item)
  31. return
  32. }