users_controller.go 520 B

1234567891011121314151617181920212223242526
  1. package v1
  2. import (
  3. "github.com/runningwater/gohub/app/models/user"
  4. "github.com/runningwater/gohub/pkg/auth"
  5. "github.com/runningwater/gohub/pkg/response"
  6. "github.com/gin-gonic/gin"
  7. )
  8. type UsersController struct {
  9. BaseApiController
  10. }
  11. // CurrentUser 当前登录用户信息
  12. func (ctrl *UsersController) CurrentUser(c *gin.Context) {
  13. users := auth.CurrentUser(c)
  14. response.Data(c, users)
  15. }
  16. // Index 所有用户
  17. func (ctrl *UsersController) Index(c *gin.Context) {
  18. data := user.All()
  19. response.Data(c, data)
  20. }