report.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. package english_report
  2. import (
  3. "hongze/hongze_yb_en_api/global"
  4. "hongze/hongze_yb_en_api/models/base"
  5. "time"
  6. )
  7. type Report struct {
  8. Id uint `gorm:"primaryKey;column:id" json:"id"`
  9. AddType int8 `gorm:"column:add_type" json:"add_type"` //新增方式:1:新增报告,2:继承报告
  10. ClassifyIdFirst int `gorm:"column:classify_id_first" json:"classify_id_first"` //一级分类id
  11. ClassifyNameFirst string `gorm:"column:classify_name_first" json:"classify_name_first"` //一级分类名称
  12. ClassifyIdSecond int `gorm:"column:classify_id_second" json:"classify_id_second"` //二级分类id
  13. ClassifyNameSecond string `gorm:"column:classify_name_second" json:"classify_name_second"` //二级分类名称
  14. Title string `gorm:"column:title" json:"title"` //标题
  15. Abstract string `gorm:"column:abstract" json:"abstract"` //摘要
  16. Author string `gorm:"column:author" json:"author"` //作者
  17. Frequency string `gorm:"column:frequency" json:"frequency"` //频度
  18. State int8 `gorm:"column:state" json:"state"` //1:未发布,2:已发布
  19. PublishTime time.Time `gorm:"column:publish_time" json:"publish_time"` //发布时间
  20. Stage int `gorm:"column:stage" json:"stage"` //期数
  21. MsgIsSend int8 `gorm:"column:msg_is_send" json:"msg_is_send"` //消息是否已发送,0:否,1:是
  22. Content string `gorm:"column:content" json:"content"` //内容
  23. Overview string `gorm:"column:overview" json:"overview"` //概述
  24. VideoUrl string `gorm:"column:video_url" json:"video_url"` //音频文件URL
  25. VideoName string `gorm:"column:video_name" json:"video_name"` //音频文件名称
  26. VideoPlaySeconds string `gorm:"column:video_play_seconds" json:"video_play_seconds"` //音频播放时长
  27. ContentSub string `gorm:"column:content_sub" json:"content_sub"` //内容前两个章节
  28. ReportCode string `gorm:"column:report_code" json:"report_code"` //报告唯一编码
  29. VideoSize string `gorm:"column:video_size" json:"video_size"` //音频文件大小,单位M
  30. Pv int `gorm:"column:pv" json:"pv"`
  31. ShareUrl string `gorm:"column:share_url" json:"share_url"` //分享url
  32. PvEmail uint `gorm:"column:pv_email" json:"pv_email"` //分享邮箱的PV
  33. UvEmail uint `gorm:"column:uv_email" json:"uv_email"` //分享邮箱的UV
  34. EmailState uint8 `gorm:"column:email_state" json:"email_state"` //是否已群发邮件:0-否; 1-是
  35. KeyTakeaways string `gorm:"column:key_takeaways" json:"key_takeaways"` //关键点
  36. base.TimeBase
  37. }
  38. // TableName get sql table name.获取数据库表名
  39. func (r *Report) TableName() string {
  40. return "english_report"
  41. }
  42. type ReportListReq struct {
  43. ClassifyIdFirst int `json:"classify_id_first" form:"classify_id_first"`
  44. ClassifyIdSecond int `json:"classify_id_second" form:"classify_id_second"`
  45. ClassifyIdRoot int `json:"classify_id_root" form:"classify_id_root"` //顶级分类ID
  46. base.PageReq
  47. }
  48. type ReportListItem struct {
  49. Id uint `json:"id"`
  50. AddType int8 `json:"add_type"` //新增方式:1:新增报告,2:继承报告
  51. ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
  52. ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
  53. ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
  54. ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
  55. Title string `json:"title"` //标题
  56. Abstract string `json:"abstract"` //摘要
  57. Author string `json:"author"` //作者
  58. Frequency string `json:"frequency"` //频度
  59. PublishTime string `json:"publish_time"` //发布时间
  60. Stage int `json:"stage"` //期数
  61. Overview string `json:"overview"` //概述
  62. VideoUrl string `json:"video_url"` //音频文件URL
  63. VideoName string `json:"video_name"` //音频文件名称
  64. VideoPlaySeconds string `json:"video_play_seconds"` //音频播放时长
  65. ReportCode string `json:"report_code"` //报告唯一编码
  66. ShareUrl string `json:"share_url"` //分享url
  67. CreateTime string `json:"create_time"` //创建时间
  68. ModifyTime string `json:"modify_time"` //最后更新时间
  69. ClassifyIdRoot int `json:"classify_id_root"` //顶级分类ID
  70. ClassifyNameRoot string `json:"classify_name_root"` //顶级分类名称
  71. }
  72. type ReportSearchReq struct {
  73. KeyWord string `json:"key_word" form:"key_word"`
  74. base.PageReq
  75. }
  76. type ReportDetailReq struct {
  77. ReportCode string `json:"report_code" form:"report_code" binding:"required"` //报告唯一编码
  78. ShareEmail int `json:"share_email" form:"share_email"` //推送的邮箱ID
  79. }
  80. type ReportDetail struct {
  81. Id uint `json:"id"`
  82. AddType int8 `json:"add_type"` //新增方式:1:新增报告,2:继承报告
  83. ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
  84. ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
  85. ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
  86. ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
  87. Title string `json:"title"` //标题
  88. Abstract string `json:"abstract"` //摘要
  89. Author string `json:"author"` //作者
  90. Content string `json:"content"` //内容
  91. ContentSub string `json:"content_sub"` //内容
  92. Frequency string `json:"frequency"` //频度
  93. PublishTime string `json:"publish_time"` //发布时间
  94. Stage int `json:"stage"` //期数
  95. VideoUrl string `json:"video_url"` //音频文件URL
  96. VideoName string `json:"video_name"` //音频文件名称
  97. VideoPlaySeconds string `json:"video_play_seconds"` //音频播放时长
  98. ReportCode string `json:"report_code"` //报告唯一编码
  99. CreateTime string `json:"create_time"` //创建时间
  100. ModifyTime string `json:"modify_time"` //最后更新时间
  101. Overview string `json:"overview"` //概述
  102. VideoSize string `json:"video_size"` //音频文件大小,单位M
  103. KeyTakeaways string `json:"key_takeaways"` //关键点
  104. ClassifyIdRoot int `json:"classify_id_root"` //顶级分类ID
  105. ClassifyNameRoot string `json:"classify_name_root"` //顶级分类名称
  106. }
  107. type ReportDetailResp struct {
  108. Report *ReportDetail `json:"report"`
  109. AuthOk bool `json:"auth_ok"`
  110. Disclaimer string `json:"disclaimer" description:"免责声明"`
  111. ReportLogo string `description:"报告logo"`
  112. }
  113. type SearchEnglishReportItem struct {
  114. Id uint `json:"id"`
  115. ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
  116. ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
  117. ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
  118. ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
  119. Title string `json:"title"` //标题
  120. Abstract string `json:"abstract"` //摘要
  121. Author string `json:"author"` //作者
  122. PublishTime string `json:"publish_time"` //发布时间
  123. ReportCode string `json:"report_code"` //报告唯一编码
  124. CreateTime string `json:"create_time"` //创建时间
  125. ContentSub string `json:"content_sub"` //内容前两个章节"`
  126. VideoUrl string `json:"video_url"` //视频文件URL
  127. VideoCoverUrl string `json:"video_cover_url"` //视频文件封面地址
  128. VideoSeconds string `json:"video_seconds"` //视频时长
  129. ReportType int `json:"report_type"` //类型:0英文研报,1英文线上路演
  130. Stage int `json:"stage"` //期数
  131. ClassifyIdRoot int `json:"classify_id_root"` //顶级分类ID
  132. ClassifyNameRoot string `json:"classify_name_root"` //顶级分类名称
  133. }
  134. type ElasticEnglishReportDetail struct {
  135. Id string
  136. ReportId uint
  137. VideoId uint
  138. ClassifyIdFirst int
  139. ClassifyNameFirst string
  140. ClassifyIdSecond int
  141. ClassifyNameSecond string
  142. StageStr string
  143. Title string
  144. Abstract string
  145. Author string
  146. Frequency string
  147. PublishState int
  148. BodyContent string
  149. ContentSub string
  150. CreateTime string
  151. PublishTime string
  152. ReportCode string
  153. Overview string
  154. }
  155. func (r *Report) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*Report, err error) {
  156. results = make([]*Report, 0)
  157. query := global.DEFAULT_MYSQL.Model(r).
  158. Select("*").
  159. Where(condition, pars...)
  160. query.Count(&count)
  161. if len(page.GetOrderItemsString()) > 0 {
  162. query = query.Order(page.GetOrderItemsString())
  163. }
  164. err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error
  165. return
  166. }
  167. func (r *Report) GetEnglishReportByCode(reportCode string) (item *Report, err error) {
  168. err = global.MYSQL["rddp"].Model(r).Where("report_code= ?", reportCode).First(&item).Error
  169. return
  170. }
  171. // 修改
  172. func (r *Report) Update(updateCols []string) (err error) {
  173. err = global.DEFAULT_MYSQL.Model(r).Select(updateCols).Updates(r).Error
  174. return
  175. }
  176. func (r *Report) UpdatePvEmailByReportCode(reportCode string) (err error) {
  177. sql := `UPDATE english_report SET pv_email = pv_email+1 WHERE report_code = ? `
  178. err = global.DEFAULT_MYSQL.Exec(sql, reportCode).Error
  179. return
  180. }
  181. func (r *Report) GetUvEmailByReportIdAndEmailId(reportId, emailId int) (count int, err error) {
  182. sql := ` SELECT COUNT(*) AS count FROM english_report_email_pv WHERE report_id = ? AND email_id = ? `
  183. err = global.DEFAULT_MYSQL.Raw(sql, reportId, emailId).Scan(&count).Error
  184. return
  185. }
  186. func (r *Report) UpdateUvEmailByReportCode(reportCode string) (err error) {
  187. sql := `UPDATE english_report SET uv_email = uv_email+1 WHERE report_code = ? `
  188. err = global.DEFAULT_MYSQL.Exec(sql, reportCode).Error
  189. return
  190. }
  191. func (r *Report) UpdatePvByReportCode(reportCode string) (err error) {
  192. sql := `UPDATE english_report SET pv = pv+1 WHERE report_code = ? `
  193. err = global.DEFAULT_MYSQL.Exec(sql, reportCode).Error
  194. return
  195. }