cygx_morning_meeting_reviews.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // CygxMorningMeetingReviews [...]
  8. type CygxMorningMeetingReviews struct {
  9. Id int `orm:"column(id);pk"`
  10. MeetingTime time.Time `json:"meetingTime"` // 晨会日期
  11. PublishTime time.Time `json:"publishTime"` // 发布日期
  12. CreateTime time.Time `json:"createTime"`
  13. ModifyTime time.Time `json:"modifyTime"`
  14. Status int `json:"status"` // 0:未发布,1:已发布
  15. PartNums int `json:"partNums"` // 段落数
  16. IndustryNames string `json:"industryName"` // 产业名称
  17. }
  18. //添加晨报点评
  19. func AddCygxMorningMeetingReviews(item *CygxMorningMeetingReviews) (id int64, err error) {
  20. o := orm.NewOrm()
  21. id, err = o.Insert(item)
  22. return
  23. }
  24. //列表
  25. func GetCygxMorningMeetingReviewsList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxMorningMeetingReviews, err error) {
  26. o := orm.NewOrm()
  27. sql := `SELECT * FROM cygx_morning_meeting_reviews WHERE 1=1 `
  28. if condition != "" {
  29. sql += condition
  30. }
  31. sql += ` LIMIT ?,? `
  32. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  33. return
  34. }
  35. func GetCygxMorningMeetingReviewsListCount(condition string, pars []interface{}) (count int, err error) {
  36. o := orm.NewOrm()
  37. sql := `SELECT COUNT(1) AS count FROM cygx_morning_meeting_reviews WHERE 1=1 `
  38. if condition != "" {
  39. sql += condition
  40. }
  41. err = o.Raw(sql, pars).QueryRow(&count)
  42. return
  43. }
  44. type CygxMorningMeetingReviewItem struct {
  45. Id int `orm:"column(id);pk"`
  46. MeetingTime string `json:"meetingTime"` // 晨会日期
  47. PublishTime string `json:"publishTime"` // 发布日期
  48. CreateTime string `json:"createTime"`
  49. ModifyTime string `json:"modifyTime"`
  50. Status int `json:"status"` // 0:未发布,1:已发布
  51. PartNums int `json:"partNums"` // 段落数
  52. IndustryNames string `json:"industryName"` // 产业名称
  53. }
  54. type CygxMorningMeetingReviewsList struct {
  55. List []*CygxMorningMeetingReviewItem
  56. Paging *paging.PagingItem `description:"分页数据"`
  57. }
  58. func GetMorningMeetingReviewById(reviewId int) (item *CygxMorningMeetingReviews, err error) {
  59. o := orm.NewOrm()
  60. sql := `SELECT * FROM cygx_morning_meeting_reviews WHERE id=?`
  61. err = o.Raw(sql, reviewId).QueryRow(&item)
  62. return
  63. }
  64. // 发布报告
  65. func PublishMorningMeetingReviewById(reviewId int) (err error) {
  66. o := orm.NewOrm()
  67. sql := `UPDATE cygx_morning_meeting_reviews SET status=1,publish_time=now(),modify_time=NOW() WHERE id = ? `
  68. _, err = o.Raw(sql, reviewId).Exec()
  69. return
  70. }
  71. type MorningReviewPublishReq struct {
  72. ReviewIds string `description:"晨会id,多个用英文逗号隔开"`
  73. }
  74. type MorningReviewPublishCancelReq struct {
  75. ReviewId int `description:"晨会id"`
  76. }
  77. //取消发布报告
  78. func PublishCancelMorningMeetingReview(reviewId int) (err error) {
  79. o := orm.NewOrm()
  80. sql := ` UPDATE cygx_morning_meeting_reviews SET status=0,publish_time=null WHERE id =? `
  81. _, err = o.Raw(sql, reviewId).Exec()
  82. return
  83. }
  84. type MorningReviewDeleteReq struct {
  85. ReviewId int `description:"晨会id"`
  86. }
  87. //删除晨会点评
  88. func DeleteMorningMeeting(reviewId int) (err error) {
  89. o := orm.NewOrm()
  90. sql := ` DELETE FROM cygx_morning_meeting_reviews WHERE id =? `
  91. _, err = o.Raw(sql, reviewId).Exec()
  92. return
  93. }
  94. //更新晨报点评
  95. func UpdateCygxMorningMeetingReviews(item *CygxMorningMeetingReviews) (err error) {
  96. o := orm.NewOrm()
  97. sql := `UPDATE cygx_morning_meeting_reviews
  98. SET
  99. meeting_time =?,
  100. publish_time = ?,
  101. modify_time = ?,
  102. part_nums = ?,
  103. industry_names = ?,
  104. status = ?
  105. WHERE id = ? `
  106. _, err = o.Raw(sql, item.MeetingTime, item.PublishTime, item.ModifyTime, item.PartNums, item.IndustryNames, item.Status, item.Id).Exec()
  107. return
  108. }