english_report.go 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type EnglishReportDetail struct {
  8. Id int `orm:"column(id)" description:"报告Id"`
  9. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  10. ClassifyIdFirst int `description:"一级分类id"`
  11. ClassifyNameFirst string `description:"一级分类名称"`
  12. ClassifyIdSecond int `description:"二级分类id"`
  13. ClassifyNameSecond string `description:"二级分类名称"`
  14. Title string `description:"标题"`
  15. Abstract string `description:"摘要"`
  16. Author string `description:"作者"`
  17. Frequency string `description:"频度"`
  18. CreateTime string `description:"创建时间"`
  19. ModifyTime string `description:"修改时间"`
  20. State int `description:"1:未发布,2:已发布"`
  21. PublishTime string `description:"发布时间"`
  22. Stage int `description:"期数"`
  23. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  24. Content string `description:"内容"`
  25. VideoUrl string `description:"音频文件URL"`
  26. VideoName string `description:"音频文件名称"`
  27. VideoPlaySeconds string `description:"音频播放时长"`
  28. ContentSub string `description:"内容前两个章节"`
  29. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  30. HasChapter int `description:"是否有章节 0-否 1-是"`
  31. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  32. ReportCode string `description:"报告唯一编码"`
  33. Overview string `description:"英文概述部分"`
  34. }
  35. type EnglishClassify struct {
  36. Id int `orm:"column(id);pk"`
  37. ClassifyName string `description:"分类名称"`
  38. Sort int `description:"排序"`
  39. ParentId int `description:"父级分类id"`
  40. CreateTime time.Time `description:"创建时间"`
  41. ModifyTime time.Time `description:"修改时间"`
  42. ClassifyLabel string `description:"分类标签"`
  43. ShowType int `description:"展示类型:1-列表 2-专栏"`
  44. IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
  45. }
  46. type ElasticEnglishReportDetail struct {
  47. ReportId int `description:"报告id"`
  48. ClassifyIdFirst int `description:"一级分类id"`
  49. ClassifyNameFirst string `description:"一级分类名称"`
  50. ClassifyIdSecond int `description:"二级分类id"`
  51. ClassifyNameSecond string `description:"二级分类名称"`
  52. StageStr string `description:"报告期数"`
  53. Title string `description:"标题"`
  54. Abstract string `description:"摘要"`
  55. Author string `description:"作者"`
  56. Frequency string `description:"频度"`
  57. PublishState int `description:"状态:1:未发布,2:已发布"`
  58. BodyContent string `description:"内容"`
  59. ContentSub string `description:"前两段内容"`
  60. CreateTime string `description:"创建时间"`
  61. PublishTime string `description:"发布时间"`
  62. ReportCode string `description:"报告唯一编码"`
  63. Overview string `description:"英文概述部分"`
  64. }
  65. type SearchEnglishReportItem struct {
  66. Id int `description:"报告Id"`
  67. ClassifyIdFirst int `description:"一级分类id"`
  68. ClassifyNameFirst string `description:"一级分类名称"`
  69. ClassifyIdSecond int `description:"二级分类id"`
  70. ClassifyNameSecond string `description:"二级分类名称"`
  71. Title string `description:"标题"`
  72. Author string `description:"作者"`
  73. CreateTime string `description:"创建时间"`
  74. PublishTime string `description:"发布时间"`
  75. ContentSub string `description:"内容前两个章节"`
  76. ReportCode string `description:"报告唯一编码"`
  77. }
  78. type SearchEnglishReportResp struct {
  79. List []*SearchEnglishReportItem
  80. Paging *paging.PagingItem `description:"分页数据"`
  81. }
  82. func GetEnglishReportByCode(reportCode string) (item *EnglishReportDetail, err error) {
  83. o := orm.NewOrmUsingDB("rddp")
  84. sql := `SELECT * FROM english_report WHERE report_code=?`
  85. err = o.Raw(sql, reportCode).QueryRow(&item)
  86. return
  87. }
  88. type EnglishReportShareDetailResp struct {
  89. Report *EnglishReportDetail `description:"报告"`
  90. H5ShareEnName string `description:"研报分享抬头"`
  91. H5ReportShareImg string `description:"研报分享图片"`
  92. Hz int
  93. }
  94. func UpdateEnglishReportCounts(reportCode string) (err error) {
  95. o := orm.NewOrmUsingDB("rddp")
  96. sql := `UPDATE english_report SET pv = pv+1 WHERE report_code = ? `
  97. _, err = o.Raw(sql, reportCode).Exec()
  98. return
  99. }
  100. func UpdateEnglishReportEmailCounts(reportCode string) (err error) {
  101. o := orm.NewOrmUsingDB("rddp")
  102. sql := `UPDATE english_report SET pv_email = pv_email+1 WHERE report_code = ? `
  103. _, err = o.Raw(sql, reportCode).Exec()
  104. return
  105. }
  106. type EnglishClassifyList struct {
  107. Id int `description:"分类ID"`
  108. ClassifyName string `description:"分类名称"`
  109. Sort int `description:"排序"`
  110. ParentId int `description:"父级分类id"`
  111. CreateTime string `description:"创建时间"`
  112. ModifyTime string `description:"修改时间"`
  113. ClassifyLabel string `description:"分类标签"`
  114. ShowType int `description:"展示类型:1-列表 2-专栏"`
  115. IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
  116. Child []*EnglishClassify
  117. }
  118. type EnglishClassifyListResp struct {
  119. List []*EnglishClassifyList
  120. }
  121. // GetParentEnglishClassify 获取一级分类列表
  122. func GetParentEnglishClassify() (items []*EnglishClassify, err error) {
  123. sql := `SELECT * FROM english_classify WHERE parent_id=0 ORDER BY sort ASC,create_time ASC`
  124. o := orm.NewOrmUsingDB("rddp")
  125. _, err = o.Raw(sql).QueryRows(&items)
  126. return
  127. }
  128. // GetChildEnglishClassify 获取二级分类列表
  129. func GetChildEnglishClassify() (items []*EnglishClassify, err error) {
  130. sql := `SELECT * FROM english_classify WHERE parent_id>0 ORDER BY sort ASC,create_time ASC`
  131. o := orm.NewOrmUsingDB("rddp")
  132. _, err = o.Raw(sql).QueryRows(&items)
  133. return
  134. }
  135. func GetEnglishReportListCount(condition string, pars []interface{}) (count int, err error) {
  136. //产品权限
  137. oRddp := orm.NewOrmUsingDB("rddp")
  138. sql := `SELECT COUNT(1) AS count FROM english_report WHERE state=2 `
  139. if condition != "" {
  140. sql += condition
  141. }
  142. err = oRddp.Raw(sql, pars).QueryRow(&count)
  143. return
  144. }
  145. type EnglishReportList struct {
  146. Id int `description:"报告Id"`
  147. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  148. ClassifyIdFirst int `description:"一级分类id"`
  149. ClassifyNameFirst string `description:"一级分类名称"`
  150. ClassifyIdSecond int `description:"二级分类id"`
  151. ClassifyNameSecond string `description:"二级分类名称"`
  152. Title string `description:"标题"`
  153. Abstract string `description:"摘要"`
  154. Author string `description:"作者"`
  155. Frequency string `description:"频度"`
  156. CreateTime string `description:"创建时间"`
  157. ModifyTime string `description:"修改时间"`
  158. PublishTime string `description:"发布时间"`
  159. Stage int `description:"期数"`
  160. VideoUrl string `description:"音频文件URL"`
  161. VideoName string `description:"音频文件名称"`
  162. VideoPlaySeconds string `description:"音频播放时长"`
  163. ReportCode string `description:"报告唯一编码"`
  164. ShareUrl string `description:"分享url"`
  165. }
  166. type EnglishReportListResp struct {
  167. List []*EnglishReportList
  168. Paging *paging.PagingItem `description:"分页数据"`
  169. }
  170. func GetEnglishReportList(condition string, pars []interface{}, startSize, pageSize int) (items []*EnglishReportDetail, err error) {
  171. o := orm.NewOrmUsingDB("rddp")
  172. sql := `SELECT *
  173. FROM english_report WHERE state=2 `
  174. if condition != "" {
  175. sql += condition
  176. }
  177. sql += `ORDER BY publish_time DESC, id DESC LIMIT ?,?`
  178. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  179. return
  180. }
  181. func GetTrialEnglishReportByCode(reportCode string) (item *EnglishReportDetail, err error) {
  182. o := orm.NewOrmUsingDB("rddp_trial")
  183. sql := `SELECT * FROM english_report WHERE report_code=?`
  184. err = o.Raw(sql, reportCode).QueryRow(&item)
  185. return
  186. }
  187. func UpdateTrialEnglishReportCounts(reportCode string) (err error) {
  188. o := orm.NewOrmUsingDB("rddp_trial")
  189. sql := `UPDATE english_report SET pv = pv+1 WHERE report_code = ? `
  190. _, err = o.Raw(sql, reportCode).Exec()
  191. return
  192. }
  193. func UpdateTrialEnglishReportEmailCounts(reportCode string) (err error) {
  194. o := orm.NewOrmUsingDB("rddp_trial")
  195. sql := `UPDATE english_report SET pv_email = pv_email+1 WHERE report_code = ? `
  196. _, err = o.Raw(sql, reportCode).Exec()
  197. return
  198. }