new file: begushiybashkir/bbvue/public/images/locations/1mayPark.webp

new file:   begushiybashkir/bbvue/public/images/locations/dinamo.jpg
	new file:   begushiybashkir/bbvue/public/images/locations/riverSide.jpeg
	modified:   begushiybashkir/bbvue/src/views/Training.vue
	modified:   serv_nginx/api_bb/internal/handlers/handler_util.go
	modified:   serv_nginx/api_bb/internal/handlers/user.go
	modified:   serv_nginx/api_bb/internal/routes/routes.go
	modified:   serv_nginx/api_bb/internal/service/auth_service.go
	modified:   serv_nginx/api_bb/internal/service/user_service.go
add photo location into trainings page
This commit is contained in:
2025-10-12 16:55:55 +05:00
parent ebe43e6617
commit 12f805f9e1
9 changed files with 124 additions and 96 deletions
@@ -2,7 +2,6 @@ package handlers
import (
"api_bb/internal/models"
"net/http"
)
// Общая функция для преобразования User в UserResponse
@@ -21,8 +20,3 @@ func toUserResponse(user *models.User) UserResponse {
UpdatedAt: user.UpdatedAt,
}
}
// Обработчик для OPTIONS запросов
func (h *UserHandler) handleOptions(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
+4 -4
View File
@@ -19,14 +19,14 @@ import (
)
type UserHandler struct {
authService service.AuthService
logger logger.Interface
userService service.UserService
}
func NewUserHandler(authService service.AuthService) *UserHandler {
func NewUserHandler(userService service.UserService) *UserHandler {
return &UserHandler{
authService: authService,
logger: logger.NewWrapper(logger.Get().With(zap.String("handler", "user"))),
userService: userService,
}
}
@@ -155,7 +155,7 @@ func (h *UserHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {
}
// Сохраняем обновленные данные
if err := h.authService.UpdateProfile(updatedUser); err != nil {
if err := h.userService.UpdateProfile(updatedUser); err != nil {
h.logger.Error("failed to update profile in service",
zap.Uint("user_id", currentUser.ID),
zap.Error(err),
+2 -1
View File
@@ -32,11 +32,12 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
// Initialize services with logger
jwtService := service.NewJWTService(config.JWTSecret)
authService := service.NewAuthService(userRepo, jwtService, baseLogger) // Передаем логгер
userService := service.NewUserService(userRepo, jwtService, baseLogger)
// Initialize handlers
healthHandler := handlers.NewHealthHandler()
authHandler := handlers.NewAuthHandler(authService, jwtService)
userHandler := handlers.NewUserHandler(authService)
userHandler := handlers.NewUserHandler(&userService)
// Health routes
r.Mount("/api", healthHandler.Routes())
@@ -15,8 +15,6 @@ import (
type AuthService interface {
Register(user *models.User) error
Login(email, password string) (*models.User, string, error)
GetUserProfile(userID uint) (*models.User, error)
UpdateProfile(user *models.User) error
}
type authService struct {
@@ -21,11 +21,17 @@ type userService struct {
logger logger.Interface
}
func NewUserService(userRepo repository.UserRepository, jwtService JWTService, log logger.Interface) AuthService {
// Создаем логгер с контекстом для сервиса
serviceLogger := log.With(zap.String("service", "auth"))
return &authService{
// UpdateProfile implements UserService.
func (s userService) UpdateProfile(user *models.User) error {
panic("unimplemented")
}
func NewUserService(userRepo repository.UserRepository, jwtService JWTService, log logger.Interface) userService {
// Создаем логгер с контекстом для сервиса
serviceLogger := log.With(zap.String("service", "user"))
return userService{
userRepo: userRepo,
jwtService: jwtService,
logger: serviceLogger,
@@ -64,7 +70,7 @@ func (s *authService) UpdateProfile(user *models.User) error {
return s.userRepo.UpdateExcludeEmail(updateData)
}
func (s *authService) GetUserProfile(userID uint) (*models.User, error) {
func (s *userService) GetUserProfile(userID uint) (*models.User, error) {
s.logger.Debug("Getting user profile",
zap.Uint("user_id", userID),
)