123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- package english_report
- import (
- "hongze/hongze_yb_en_api/global"
- "hongze/hongze_yb_en_api/models/base"
- "time"
- )
- type Report struct {
- Id uint `gorm:"primaryKey;column:id" json:"id"`
- AddType int8 `gorm:"column:add_type" json:"add_type"` //新增方式:1:新增报告,2:继承报告
- ClassifyIdFirst int `gorm:"column:classify_id_first" json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `gorm:"column:classify_name_first" json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `gorm:"column:classify_id_second" json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `gorm:"column:classify_name_second" json:"classify_name_second"` //二级分类名称
- Title string `gorm:"column:title" json:"title"` //标题
- Abstract string `gorm:"column:abstract" json:"abstract"` //摘要
- Author string `gorm:"column:author" json:"author"` //作者
- Frequency string `gorm:"column:frequency" json:"frequency"` //频度
- State int8 `gorm:"column:state" json:"state"` //1:未发布,2:已发布
- PublishTime time.Time `gorm:"column:publish_time" json:"publish_time"` //发布时间
- Stage int `gorm:"column:stage" json:"stage"` //期数
- MsgIsSend int8 `gorm:"column:msg_is_send" json:"msg_is_send"` //消息是否已发送,0:否,1:是
- Content string `gorm:"column:content" json:"content"` //内容
- Overview string `gorm:"column:overview" json:"overview"` //概述
- VideoUrl string `gorm:"column:video_url" json:"video_url"` //音频文件URL
- VideoName string `gorm:"column:video_name" json:"video_name"` //音频文件名称
- VideoPlaySeconds string `gorm:"column:video_play_seconds" json:"video_play_seconds"` //音频播放时长
- ContentSub string `gorm:"column:content_sub" json:"content_sub"` //内容前两个章节
- ReportCode string `gorm:"column:report_code" json:"report_code"` //报告唯一编码
- VideoSize string `gorm:"column:video_size" json:"video_size"` //音频文件大小,单位M
- Pv int `gorm:"column:pv" json:"pv"`
- ShareUrl string `gorm:"column:share_url" json:"share_url"` //分享url
- PvEmail uint `gorm:"column:pv_email" json:"pv_email"` //分享邮箱的PV
- UvEmail uint `gorm:"column:uv_email" json:"uv_email"` //分享邮箱的UV
- EmailState uint8 `gorm:"column:email_state" json:"email_state"` //是否已群发邮件:0-否; 1-是
- KeyTakeaways string `gorm:"column:key_takeaways" json:"key_takeaways"` //关键点
- base.TimeBase
- }
- // TableName get sql table name.获取数据库表名
- func (r *Report) TableName() string {
- return "english_report"
- }
- type ReportListReq struct {
- ClassifyIdFirst int `json:"classify_id_first" form:"classify_id_first"`
- ClassifyIdSecond int `json:"classify_id_second" form:"classify_id_second"`
- ClassifyIdRoot int `json:"classify_id_root" form:"classify_id_root"` //顶级分类ID
- base.PageReq
- }
- type ReportListItem struct {
- Id uint `json:"id"`
- AddType int8 `json:"add_type"` //新增方式:1:新增报告,2:继承报告
- ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
- Title string `json:"title"` //标题
- Abstract string `json:"abstract"` //摘要
- Author string `json:"author"` //作者
- Frequency string `json:"frequency"` //频度
- PublishTime string `json:"publish_time"` //发布时间
- Stage int `json:"stage"` //期数
- Overview string `json:"overview"` //概述
- VideoUrl string `json:"video_url"` //音频文件URL
- VideoName string `json:"video_name"` //音频文件名称
- VideoPlaySeconds string `json:"video_play_seconds"` //音频播放时长
- ReportCode string `json:"report_code"` //报告唯一编码
- ShareUrl string `json:"share_url"` //分享url
- CreateTime string `json:"create_time"` //创建时间
- ModifyTime string `json:"modify_time"` //最后更新时间
- ClassifyIdRoot int `json:"classify_id_root"` //顶级分类ID
- ClassifyNameRoot string `json:"classify_name_root"` //顶级分类名称
- }
- type ReportSearchReq struct {
- KeyWord string `json:"key_word" form:"key_word"`
- base.PageReq
- }
- type ReportDetailReq struct {
- ReportCode string `json:"report_code" form:"report_code" binding:"required"` //报告唯一编码
- ShareEmail int `json:"share_email" form:"share_email"` //推送的邮箱ID
- }
- type ReportDetail struct {
- Id uint `json:"id"`
- AddType int8 `json:"add_type"` //新增方式:1:新增报告,2:继承报告
- ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
- Title string `json:"title"` //标题
- Abstract string `json:"abstract"` //摘要
- Author string `json:"author"` //作者
- Content string `json:"content"` //内容
- ContentSub string `json:"content_sub"` //内容
- Frequency string `json:"frequency"` //频度
- PublishTime string `json:"publish_time"` //发布时间
- Stage int `json:"stage"` //期数
- VideoUrl string `json:"video_url"` //音频文件URL
- VideoName string `json:"video_name"` //音频文件名称
- VideoPlaySeconds string `json:"video_play_seconds"` //音频播放时长
- ReportCode string `json:"report_code"` //报告唯一编码
- CreateTime string `json:"create_time"` //创建时间
- ModifyTime string `json:"modify_time"` //最后更新时间
- Overview string `json:"overview"` //概述
- VideoSize string `json:"video_size"` //音频文件大小,单位M
- KeyTakeaways string `json:"key_takeaways"` //关键点
- ClassifyIdRoot int `json:"classify_id_root"` //顶级分类ID
- ClassifyNameRoot string `json:"classify_name_root"` //顶级分类名称
- }
- type ReportDetailResp struct {
- Report *ReportDetail `json:"report"`
- AuthOk bool `json:"auth_ok"`
- Disclaimer string `json:"disclaimer" description:"免责声明"`
- ReportLogo string `description:"报告logo"`
- }
- type SearchEnglishReportItem struct {
- Id uint `json:"id"`
- ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
- Title string `json:"title"` //标题
- Abstract string `json:"abstract"` //摘要
- Author string `json:"author"` //作者
- PublishTime string `json:"publish_time"` //发布时间
- ReportCode string `json:"report_code"` //报告唯一编码
- CreateTime string `json:"create_time"` //创建时间
- ContentSub string `json:"content_sub"` //内容前两个章节"`
- VideoUrl string `json:"video_url"` //视频文件URL
- VideoCoverUrl string `json:"video_cover_url"` //视频文件封面地址
- VideoSeconds string `json:"video_seconds"` //视频时长
- ReportType int `json:"report_type"` //类型:0英文研报,1英文线上路演
- Stage int `json:"stage"` //期数
- ClassifyIdRoot int `json:"classify_id_root"` //顶级分类ID
- ClassifyNameRoot string `json:"classify_name_root"` //顶级分类名称
- }
- type ElasticEnglishReportDetail struct {
- Id string
- ReportId uint
- VideoId uint
- ClassifyIdFirst int
- ClassifyNameFirst string
- ClassifyIdSecond int
- ClassifyNameSecond string
- StageStr string
- Title string
- Abstract string
- Author string
- Frequency string
- PublishState int
- BodyContent string
- ContentSub string
- CreateTime string
- PublishTime string
- ReportCode string
- Overview string
- }
- func (r *Report) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*Report, err error) {
- results = make([]*Report, 0)
- query := global.DEFAULT_MYSQL.Model(r).
- Select("*").
- Where(condition, pars...)
- query.Count(&count)
- if len(page.GetOrderItemsString()) > 0 {
- query = query.Order(page.GetOrderItemsString())
- }
- err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error
- return
- }
- func (r *Report) GetEnglishReportByCode(reportCode string) (item *Report, err error) {
- err = global.MYSQL["rddp"].Model(r).Where("report_code= ?", reportCode).First(&item).Error
- return
- }
- // 修改
- func (r *Report) Update(updateCols []string) (err error) {
- err = global.DEFAULT_MYSQL.Model(r).Select(updateCols).Updates(r).Error
- return
- }
- func (r *Report) UpdatePvEmailByReportCode(reportCode string) (err error) {
- sql := `UPDATE english_report SET pv_email = pv_email+1 WHERE report_code = ? `
- err = global.DEFAULT_MYSQL.Exec(sql, reportCode).Error
- return
- }
- func (r *Report) GetUvEmailByReportIdAndEmailId(reportId, emailId int) (count int, err error) {
- sql := ` SELECT COUNT(*) AS count FROM english_report_email_pv WHERE report_id = ? AND email_id = ? `
- err = global.DEFAULT_MYSQL.Raw(sql, reportId, emailId).Scan(&count).Error
- return
- }
- func (r *Report) UpdateUvEmailByReportCode(reportCode string) (err error) {
- sql := `UPDATE english_report SET uv_email = uv_email+1 WHERE report_code = ? `
- err = global.DEFAULT_MYSQL.Exec(sql, reportCode).Error
- return
- }
- func (r *Report) UpdatePvByReportCode(reportCode string) (err error) {
- sql := `UPDATE english_report SET pv = pv+1 WHERE report_code = ? `
- err = global.DEFAULT_MYSQL.Exec(sql, reportCode).Error
- return
- }
|