report.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. }