package models import ( "eta_gn/eta_api/global" "eta_gn/eta_api/utils" ) type ResearchReportViewPUV struct { ResearchReportId int `gorm:"column:research_report_id;primaryKey;type:int" orm:"column(research_report_id);pk" description:"研究报告ID"` Pv int `gorm:"column:pv;type:int" orm:"column(pv)" description:"页面浏览量"` Uv int `gorm:"column:uv;type:int" orm:"column(uv)" description:"独立访客数"` } // GetPUVByResearchReportIds 通过报告IDs获取老报告PV、UV func GetPUVByResearchReportIds(reportIds []string) (list []*ResearchReportViewPUV, err error) { if len(reportIds) == 0 { return } sql := `SELECT research_report_id, COUNT(1) AS pv, COUNT(DISTINCT user_id) AS uv FROM user_view_history WHERE research_report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) GROUP BY research_report_id` err = global.DmSQL["weekly"].Raw(sql, reportIds).Scan(&list).Error return }