12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package models
- import "rdluck_tools/orm"
- type ResearchReportViewers struct {
- ResearchReportName string
- ReportType string
- Count int //访问次数
- UserCount int //访问人数
- CreateDate string
- }
- func GetResearchReportViewers(reportType string) (items []*ResearchReportViewers, err error) {
- sql := `select rr.research_report_name,rr.type as report_type,count(*) AS count,count(DISTINCT user_id) AS user_count
- from user_view_history uvh
- inner join research_report rr on rr.research_report_id = uvh.research_report_id
- where rr.type = ?
- group by rr.research_report_id
- order by rr.research_report_date desc`
- o := orm.NewOrm()
- _, err = o.Raw(sql, reportType).QueryRows(&items)
- return
- }
- func GetRddpReportViewers() (items []*ResearchReportViewers, err error) {
- sql := `select b.title as research_report_name, replace(SUBSTRING(b.create_time,6,5),'-','') as create_date ,b.classify_name_second AS report_type,count(*) AS count,count(DISTINCT a.user_id) AS user_count
- from report_view_record as a
- inner join report as b on a.report_id=b.id
- group by b.id
- order by b.create_time desc
- `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type ReportType struct {
- TypeName string
- TypeValue string
- }
- type ResearchReportViewersDetail struct {
- RealName string
- CompanyName string
- CreatedTime string //访问时间
- ResearchReportName string
- ReportVariety string
- ResearchReportType string
- ReportCreateDate string
- }
- func GetResearchReportViewersDetail(startTime, reportType string) (items []*ResearchReportViewersDetail, err error) {
- sql := `
- select u.real_name,c.company_name,uvh.created_time,rr.research_report_name,ifnull(rct.report_chapter_type_name,rr.report_variety) as report_variety,rr.type as research_report_type
- from user_view_history uvh
- inner join wx_user u on u.user_id = uvh.user_id
- inner join company c on c.company_id = u.company_id
- inner join research_report rr on rr.research_report_id = uvh.research_report_id
- left join research_report_type rrt on rrt.research_report_type_id = uvh.research_report_type_id
- left join report_chapter_type rct on rct.report_chapter_type_id = rrt.type_id
- where uvh.created_time > ?
- and rr.type =?
- and c.company_id not in (1,16)
- `
- o := orm.NewOrm()
- _, err = o.Raw(sql, startTime, reportType).QueryRows(&items)
- return
- }
- func GetRddpReportViewersDetail(startTime string) (items []*ResearchReportViewersDetail, err error) {
- sql := `
- SELECT u.real_name,c.company_name,uvh.create_time as created_time,REPLACE(SUBSTRING(r.create_time,6,5),'-','') AS report_create_date,r.title as research_report_name,r.classify_name_second as research_report_type
- FROM hongze_rddp.report_view_record AS uvh
- INNER JOIN hongze_rddp.report AS r ON uvh.report_id=r.id
- INNER JOIN wx_user u ON u.user_id = uvh.user_id
- INNER JOIN company c ON c.company_id = u.company_id
- WHERE uvh.create_time >?
- AND c.company_id NOT IN (1,16)
- ORDER BY uvh.create_time DESC
- `
- o := orm.NewOrm()
- _, err = o.Raw(sql, startTime).QueryRows(&items)
- return
- }
|