123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxYanxuanSpecialRecord struct {
- CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
- UserId int // 用户ID
- Mobile string // 手机号
- Email string // 邮箱
- CompanyId int // 公司ID
- CompanyName string // 公司名称
- RealName string // 用户实际名称
- SellerName string // 所属销售
- CreateTime time.Time // 创建时间
- ModifyTime time.Time // 修改时间
- RegisterPlatform int // 来源 1小程序,2:网页
- YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
- StopTime int // 停留时间
- PermissionCode int // 权限状态,1:有权限,0:无权限
- }
- type CygxYanxuanSpecialRecordResp struct {
- CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
- UserId int // 用户ID
- Mobile string // 手机号
- Email string // 邮箱
- CompanyId int // 公司ID
- CompanyName string // 公司名称
- RealName string // 用户实际名称
- SellerName string // 所属销售
- CreateTime string // 创建时间
- ModifyTime time.Time // 修改时间
- RegisterPlatform int // 来源 1小程序,2:网页
- YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
- StopTime int // 停留时间
- }
- func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type AddCygxYanxuanSpecialRecordReq struct {
- SpecialId int `description:"专栏文章id"`
- StopTime int `description:"停留时间"`
- }
- // 获取数量
- func GetCygxYanxuanSpecialRecordCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as art WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 获取数量
- func GetCygxYanxuanSpecialRecordCountGroup(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT count(*) AS count FROM
- ( SELECT COUNT(*) FROM cygx_yanxuan_special_record AS art WHERE 1 = 1 ` + condition + ` GROUP BY user_id ) f `
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 判断一个用户是否阅读过 某一篇研选专栏
- func GetCygxYanxuanSpecialRecordCountByUser(userId, yanxuanSpecialId int) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as a WHERE user_id= ? AND yanxuan_special_id = ? `
- o := orm.NewOrm()
- err = o.Raw(sqlCount, userId, yanxuanSpecialId).QueryRow(&count)
- return
- }
- // 详细日志记录,不过滤时长小于 3 秒的那种
- type CygxYanxuanSpecialRecordLog struct {
- CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
- UserId int // 用户ID
- Mobile string // 手机号
- Email string // 邮箱
- CompanyId int // 公司ID
- CompanyName string // 公司名称
- RealName string // 用户实际名称
- SellerName string // 所属销售
- CreateTime time.Time // 创建时间
- ModifyTime time.Time // 修改时间
- RegisterPlatform int // 来源 1小程序,2:网页
- YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
- StopTime int // 停留时间
- PermissionCode int // 权限状态,1:有权限,0:无权限
- }
- func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- // 列表
- func GetCygxYanxuanSpecialRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialRecordResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_yanxuan_special_record as art WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type LisYanxuanSpecialRecordPvResp struct {
- YanxuanSpecialId int `description:"文章ID"`
- Pv int `description:"pv"`
- Uv int `description:"pv"`
- }
- // pv 列表
- func GetCygxYanxuanSpecialRecordListPv(condition string, pars []interface{}) (items []*LisYanxuanSpecialRecordPvResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- COUNT( 1 ) AS pv,
- yanxuan_special_id
- FROM
- cygx_yanxuan_special_record WHERE 1 = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY yanxuan_special_id `
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
|