12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package models
- import (
- "strings"
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- type UserReadRecord struct {
- UserReadRecordId int `orm:"pk" description:"id"`
- UserId int `description:"用户id"`
- ReportId int `description:"报告id"`
- ReportTitle string `description:"报告标题"`
- // ChartPermissionId1 string `description:"一级品种id"`
- // ChartPermissionId2 string `description:"二级品种id"`
- ChartPermissionName string `description:"二级品种名称"`
- ClassifyId1 int `description:"一级级分类id"`
- ClassifyName1 string `description:"一级分类名称"`
- ClassifyId2 int `description:"二级分类id"`
- ClassifyName2 string `description:"二级分类名称"`
- ClassifyId3 int `description:"三级分类id"`
- ClassifyName3 string `description:"三级分类名称"`
- Timestamp int `description:"阅读开始时间戳"`
- EndTimestamp int `description:"阅读结束时间戳"`
- CreateTime time.Time `description:"创建时间"`
- CreateDate string `description:"创建日期"`
- StayTime string `description:"停留时间"`
- StayTimestamp string `description:"停留时间戳"`
- ReportType int `description:"报告类型:1-普通研报;2-pdf研报"`
- }
- func (u *UserReadRecord) Insert() (insertId int64, err error) {
- o := orm.NewOrm()
- insertId, err = o.Insert(u)
- return
- }
- func (u *UserReadRecord) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(u, cols...)
- return
- }
- func GetUserReadRecordListById(recordId int) (items *UserReadRecord, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM user_read_record WHERE 1=1 AND user_read_record_id = ?`
- err = o.Raw(sql, recordId).QueryRow(&items)
- return
- }
- func GetUserReadRecordCountByReportPdfIdAndUserId(reportId, userId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(*) AS count FROM user_read_record WHERE 1=1 AND report_id=? AND user_id = ? AND report_type = 2`
- err = o.Raw(sql, reportId, userId).QueryRow(&count)
- return
- }
- func GetUserReadRecordListByRcordIds(recordIds []string) (items []*UserReadRecord, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM user_read_record WHERE 1=1 `
- var stringIds string
- if len(recordIds) > 0 {
- sql += ` AND user_read_record_id in (?) `
- stringIds = strings.Join(recordIds, ",")
- }
- _, err = o.Raw(sql, stringIds).QueryRows(&items)
- return
- }
- func UpdateUserReadRecordById(recordId, endTimeStamp, stayTime int, stayTimeStr string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE user_read_record SET end_timestamp=?, stay_timestamp=?, stay_time=? WHERE 1=1 AND user_read_record_id = ? `
- _, err = o.Raw(sql, endTimeStamp, stayTime, stayTimeStr, recordId).Exec()
- return
- }
- func UpdateUserReadRecordByRecordIds(recordIds []string, endTimeStamp, stayTime int, stayTimeStr string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE user_read_record SET end_timestamp=?, stay_timestamp=?, stay_time=? WHERE 1=1 `
- var stringIds string
- if len(recordIds) > 0 {
- sql += ` AND user_read_record_id in (?) `
- stringIds = strings.Join(recordIds, ",")
- }
- _, err = o.Raw(sql, endTimeStamp, stayTime, stayTimeStr, stringIds).Exec()
- return
- }
|