gushou_time_line.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package time_line
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type CygxGushouTimeLine struct {
  8. TimeLineId int `orm:"column(time_line_id);pk"`
  9. PublishTime time.Time `description:"发布日期"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ModifyTime time.Time `description:"更新时间"`
  12. Status int `description:"0:未发布,1:已发布"`
  13. Content string `description:"内容"`
  14. ArticleId int `description:"文章ID"`
  15. ChartId int `description:"图表ID"`
  16. Link string `description:"文章或图表链接"`
  17. AdminId int `description:"管理员ID"`
  18. }
  19. type AddGushouTimeLineReq struct {
  20. TimeLineId int `orm:"column(time_line_id);pk"`
  21. PublishTime string `description:"发布日期"`
  22. Content string `description:"内容"`
  23. Link string `description:"文章或图表链接"`
  24. }
  25. type GushouTimeLineTimeLineIdReq struct {
  26. TimeLineId int `description:"ID"`
  27. }
  28. type GetCygxGushouTimeLineResp struct {
  29. Status int `description:"0:内部可见,1:全部可见"`
  30. Paging *paging.PagingItem `description:"分页数据"`
  31. List []*CygxGushouTimeLineResp
  32. }
  33. type CygxGushouTimeLineResp struct {
  34. TimeLineId int `description:"ID"`
  35. PublishTime string `description:"发布日期"`
  36. Status int `description:"0:未发布,1:已发布"`
  37. Content string `description:"内容"`
  38. ArticleId int `description:"文章ID"`
  39. ChartId int `description:"图表ID"`
  40. Link string `description:"文章或图表链接"`
  41. Resource int `description:"来源类型,1:文章、2:产品内测、3:晨报点评"`
  42. ChartPermissionName string `description:"行业名称"`
  43. }
  44. // 获取数量
  45. func GetCygxGushouTimeLineCount(condition string, pars []interface{}) (count int, err error) {
  46. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_gushou_time_line as art WHERE 1= 1 `
  47. if condition != "" {
  48. sqlCount += condition
  49. }
  50. o := orm.NewOrm()
  51. err = o.Raw(sqlCount, pars).QueryRow(&count)
  52. return
  53. }
  54. // 列表
  55. func GetCygxGushouTimeLineList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxGushouTimeLineResp, err error) {
  56. o := orm.NewOrm()
  57. sql := `SELECT * FROM cygx_gushou_time_line as art WHERE 1= 1 `
  58. if condition != "" {
  59. sql += condition
  60. }
  61. sql += ` LIMIT ?,? `
  62. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  63. return
  64. }
  65. type GetCygxGushouTimeLineDetailResp struct {
  66. Detail *CygxGushouTimeLineResp
  67. }
  68. // 通过ID获取详情
  69. func GetCygxGushouTimeLineDetail(timeLineId int) (item *CygxGushouTimeLineResp, err error) {
  70. o := orm.NewOrm()
  71. sql := `SELECT * FROM cygx_gushou_time_line WHERE time_line_id=? `
  72. err = o.Raw(sql, timeLineId).QueryRow(&item)
  73. return
  74. }