xorm_test.go 968 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. "fmt"
  4. _ "github.com/go-sql-driver/mysql"
  5. "github.com/xormplus/xorm"
  6. "testing"
  7. )
  8. func TestRflect(t *testing.T) {
  9. db, err := xorm.NewEngine("mysql", "root:gSRGZqb121TlYIbJy0@tcp(47.103.202.94:3306)/i2bill?charset=utf8&loc=Local&parseTime=true")
  10. if err != nil {
  11. panic(err)
  12. }
  13. db.RegisterSqlMap(xorm.Xml("sqlconfig", ".xml"))
  14. db.RegisterSqlTemplate(xorm.Pongo2("sqlconfig", ".stpl"))
  15. db.RegisterSqlTemplate(xorm.Jet("sqlconfig", ".jet"))
  16. db.RegisterSqlTemplate(xorm.Default("../i2-bill-openapi/internal/sql", ".tpl"))
  17. db.StartFSWatcher()
  18. db.ShowSQL(true)
  19. stplkey := fmt.Sprintf("i2bill_acquirer_attendance_record_page_select.tpl")
  20. paramMap_i_t := map[string]interface{}{
  21. "page": 1,
  22. "rows": 10,
  23. "date_sta": "",
  24. "date_end": "",
  25. "user_id": 3,
  26. "all": false,
  27. }
  28. result, err := db.SqlTemplateClient(stplkey, &paramMap_i_t).Query().List()
  29. if err != nil {
  30. fmt.Println(err)
  31. return
  32. }
  33. fmt.Println(result)
  34. }