123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxIndustryFllow struct {
- Id int `orm:"column(id);pk"`
- IndustrialManagementId int `description:"产业D"`
- UserId int `description:"用户ID"`
- Mobile string `description:"手机号"`
- Email string `description:"邮箱"`
- CompanyId int `description:"公司id"`
- CompanyName string `description:"公司名称"`
- Type int `description:"操作方式,1报名,2取消报名"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- RealName string `description:"用户实际名称"`
- Source int `description:"来源1查研观向,2查研观向小助手"`
- }
- type CygxIndustryFllowRep struct {
- IndustrialManagementId int `description:"产业D"`
- }
- type CygxCategoryFllowRep struct {
- CategoryId int `description:"分类ID"`
- }
- // 根据手机号获取用户关注的产业
- func GetCygxIndustryFllowList(mobile string) (items []*CygxIndustryFllow, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_industry_fllow WHERE mobile = ?`
- _, err = o.Raw(sql, mobile).QueryRows(&items)
- return
- }
- type CygxIndustryFllowResp struct {
- Status int `description:"1:关注,2:取消关注"`
- }
- // 获取数量
- func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
- sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? `
- err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
- return
- }
- // 添加
- func AddCygxIndustryFllow(item *CygxIndustryFllow) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- // 删除
- func RemoveCygxIndustryFllow(userId, industrialManagementId int) (err error) {
- o := orm.NewOrm()
- sql := `DELETE FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? `
- _, err = o.Raw(sql, userId, industrialManagementId).Exec()
- return
- }
- // 获取某个用户关注某个行业下的产业数量
- func GetCountCygxIndustryFllowByUidAndChartPermissionId(userId, ChartPermissionId int) (count int, err error) {
- sql := `SELECT
- COUNT( 1 ) AS count
- FROM
- cygx_industry_fllow AS f
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = f.industrial_management_id
- WHERE
- user_id = ?
- AND m.chart_permission_id = ? `
- err = orm.NewOrm().Raw(sql, userId, ChartPermissionId).QueryRow(&count)
- return
- }
- // 获取用户关注的产业列表
- func GetUserFllowIndustrialList(userId int) (items []*CygxIndustryFllow, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- f.user_id,
- m.industry_name,
- m.industrial_management_id
- FROM
- cygx_industry_fllow AS f
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = f.industrial_management_id
- WHERE
- 1 = 1
- AND f.user_id = ? `
- _, err = o.Raw(sql, userId).QueryRows(&items)
- return
- }
- // UpdateIndustrialManagementTimeLineData 更新时间线关联对应最新文章的数据信息
- func UpdateIndustrialManagementTimeLineData(industrialManagementId int, timeLineData string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_industrial_management SET time_line_data = ? WHERE industrial_management_id = ? `
- _, err = o.Raw(sql, timeLineData, industrialManagementId).Exec()
- return
- }
|