package models import ( "github.com/beego/beego/v2/client/orm" "strconv" "time" ) type CygxPageHistoryRecord struct { Id int `orm:"column(id);pk"` UserId int `description:"用户ID"` CreateTime time.Time `description:"创建时间"` Mobile string `description:"手机号"` Email string `description:"邮箱"` CompanyId int `description:"公司id"` CompanyName string `description:"公司名称"` DetailId string `description:"详情ID"` ChartPermissionId int `description:"行业ID"` IndustrialManagementId string `description:"产业ID"` PageType string `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars,已结束活动:OverActivity"` Parameter string `description:"参数"` Router string `description:"路由"` PageRouter string `description:"前端页面路径"` RegisterPlatform int `description:"来源 1小程序,2:网页"` } type CygxPageHistoryRecordRep struct { DetailId string `description:"详情ID"` ChartPermissionId int `description:"行业ID"` IndustrialManagementId string `description:"产业ID"` PageType string `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars , 我的日程:MySchedule, 更多标签:LabelMore , 文章复制:ArticleCopy"` } type CygxPageHistoryRecordHtgjRep struct { DetailId string `description:"详情ID"` ChartPermissionId int `description:"行业ID"` IndustrialManagementId string `description:"产业ID"` CompanyCode string `description:"机构编码"` CompanyName string `description:"机构名称"` Email string `description:"机构邮箱"` Sign string `description:"签名"` } // 添加 func AddCygxPageHistoryRecord(item *CygxPageHistoryRecord) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } type PageRouter struct { PageRouter string } func GetTimeLineRecordCount(userId, industrialManagementId int) (count int, err error) { o := orm.NewOrm() sql := `SELECT COUNT(1) AS count FROM cygx_page_history_record WHERE user_id=? AND router = '/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=` + strconv.Itoa(industrialManagementId) + `'` err = o.Raw(sql, userId).QueryRow(&count) return } func GetTimeLineRecordItem(userId, industrialManagementId int) (item *CygxPageHistoryRecord, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_page_history_record WHERE user_id=? AND router = '/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=` + strconv.Itoa(industrialManagementId) + `' ORDER BY create_time DESC LIMIT 1,1 ` err = o.Raw(sql, userId).QueryRow(&item) return } func GetTimeLineRecordAllCount(userId int, date string) (items []*CygxPageHistoryRecord, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_page_history_record WHERE user_id=? AND router LIKE '%/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=%' AND create_time > ? ORDER BY id DESC LIMIT 10 ` _, err = o.Raw(sql, userId, date).QueryRows(&items) return }