user.go 919 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package system
  2. import (
  3. "kpt-tmr-group/http/middleware"
  4. "kpt-tmr-group/pkg/apierr"
  5. "kpt-tmr-group/pkg/apiok"
  6. operationPb "kpt-tmr-group/proto/go/backend/operation"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func Auth(c *gin.Context) {
  11. req := &operationPb.UserAuth{}
  12. if err := c.BindJSON(req); err != nil {
  13. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  14. return
  15. }
  16. res, err := middleware.Dependency(c).StoreEventHub.OpsService.Auth(c, req)
  17. if err != nil {
  18. apierr.ClassifiedAbort(c, err)
  19. return
  20. }
  21. c.JSON(http.StatusOK, apiok.CommonResponse(res))
  22. }
  23. func AddUser(c *gin.Context) {
  24. c.JSON(http.StatusOK, apiok.CommonResponse(apiok.NewApiOk(true)))
  25. }
  26. func GetUserInfo(c *gin.Context) {
  27. res, err := middleware.BackendOperation(c).OpsService.GetUserInfo(c, middleware.GetToken(c))
  28. if err != nil {
  29. apierr.ClassifiedAbort(c, err)
  30. return
  31. }
  32. c.JSON(http.StatusOK, apiok.CommonResponse(res))
  33. }