You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

4 years ago
  1. package main
  2. func InitializationHttpCrudAdminMyTestr(router *hskgin.GinHelper) {
  3. var authority = func(ctx *hskgin.GinContextHelper) {
  4. //todo 权限控制
  5. }
  6. router.Any("/admin/myTestr/get", func(ctx *hskgin.GinContextHelper) {
  7. authority(ctx)
  8. req := MyTestr{}
  9. ctx.Bind(&req)
  10. err := req.Load()
  11. ctx.CheckErrDisplayByError(err)
  12. ctx.DisplayByData(req)
  13. })
  14. router.Any("/admin/myTestr/save", func(ctx *hskgin.GinContextHelper) {
  15. authority(ctx)
  16. req := MyTestr{}
  17. ctx.Bind(&req)
  18. err := req.Save()
  19. ctx.CheckErrDisplayByError(err)
  20. err = req.Load()
  21. ctx.CheckErrDisplayByError(err)
  22. ctx.DisplayByData(req)
  23. })
  24. router.Any("/admin/myTestr/data", func(ctx *hskgin.GinContextHelper) {
  25. authority(ctx)
  26. req := MyTestr{}
  27. ctx.Bind(&req)
  28. data := req.Data()
  29. ctx.DisplayByData(data)
  30. })
  31. router.Any("/admin/myTestr/list", func(ctx *hskgin.GinContextHelper) {
  32. authority(ctx)
  33. req := MyTestr{}
  34. ctx.Bind(&req)
  35. page := ctx.ParamRequired2Page(true)
  36. data, count := req.PageData(page, 10)
  37. ctx.DisplayByPage(data, count)
  38. })
  39. }