cygx_yanxuan_special_message.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_web_mfyx/utils"
  6. "time"
  7. )
  8. type CygxYanxuanSpecialMessage struct {
  9. MessageId int `orm:"column(message_id);pk"`
  10. UserId int `comment:"用户ID"`
  11. Mobile string `comment:"手机号"`
  12. Email string `comment:"邮箱"`
  13. CompanyId int `comment:"公司ID"`
  14. CompanyName string `comment:"公司名称"`
  15. RealName string `comment:"用户实际名称"`
  16. SellerName string `comment:"所属销售"`
  17. RegisterPlatform int `comment:"来源 1小程序,2:网页,5买方研选小程序,6:买方研选网页版"`
  18. YanxuanSpecialId int `comment:"cygx_yanxuan_special 表主键ID"`
  19. Content string `comment:"留言内容"`
  20. PublicTime time.Time `comment:"公开时间"`
  21. Status int `comment:"消息状态,0未公开、1:已公开"`
  22. TopTime int `comment:"置顶时间"`
  23. LikeCount int `comment:"点赞数量"`
  24. ParentId int `comment:"父级ID"`
  25. YanxuanSpecialUserId int `comment:"研选专栏作者对应的用户ID"`
  26. SourceTitle string `comment:"标题"`
  27. CreateTime time.Time `comment:"创建时间"`
  28. ModifyTime time.Time `comment:"修改时间"`
  29. }
  30. type AddCygxYanxuanSpecialMessageReq struct {
  31. YanxuanSpecialId int `comment:"cygx_yanxuan_special 表主键ID"`
  32. Content string `comment:"留言内容"`
  33. ParentId int `comment:"父级ID"`
  34. }
  35. type DeleteCygxYanxuanSpecialMessageReq struct {
  36. MessageId int `comment:"留言消息ID"`
  37. }
  38. type PubliceCygxYanxuanSpecialMessageReq struct {
  39. MessageIds []int `comment:"留言消息ID"`
  40. DoType int `comment:"0取消置顶,1置顶"`
  41. }
  42. type TopCygxYanxuanSpecialMessageReq struct {
  43. MessageId int `comment:"留言消息ID"`
  44. DoType int `comment:"0取消置顶,1置顶"`
  45. }
  46. // 新增
  47. func AddCygxYanxuanSpecialMessage(item *CygxYanxuanSpecialMessage) (err error) {
  48. o := orm.NewOrm()
  49. _, err = o.Insert(item)
  50. return
  51. }
  52. // 删除
  53. func DeleteCygxYanxuanSpecialMessage(messageId int) (err error) {
  54. o := orm.NewOrm()
  55. sql := `DELETE FROM cygx_yanxuan_special_message WHERE message_id = ? `
  56. _, err = o.Raw(sql, messageId).Exec()
  57. return
  58. }
  59. // 更新置顶时间
  60. func UpdateCygxYanxuanSpecialMessageTopTime(topTime, messageId int) (err error) {
  61. o := orm.NewOrm()
  62. sql := ``
  63. sql = `UPDATE cygx_yanxuan_special_message SET top_time = ? WHERE message_id = ? `
  64. _, err = o.Raw(sql, topTime, messageId).Exec()
  65. return
  66. }
  67. // 更新是否公开
  68. func UpdateCygxYanxuanSpecialMessageStatus(status int, publicTime string, messageIds []int) (err error) {
  69. o := orm.NewOrm()
  70. sql := ``
  71. sql = `UPDATE cygx_yanxuan_special_message SET status = ? ,public_time = ? WHERE message_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `) OR parent_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `) `
  72. _, err = o.Raw(sql, status, publicTime, messageIds, messageIds).Exec()
  73. return
  74. }
  75. func GetCygxYanxuanSpecialMessageList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialMessage, err error) {
  76. o := orm.NewOrm()
  77. sql := `SELECT *
  78. FROM
  79. cygx_yanxuan_special_message
  80. WHERE 1 = 1 ` + condition
  81. sql += ` LIMIT ?,? `
  82. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  83. return
  84. }
  85. // 根据id获取详情
  86. func GetCygxYanxuanSpecialMessagerDetailById(messageId int) (item *CygxYanxuanSpecialMessage, err error) {
  87. o := orm.NewOrm()
  88. sql := `SELECT * FROM cygx_yanxuan_special_message WHERE message_id = ? `
  89. err = o.Raw(sql, messageId).QueryRow(&item)
  90. return
  91. }
  92. // 获取数量
  93. func GetCygxYanxuanSpecialMessagerCount(condition string, pars []interface{}) (count int, err error) {
  94. o := orm.NewOrm()
  95. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_message WHERE 1= 1 ` + condition
  96. err = o.Raw(sqlCount, pars).QueryRow(&count)
  97. return
  98. }
  99. type CygxYanxuanSpecialMessageManageResp struct {
  100. MessageId int `comment:"留言消息ID"`
  101. RealName string `comment:"用户实际名称"`
  102. Headimgurl string `comment:"用户头像"`
  103. YanxuanSpecialId int `comment:"研选专栏文章ID"`
  104. Content string `comment:"留言内容"`
  105. Status int `comment:"消息状态,0未公开、1:已公开"`
  106. TopTime int `comment:"置顶时间(大于零置顶,等于零未置顶)"`
  107. HaveOtherTop bool `comment:"是否有其它的置顶"`
  108. SourceTitle string `comment:"专栏标题"`
  109. CreateTime string `comment:"创建时间"`
  110. LikeCount int `comment:"点赞数量"`
  111. IsLikeCount bool `comment:"是否点赞"`
  112. IsMySelf bool `comment:"是否属于本人留言"`
  113. CheckIds []int `comment:"空数组前端渲染使用"`
  114. ChildList []*CygxYanxuanSpecialMessageManageChildResp // 留言子集
  115. }
  116. type CygxYanxuanSpecialMessageManageChildResp struct {
  117. MessageId int `comment:"留言消息ID"`
  118. Content string `comment:"留言内容"`
  119. Headimgurl string `comment:"用户头像"`
  120. LikeCount int `comment:"点赞数量"`
  121. IsLikeCount bool `comment:"是否点赞"`
  122. CreateTime string `comment:"创建时间"`
  123. }
  124. type YanxuanSpecialMessageManageRespListResp struct {
  125. Paging *paging.PagingItem `description:"分页数据"`
  126. List []*CygxYanxuanSpecialMessageManageResp
  127. }