report.go 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package models
  2. import "rdluck_tools/orm"
  3. type Report struct {
  4. Id int
  5. Content string
  6. ContentSub string
  7. }
  8. func GetReport() (items []*Report, err error) {
  9. sql := `SELECT * FROM report ORDER BY id ASC `
  10. o := orm.NewOrm()
  11. o.Using("rddp")
  12. _, err = o.Raw(sql).QueryRows(&items)
  13. return
  14. }
  15. func ModifyReportContentSub(id int, contentSub string) (err error) {
  16. sql := `UPDATE report SET content_sub=? WHERE id=? `
  17. o := orm.NewOrm()
  18. o.Using("rddp")
  19. _, err = o.Raw(sql, contentSub, id).Exec()
  20. return
  21. }
  22. func GetReportLimit() (items []*Report, err error) {
  23. sql := `SELECT * FROM report WHERE state=2 ORDER BY id DESC LIMIT 50 `
  24. o := orm.NewOrm()
  25. o.Using("rddp")
  26. _, err = o.Raw(sql).QueryRows(&items)
  27. return
  28. }
  29. func EditReportContent(reportId int, content, contentSub string) (err error) {
  30. o := orm.NewOrm()
  31. o.Using("rddp")
  32. sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  33. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  34. return
  35. }