123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxArticleHistoryRecordAll struct {
- Id int `orm:"column(id);pk"`
- ArticleId int
- UserId int
- CreateTime string
- ModifyTime time.Time
- Mobile string `description:"手机号"`
- Email string `description:"邮箱"`
- CompanyId int `description:"公司id"`
- CompanyName string `description:"公司名称"`
- StopTime int `description:"停留时间"`
- OutType int `description:"退出方式,1正常退出,2强制关闭"`
- Source string `description:"来源,MOBILE:手机端,PC:电脑端"`
- RealName string `description:"用户实际名称"`
- CreateDateApi time.Time `description:"同步创建时间"`
- CelueHistoryId int `description:"策略平台记录的ID"`
- Platfor int `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
- IsDel int `description:"是否删除"`
- RegisterPlatform int `description:"来源"`
- CompanyStatus string `description:"公司状态"`
- SellerName string `description:"所属销售"`
- }
- // 获取数量
- func GetCygxArticleHistoryRecordAllCountBycondition(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_history_record_all as art WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 列表
- func GetCygxArticleHistoryRecordAllList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleHistoryRecordAll, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_article_history_record_all as art WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type CygxArticleHistoryRecordAllResp struct {
- Id int `orm:"column(id);pk"`
- ArticleId int
- UserId int
- CreateTime string
- ModifyTime time.Time
- Mobile string `description:"手机号"`
- Email string `description:"邮箱"`
- CompanyId int `description:"公司id"`
- CompanyName string `description:"公司名称"`
- StopTime int `description:"停留时间"`
- OutType int `description:"退出方式,1正常退出,2强制关闭"`
- Source string `description:"来源,MOBILE:手机端,PC:电脑端"`
- RealName string `description:"用户实际名称"`
- CreateDateApi time.Time `description:"同步创建时间"`
- CelueHistoryId int `description:"策略平台记录的ID"`
- Platfor int `description:"PV阅读记录来源,1:查研观向,2:策略平台"`
- IsDel int `description:"是否删除"`
- RegisterPlatform int `description:"来源"`
- Title string `description:"标题"`
- CategoryName string `description:"一级分类"`
- }
- // 列表
- func GetCygxArticleHistoryRecordAllListNoLimit(condition string, pars []interface{}) (items []*CygxArticleHistoryRecordAllResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT art.* ,a.title,a.category_name FROM cygx_article_history_record_all as art INNER JOIN cygx_article AS a ON a.article_id = art.article_id WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // AddCygxArticleHistoryRecordAllMulti 批量添加
- func AddCygxArticleHistoryRecordAllMulti(itemsCelue []*CygxCelueArticleHistoryRecord, items []*CygxArticleHistoryRecordAll) (err error) {
- o, err := orm.NewOrm().Begin()
- if err != nil {
- return
- }
- defer func() {
- if err == nil {
- o.Commit()
- } else {
- o.Rollback()
- }
- }()
- //批量插入新的关联数据
- if len(itemsCelue) > 0 {
- //批量添加流水信息
- _, err = o.InsertMulti(len(itemsCelue), itemsCelue)
- }
- //批量插入新的关联数据
- if len(items) > 0 {
- //批量添加流水信息
- _, err = o.InsertMulti(len(items), items)
- }
- return
- }
|