report_send_ths_config.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // ReportSendThsConfig 产品推送给同花顺的配置的表结构体
  8. type ReportSendThsConfig struct {
  9. ConfigId int `orm:"column(config_id);pk" description:"配置Id"`
  10. ConfigType string `description:"产品类型:研报、视频社区、线上路演"`
  11. ClassifyId int `description:"分类id(该产品类型对应的所属分类id)"`
  12. ClassifyName string `description:"分类名称(该产品类型对应的所属分类名称)"`
  13. Level int `description:"等级,1:紧急,2:优先,3:普通"`
  14. Time int `description:"间隔时间,单位:分"`
  15. SysUserId int `description:"操作人用户id"`
  16. SysRealName string `description:"操作人用户名称"`
  17. ModifyTime time.Time `description:"最近修改时间"`
  18. CreateTime time.Time `description:"创建时间"`
  19. }
  20. // Update 更新产品推送给同花顺的配置
  21. func (item *ReportSendThsConfig) Update(cols []string) (err error) {
  22. o := orm.NewOrm()
  23. _, err = o.Update(item, cols...)
  24. return
  25. }
  26. // GetReportSendThsConfigByConfigId 根据配置id获取对应的配置信息
  27. func GetReportSendThsConfigByConfigId(configId int) (item *ReportSendThsConfig, err error) {
  28. o := orm.NewOrm()
  29. sql := ` SELECT * FROM report_send_ths_config WHERE config_id=? order by config_id desc`
  30. err = o.Raw(sql, configId).QueryRow(&item)
  31. return
  32. }
  33. type ReportSendThsConfigListResp struct {
  34. Paging *paging.PagingItem
  35. List []*ReportSendThsConfigListItem
  36. }
  37. type ReportSendThsConfigListItem struct {
  38. ConfigId int `orm:"column(config_id);pk" description:"配置Id"`
  39. ConfigType string `description:"产品类型:研报、视频社区、线上路演"`
  40. ClassifyId int `description:"分类id(该产品类型对应的所属分类id)"`
  41. ClassifyName string `description:"分类名称(该产品类型对应的所属分类名称)"`
  42. Level int `description:"等级,1:紧急,2:优先,3:普通"`
  43. ModifyTime string `description:"最近修改时间"`
  44. CreateTime string `description:"创建时间"`
  45. }
  46. // AddReportSendThsConfig 新增产品推送给同花顺的配置的记录
  47. func AddReportSendThsConfig(item *ReportSendThsConfig) (err error) {
  48. o := orm.NewOrm()
  49. lastId, err := o.Insert(item)
  50. if err == nil {
  51. item.ConfigId = int(lastId)
  52. }
  53. return
  54. }
  55. // GetReportSendThsConfigByClassifyId 根据分类id获取对应的配置信息
  56. func GetReportSendThsConfigByClassifyId(configType string, classifyId int) (item *ReportSendThsConfig, err error) {
  57. o := orm.NewOrm()
  58. sql := ` SELECT * FROM report_send_ths_config WHERE classify_id=? AND config_type=? order by config_id desc`
  59. err = o.Raw(sql, classifyId, configType).QueryRow(&item)
  60. return
  61. }
  62. // GetCountReportSendThsConfigByClassifyId 根据分类id查询是否添加对应的配置
  63. func GetCountReportSendThsConfigByClassifyId(configType string, classifyId int) (total int, err error) {
  64. o := orm.NewOrm()
  65. sql := ` SELECT count(1) total FROM report_send_ths_config WHERE classify_id=? AND config_type=? `
  66. err = o.Raw(sql, classifyId, configType).QueryRow(&total)
  67. return
  68. }
  69. // GetReportSendThsConfigList 获取同花顺推送配置列表
  70. func GetReportSendThsConfigList(condition string, pars []interface{}, startSize, pageSize int, orderBy string) (items []*ReportSendThsConfig, err error) {
  71. o := orm.NewOrm()
  72. sql := `SELECT * FROM report_send_ths_config WHERE 1 = 1 `
  73. if condition != "" {
  74. sql += condition
  75. }
  76. sql += ` ORDER BY ` + orderBy
  77. sql += ` limit ?,? `
  78. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  79. return
  80. }
  81. // GetReportSendThsConfigCount 获取同花顺推送配置数量
  82. func GetReportSendThsConfigCount(condition string, pars []interface{}) (count int64, err error) {
  83. o := orm.NewOrm()
  84. sql := `SELECT COUNT(1) AS count FROM report_send_ths_config WHERE 1 = 1 `
  85. if condition != "" {
  86. sql += condition
  87. }
  88. err = o.Raw(sql, pars).QueryRow(&count)
  89. return
  90. }
  91. // DeleteReportSendThsConfigByConfigId 删除配置id获取对应的配置信息
  92. func DeleteReportSendThsConfigByConfigId(configId int) (err error) {
  93. o := orm.NewOrm()
  94. sql := ` DELETE from report_send_ths_config WHERE config_id=? `
  95. _, err = o.Raw(sql, configId).Exec()
  96. return
  97. }