tactics_time_line.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 CygxTacticsTimeLine 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 AddTacticsTimeLineReq 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 TacticsTimeLineTimeLineIdReq struct {
  26. TimeLineId int `description:"ID"`
  27. }
  28. type GetCygxTacticsTimeLineResp struct {
  29. Paging *paging.PagingItem `description:"分页数据"`
  30. List []*CygxTacticsTimeLineResp
  31. }
  32. type CygxTacticsTimeLineResp struct {
  33. TimeLineId int `description:"ID"`
  34. PublishTime string `description:"发布日期"`
  35. Status int `description:"0:未发布,1:已发布"`
  36. Content string `description:"内容"`
  37. ArticleId int `description:"文章ID"`
  38. ChartId int `description:"图表ID"`
  39. Link string `description:"文章或图表链接"`
  40. }
  41. // 获取数量
  42. func GetCygxTacticsTimeLineCount(condition string, pars []interface{}) (count int, err error) {
  43. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_tactics_time_line as art WHERE 1= 1 `
  44. if condition != "" {
  45. sqlCount += condition
  46. }
  47. o := orm.NewOrm()
  48. err = o.Raw(sqlCount, pars).QueryRow(&count)
  49. return
  50. }
  51. // 列表
  52. func GetCygxTacticsTimeLineList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxTacticsTimeLineResp, err error) {
  53. o := orm.NewOrm()
  54. sql := `SELECT * FROM cygx_tactics_time_line as art WHERE 1= 1 `
  55. if condition != "" {
  56. sql += condition
  57. }
  58. sql += ` LIMIT ?,? `
  59. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  60. return
  61. }
  62. type GetCygxTacticsTimeLineDetailResp struct {
  63. Detail *CygxTacticsTimeLineResp
  64. }
  65. // 通过ID获取详情
  66. func GetCygxTacticsTimeLineDetail(timeLineId int) (item *CygxTacticsTimeLineResp, err error) {
  67. o := orm.NewOrm()
  68. sql := `SELECT * FROM cygx_tactics_time_line WHERE time_line_id=? `
  69. err = o.Raw(sql, timeLineId).QueryRow(&item)
  70. return
  71. }