report.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package models
  2. import (
  3. "fmt"
  4. "hongze/hongze_task/utils"
  5. "rdluck_tools/orm"
  6. "time"
  7. )
  8. type Report struct {
  9. Id int
  10. Content string
  11. ContentSub string
  12. }
  13. func GetReport() (items []*Report, err error) {
  14. sql := `SELECT * FROM report ORDER BY id ASC `
  15. o := orm.NewOrm()
  16. o.Using("rddp")
  17. _, err = o.Raw(sql).QueryRows(&items)
  18. return
  19. }
  20. func ModifyReportContentSub(id int, contentSub string) (err error) {
  21. sql := `UPDATE report SET content_sub=? WHERE id=? `
  22. o := orm.NewOrm()
  23. o.Using("rddp")
  24. _, err = o.Raw(sql, contentSub, id).Exec()
  25. return
  26. }
  27. func GetReportLimit() (items []*Report, err error) {
  28. sql := `SELECT * FROM report WHERE state=2 ORDER BY id DESC LIMIT 50 `
  29. o := orm.NewOrm()
  30. o.Using("rddp")
  31. _, err = o.Raw(sql).QueryRows(&items)
  32. return
  33. }
  34. func EditReportContent(reportId int, content, contentSub string) (err error) {
  35. o := orm.NewOrm()
  36. o.Using("rddp")
  37. sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  38. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  39. return
  40. }
  41. //删除报告日志记录-保留3个月
  42. func DeleteReportSaveLog() {
  43. startDateTime:=time.Now().AddDate(0,-3,0).Format(utils.FormatDateTime)
  44. fmt.Println(startDateTime)
  45. }
  46. func EditReportContentHtml(reportId int, content string) (err error) {
  47. o := orm.NewOrm()
  48. o.Using("rddp")
  49. sql := ` UPDATE report SET content=?,modify_time=NOW() WHERE id=? `
  50. _, err = o.Raw(sql, content, reportId).Exec()
  51. return
  52. }