package platform import ( "errors" "github.com/gin-gonic/gin" "github.com/google/uuid" "base/internal/domain/profile" "base/internal/dto" "base/internal/server/middleware" ) // GetSpecialistOverview returns overview for specialist users with full asset details, profile, and skills. // @Summary get specialist overview // @Description get overview for specialist view with assets, profile, skills, recently joined, analytics // @Tags Platform // @Produce json // @Security BearerAuth // @Success 200 {object} dto.SpecialistOverviewFetchedResponse // @Failure 401 {object} dto.ErrorResponse // @Failure 404 {object} dto.ErrorResponse "profile not found" // @Failure 500 {object} dto.ErrorResponse "internal server error" // @Router /api/v1/platform/overview/specialist [get] func (ctl *Controller) GetSpecialistOverview(c *gin.Context) { lg := ctl.logger.With(). Str("module", "platform"). Str("router", "overview"). Str("handler", "Overview"). Logger() userIDVal, exists := c.Get(middleware.UserIDKey) if !exists { r := dto.Unauthorized() c.JSON(r.Status, r) return } userIDStr, ok := userIDVal.(string) if !ok { r := dto.Unauthorized() c.JSON(r.Status, r) return } userID, err := uuid.Parse(userIDStr) if err != nil { r := dto.BadRequest().WithMessage("invalid user ID") c.JSON(r.Status, r) return } resp, err := ctl.specialistService.Overview(c.Request.Context(), userID) if err != nil { lg.Error().Err(err).Msg("failed to fetch overview") switch { case errors.Is(err, profile.ErrProfileNotFound): r := dto.NotFound().WithMessage("profile not found") c.JSON(r.Status, r) default: r := dto.InternalServerError() c.JSON(r.Status, r) } return } r := dto.OK().WithData(resp) c.JSON(r.Status, r) } // GetDiscoveryOverview returns overview for non-specialist users discovering assets and specialists. // No profile required - callers browse latest assets and profiles. // @Summary get discovery overview // @Description overview for browsing users (latest assets, recently joined profiles, analytics). No profile required. // @Tags Platform // @Accept json // @Produce json // @Security BearerAuth // @Success 200 {object} dto.OverviewFetchedResponse "overview response" // @Failure 401 {object} dto.ErrorResponse "unauthorized" // @Failure 500 {object} dto.ErrorResponse "internal server error" // @Router /api/v1/platform/overview/discovery [get] func (ctl *Controller) GetDiscoveryOverview(c *gin.Context) { lg := ctl.logger.With(). Str("module", "platform"). Str("router", "overview"). Str("handler", "GetDiscoveryOverview"). Logger() if _, exists := c.Get(middleware.UserIDKey); !exists { r := dto.Unauthorized() c.JSON(r.Status, r) return } overview, err := ctl.discoveryService.GetDiscoveryOverview(c.Request.Context()) if err != nil { lg.Error().Err(err).Msg("failed to get discovery overview") r := dto.InternalServerError() c.JSON(r.Status, r) return } r := dto.OK().WithData(overview) c.JSON(r.Status, r) }