product_interior.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 CygxProductInterior struct {
  8. ProductInteriorId int `orm:"column(product_interior_id);pk"`
  9. ColumnName string `description:"栏目名称"`
  10. Title string `description:"标题"`
  11. PublishTime time.Time `description:"发布日期"`
  12. CreateTime time.Time `description:"创建时间"`
  13. ModifyTime time.Time `description:"更新时间"`
  14. Status int `description:"0:未发布,1:已发布"`
  15. Body string `description:"内容"`
  16. IsCancel int `description:"是否取消,1是,0否"`
  17. VisibleRange int `description:"设置可见范围1全部,0内部"`
  18. Abstract string `description:"摘要"`
  19. Department string `description:"作者"`
  20. AdminId int `description:"管理员ID"`
  21. }
  22. type AddProductInteriorReq struct {
  23. ProductInteriorId int `description:"ID"`
  24. DoType int `description:"操作类型 0,保存 、1,发布"`
  25. ColumnName string `description:"栏目名称"`
  26. Title string `description:"标题"`
  27. Abstract string `description:"摘要"`
  28. Department string `description:"作者"`
  29. Body string `description:"内容"`
  30. PublishTime string `description:"发布日期"`
  31. }
  32. type ProductInteriorIdReq struct {
  33. ProductInteriorId int `description:"ID"`
  34. }
  35. type GetCygxProductInteriorResp struct {
  36. Paging *paging.PagingItem `description:"分页数据"`
  37. List []*CygxProductInteriorResp
  38. }
  39. type CygxProductInteriorResp struct {
  40. ProductInteriorId int `description:"ID"`
  41. PublishTime string `description:"发布日期"`
  42. CreateTime string `description:"创建时间"`
  43. ModifyTime string `description:"更新时间"`
  44. Title string `description:"标题"`
  45. ColumnName string `description:"栏目名称"`
  46. Body string `description:"内容"`
  47. BodySlice []*ProductInteriorUrlResp `description:"内容切片"`
  48. IsCancel int `description:"是否取消,1是,0否"`
  49. VisibleRange int `description:"设置可见范围1全部,0内部"`
  50. Abstract string `description:"摘要"`
  51. Department string `description:"作者"`
  52. Pv int `description:"PV"`
  53. }
  54. type ProductInteriorUrlResp struct {
  55. ChartPermissionId int `description:"行业id"`
  56. SourceId int `description:"资源ID"`
  57. Type int `description:"类型:1普通文本,2:文章、3:活动、4:产业"`
  58. Body string `description:"内容"`
  59. ActivityVideo *CygxActivityVideoReq //活动视频
  60. AuthInfo *UserPermissionAuthInfo // 权限
  61. }
  62. // 获取数量
  63. func GetCygxProductInteriorCount(condition string, pars []interface{}) (count int, err error) {
  64. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_product_interior as art WHERE 1= 1 `
  65. if condition != "" {
  66. sqlCount += condition
  67. }
  68. o := orm.NewOrm()
  69. err = o.Raw(sqlCount, pars).QueryRow(&count)
  70. return
  71. }
  72. // 列表
  73. func GetCygxProductInteriorList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxProductInteriorResp, err error) {
  74. o := orm.NewOrm()
  75. sql := `SELECT * FROM cygx_product_interior as art WHERE 1= 1 `
  76. if condition != "" {
  77. sql += condition
  78. }
  79. sql += ` LIMIT ?,? `
  80. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  81. return
  82. }
  83. type GetCygxProductInteriorDetailResp struct {
  84. Detail *CygxProductInteriorResp
  85. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  86. IsShow bool `description:"是否展示"`
  87. Disclaimers string `description:"免责声明"`
  88. }
  89. // 通过ID获取详情
  90. func GetCygxProductInteriorDetail(productInteriorId int) (item *CygxProductInteriorResp, err error) {
  91. o := orm.NewOrm()
  92. sql := `SELECT * FROM cygx_product_interior WHERE product_interior_id=? AND status = 1 `
  93. err = o.Raw(sql, productInteriorId).QueryRow(&item)
  94. return
  95. }
  96. // 删除数据
  97. func DeleteProductInterior(productInteriorId int) (err error) {
  98. o := orm.NewOrm()
  99. sql := ` DELETE FROM cygx_product_interior WHERE product_interior_id = ?`
  100. _, err = o.Raw(sql, productInteriorId).Exec()
  101. return
  102. }
  103. // 修改是否展示
  104. func EditProductInteriorStatus(status, isCancel, productInteriorId int) (err error) {
  105. o := orm.NewOrm()
  106. sql := `UPDATE cygx_product_interior SET status=?,is_cancel = ? , modify_time=NOW() WHERE product_interior_id=? `
  107. _, err = o.Raw(sql, status, isCancel, productInteriorId).Exec()
  108. return
  109. }
  110. // 修改可见范围
  111. func ProductInteriorVisibleRange(visibleRange, productInteriorId int) (err error) {
  112. o := orm.NewOrm()
  113. sql := `UPDATE cygx_product_interior SET visible_range=?, modify_time=NOW() WHERE product_interior_id=? `
  114. _, err = o.Raw(sql, visibleRange, productInteriorId).Exec()
  115. return
  116. }