logic_test.go 989 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package logic
  2. import (
  3. "database/sql"
  4. "fmt"
  5. "git.i2edu.net/i2/i2-bill-api/internal/logic/auth"
  6. "git.i2edu.net/i2/i2-bill-api/internal/utils"
  7. "testing"
  8. "time"
  9. )
  10. func TestCreateJWT(t *testing.T) {
  11. l := new(auth.LoginByWeixinLogic)
  12. payloads := map[string]interface{}{
  13. "userId": 35,
  14. "sessionKey": "sessionKey",
  15. }
  16. fmt.Println(l.CreateJWT(1626837985, "6hy789iu87", payloads, 604800))
  17. }
  18. func TestRflect(t *testing.T) {
  19. type Ref struct {
  20. CreateTime sql.NullTime `db:"create_time"`
  21. Id int64 `db:"id"`
  22. StartTime time.Time `db:"start_time"`
  23. StartAdress string `db:"start_adress"`
  24. }
  25. var T = Ref{CreateTime: sql.NullTime{time.Now(), false}, Id: 100, StartAdress: "地址", StartTime: time.Now().AddDate(1, 0, 0)}
  26. var ts []Ref
  27. ts = append(ts, T)
  28. row := utils.UnmarshalMysqlRows(ts)
  29. fmt.Println(row)
  30. }
  31. func TestTime(t *testing.T) {
  32. ts, _ := time.Parse("2006-01-02 15:04:05", "1970-01-01 00:00:00")
  33. fmt.Println(ts.Unix(), time.Now())
  34. }