comment.go 1.0 KB

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. )
  5. //AddComment add comment for performance test task
  6. func (d *Dao) AddComment(comment *model.Comment) error {
  7. //comment.Status = 1
  8. return d.DB.Table(model.Comment{}.TableName()).Create(comment).Error
  9. }
  10. //QueryComment query comment
  11. func (d *Dao) QueryComment(comment *model.Comment) (res *model.QueryCommentResponse, err error) {
  12. res = &model.QueryCommentResponse{}
  13. //comment.Status = 1
  14. err = d.DB.Table(model.Comment{}.TableName()).Where(comment).Count(&res.Total).Order("id desc").Find(&res.Comments).Error
  15. return
  16. }
  17. //UpdateComment update comment
  18. func (d *Dao) UpdateComment(comment *model.Comment) error {
  19. //return d.DB.Table(model.Comment{}.TableName()).Update(comment).Where("ID=?", comment.ID).Error
  20. return d.DB.Model(&model.Comment{}).Update(comment).Where("ID=?", comment.ID).Error
  21. }
  22. //DeleteComment delete comment
  23. func (d *Dao) DeleteComment(id int64) error {
  24. return d.DB.Model(&model.Comment{}).Where("ID=?", id).Update("status", 2).Error
  25. }