This commit is contained in:
parent
c7c67a641e
commit
081267a662
3 changed files with 57 additions and 8 deletions
|
|
@ -29,6 +29,7 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup, mw *router.Middlewares) {
|
|||
userGroup.POST("", mw.RegMW, h.controller.create)
|
||||
userGroup.DELETE("", mw.AuthMW, h.controller.delete)
|
||||
userGroup.GET("/me", mw.AuthMW, h.controller.me)
|
||||
userGroup.GET("/personal", mw.AuthMW, h.controller.getPersonalData)
|
||||
}
|
||||
|
||||
// create godoc
|
||||
|
|
@ -121,3 +122,38 @@ func (co *controller) me(c *gin.Context) {
|
|||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// getPersonalData godoc
|
||||
//
|
||||
// @Summary Получить персональные данные.
|
||||
// @Description Получить персональные данные. Запрос данных по gRPC у сервиса авторизации.
|
||||
// @Tags User
|
||||
// @Produce json
|
||||
// @Success 200 {object} common.PersonalDTO
|
||||
// @Success 204 {object}
|
||||
// @Failure 400 {object} responses.BadRequest
|
||||
// @Failure 401 {object} responses.Unauthorized
|
||||
// @Failure 500 {object} responses.InternalServerError
|
||||
// @Router /merch/labels/{uuid} [get]
|
||||
func (co *controller) getPersonalData(c *gin.Context) {
|
||||
u, err := co.utils.GetUserUuidFromContext(c)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, responses.BadRequest{Error: err.Error()})
|
||||
appLog.LogErr(pkgLogHeader, controllerLogHeader, err)
|
||||
return
|
||||
}
|
||||
|
||||
response, err := co.service.getPersonalData(c, u)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, responses.InternalServerError{Error: err.Error()})
|
||||
appLog.LogErr(pkgLogHeader, controllerLogHeader, err)
|
||||
return
|
||||
}
|
||||
|
||||
if response == nil {
|
||||
c.Status(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue