package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxXzsChooseCategoryZhouqi struct { Id int `orm:"column(id);pk"` UserId int `description:"用户ID"` Mobile string `description:"手机号"` Email string `description:"邮箱"` CompanyId int `description:"公司id"` CompanyName string `description:"公司名称"` RealName string `description:"用户实际名称"` CategoryId int `description:"cygx_zhouqi_article_map 表主键"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"更新时间"` } // 根据手机号获取用户关注的产业 func GetCygxXzsChooseCategoryZhouqiList(mobile string) (items []*CygxXzsChooseCategoryZhouqi, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_xzs_choose_category_zhouqi WHERE mobile = ?` _, err = o.Raw(sql, mobile).QueryRows(&items) return } // 添加 func AddCygxCategoryFllowZhouqi(item *CygxXzsChooseCategoryZhouqi) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } // 删除 func RemoveCygxCategoryFllowZhouqi(mobile string, CategoryId int) (err error) { o := orm.NewOrm() sql := `DELETE FROM cygx_xzs_choose_category_zhouqi WHERE mobile=? AND category_id=? ` _, err = o.Raw(sql, mobile, CategoryId).Exec() return } // 获取关注数量 func GetCountCategoryFllowZhouqi(categoryId int, mobile string) (count int, err error) { sql := `SELECT COUNT(1) AS count FROM cygx_xzs_choose_category_zhouqi WHERE mobile=? AND category_id=? ` err = orm.NewOrm().Raw(sql, mobile, categoryId).QueryRow(&count) return } type XzsChooseMapZhouqiResp struct { Id int `description:"id"` CategoryId int `description:"权益文章对应分类,cygx_article"` CharPpermissionName string `description:"权限名称"` MatchTypeName string `description:"分类名称"` }