api_w_random.go 493 B

12345678910111213141516171819202122
  1. package route
  2. import (
  3. "opennamu/route/tool"
  4. )
  5. func Api_w_random(config tool.Config) map[string]string {
  6. db := tool.DB_connect()
  7. defer tool.DB_close(db)
  8. title := "Test"
  9. tool.QueryRow_DB(
  10. db,
  11. "select title from data where title not like 'user:%' and title not like 'category:%' and title not like 'file:%' order by random() limit 1",
  12. []any{ &title },
  13. )
  14. new_data := map[string]string{}
  15. new_data["data"] = title
  16. return new_data
  17. }