test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package controller
  2. import (
  3. "gframe/service"
  4. "net/http"
  5. )
  6. type Test struct {
  7. BaseController
  8. }
  9. // UserAdd godoc
  10. // @Summary 会员用户添加
  11. // @tags Test
  12. // @Description 会员用户添加
  13. // @Accept x-www-form-urlencoded
  14. // @Produce json
  15. // @Param name formData string true "姓名"
  16. // @Success 200 {object} controller.ResponseBase
  17. // @Router /Test/UserAdd [post]
  18. func (t *Test) UserAdd() (err error) {
  19. name := t.postString("name", true)
  20. err = service.Test{}.UserAdd(name)
  21. if err != nil {
  22. return
  23. }
  24. t.Ctx().JSON(http.StatusOK, newResponseBase())
  25. return
  26. }
  27. type UserList struct {
  28. ResponseBase
  29. Rs []interface{}
  30. //Rs []*gorm.ShopUserSimpleInfo
  31. }
  32. // UserListQuery godoc
  33. // @Summary 会员用户查询
  34. // @tags Test
  35. // @Description 会员用户查询
  36. // @Accept x-www-form-urlencoded
  37. // @Produce json
  38. // @Success 200 {object} controller.UserList
  39. // @Router /Test/UserListQuery [post]
  40. func (t *Test) UserListQuery() (err error) {
  41. rs, err := service.Test{}.UserListQuery()
  42. if err != nil {
  43. return
  44. }
  45. rp := UserList{
  46. newResponseBase(),
  47. rs,
  48. }
  49. t.Ctx().JSON(http.StatusOK, rp)
  50. return
  51. }