package models import ( "eta/eta_api/global" "eta/eta_api/utils" ) type ResearchReportViewPUV struct { ResearchReportId int Pv int Uv int } // GetPUVByResearchReportIds 通过报告IDs获取老报告PV、UV func GetPUVByResearchReportIds(reportIds []string) (list []*ResearchReportViewPUV, err error) { if len(reportIds) == 0 { return } o := global.DbMap[utils.DbNameWeekly] 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 = o.Raw(sql, reportIds).Find(&list).Error return }