cygx_industry_top.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxIndustryTop struct {
  7. Id int `orm:"column(id);pk"`
  8. IndustrialManagementId int `description:"产业D"`
  9. UserId int `description:"用户ID"`
  10. CreateTime time.Time `description:"创建时间"`
  11. }
  12. type CygxIndustryTopRep struct {
  13. IndustrialManagementId int `description:"产业D"`
  14. }
  15. //添加收藏信息
  16. func AddCygxIndustryTop(item *CygxIndustryTop) (lastId int64, err error) {
  17. o := orm.NewOrm()
  18. lastId, err = o.Insert(item)
  19. return
  20. }
  21. type CygxIndustryTopResp struct {
  22. Status int `description:"1:收藏,2:取消收藏"`
  23. CollectCount int `description:"收藏总数"`
  24. }
  25. func RemoveCygxIndustryTop(userId, industrialManagementId int) (err error) {
  26. o := orm.NewOrm()
  27. sql := `DELETE FROM cygx_industry_top WHERE user_id=? AND industrial_management_id=? `
  28. _, err = o.Raw(sql, userId, industrialManagementId).Exec()
  29. return
  30. }
  31. //判断这篇文章是否被用户收藏
  32. func GetCygxIndustryTop(userId, industrialManagementId int) (count int, err error) {
  33. sql := `SELECT COUNT(1) AS count FROM cygx_industry_top WHERE user_id=? AND industrial_management_id=? `
  34. err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
  35. return
  36. }