1
0

binding_test.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package api
  2. import (
  3. "fmt"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. type Pagination struct {
  8. PageIndex int `form:"pageIndex"`
  9. PageSize int `form:"pageSize"`
  10. }
  11. type SysUserSearch struct {
  12. Pagination `search:"-"`
  13. UserId int `form:"userId" search:"type:exact;column:id;table:sys_user" comment:"用户ID"`
  14. Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
  15. NickName string `form:"nickName" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
  16. Phone string `form:"phone" search:"type:contains;column:phone;table:sys_user" comment:"手机号"`
  17. RoleId string `form:"roleId" search:"type:exact;column:role_id;table:sys_user" comment:"角色ID"`
  18. Sex string `form:"sex" search:"type:exact;column:sex;table:sys_user" comment:"性别"`
  19. Email string `form:"email" search:"type:contains;column:email;table:sys_user" comment:"邮箱"`
  20. OrganId string `form:"organId" search:"type:exact;column:organ_id;table:sys_user" comment:"机构"`
  21. PostId string `form:"postId" search:"type:exact;column:post_id;table:sys_user" comment:"岗位"`
  22. Status string `form:"status" search:"type:exact;column:status;table:sys_user" comment:"状态"`
  23. SysUserOrder
  24. }
  25. type SysUserOrder struct {
  26. UserIdOrder string `search:"type:order;column:id;table:sys_user" form:"userIdOrder"`
  27. UsernameOrder string `search:"type:order;column:username;table:sys_user" form:"usernameOrder"`
  28. StatusOrder string `search:"type:order;column:status;table:sys_user" form:"statusOrder"`
  29. CreatedAtOrder string `search:"type:order;column:created_at;table:sys_user" form:"createdAtOrder"`
  30. }
  31. func TestResolve(t *testing.T) {
  32. // Only pass t into top-level Convey calls
  33. Convey("Given some integer with a starting value", t, func() {
  34. d := SysUserSearch{}
  35. list := constructor.GetBindingForGin(d)
  36. for _, binding := range list {
  37. fmt.Printf("%v /n", binding)
  38. }
  39. })
  40. }