industry_fllow.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxIndustryFllow struct {
  7. Id int `orm:"column(id);pk"`
  8. IndustrialManagementId int `description:"产业D"`
  9. UserId int `description:"用户ID"`
  10. Mobile string `description:"手机号"`
  11. Email string `description:"邮箱"`
  12. CompanyId int `description:"公司id"`
  13. CompanyName string `description:"公司名称"`
  14. Type int `description:"操作方式,1报名,2取消报名"`
  15. CreateTime time.Time `description:"创建时间"`
  16. ModifyTime time.Time `description:"更新时间"`
  17. }
  18. type CygxIndustryFllowRep struct {
  19. IndustrialManagementId int `description:"产业D"`
  20. }
  21. //添加
  22. func AddCygxIndustryFllow(item *CygxIndustryFllow) (lastId int64, err error) {
  23. o := orm.NewOrm()
  24. lastId, err = o.Insert(item)
  25. return
  26. }
  27. type CygxIndustryFllowResp struct {
  28. Status int `description:"1:关注,2:取消关注"`
  29. GoFollow bool `description:"是否去关注"`
  30. }
  31. func RemoveCygxIndustryFllow(userId, industrialManagementId, doType int) (err error) {
  32. o := orm.NewOrm()
  33. sql := `UPDATE cygx_industry_fllow SET type = ? ,modify_time=? WHERE user_id=? AND industrial_management_id=? `
  34. _, err = o.Raw(sql, doType, time.Now(), userId, industrialManagementId).Exec()
  35. return
  36. }
  37. //获取数量
  38. func GetCountCygxIndustryFllow(userId, industrialManagementId int, condition string) (count int, err error) {
  39. sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? ` + condition
  40. err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
  41. return
  42. }
  43. //获取数量
  44. func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
  45. sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? `
  46. err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
  47. return
  48. }