style: форматирование кода - убраны лишние пустые строки
This commit is contained in:
@@ -90,9 +90,9 @@ type OrganizationResponse struct {
|
||||
|
||||
// LoginResponse ответ на аутентификацию
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
User UserResponse `json:"user"`
|
||||
Organization OrganizationResponse `json:"organization"`
|
||||
Token string `json:"token"`
|
||||
User UserResponse `json:"user"`
|
||||
Organization OrganizationResponse `json:"organization"`
|
||||
}
|
||||
|
||||
// CreateLocationRequest запрос на создание места хранения
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"erp-mvp/core-service/internal/models"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -29,18 +30,18 @@ func (r *organizationRepository) Create(ctx context.Context, org *models.Organiz
|
||||
INSERT INTO organizations (id, name, type, settings, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
`
|
||||
|
||||
|
||||
// Конвертируем JSON в строку
|
||||
settingsJSON, err := json.Marshal(org.Settings)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal settings: %w", err)
|
||||
}
|
||||
|
||||
|
||||
_, err = r.db.ExecContext(ctx, query, org.ID, org.Name, org.Type, string(settingsJSON), org.CreatedAt)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create organization: %w", err)
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ func (r *organizationRepository) GetByID(ctx context.Context, id uuid.UUID) (*mo
|
||||
FROM organizations
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
|
||||
var settingsJSON []byte
|
||||
org := &models.Organization{}
|
||||
err := r.db.QueryRowContext(ctx, query, id).Scan(
|
||||
@@ -60,14 +61,14 @@ func (r *organizationRepository) GetByID(ctx context.Context, id uuid.UUID) (*mo
|
||||
&settingsJSON,
|
||||
&org.CreatedAt,
|
||||
)
|
||||
|
||||
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, fmt.Errorf("organization not found")
|
||||
}
|
||||
return nil, fmt.Errorf("failed to get organization: %w", err)
|
||||
}
|
||||
|
||||
|
||||
// Конвертируем JSON строку в map
|
||||
if len(settingsJSON) > 0 {
|
||||
err = json.Unmarshal(settingsJSON, &org.Settings)
|
||||
@@ -77,7 +78,7 @@ func (r *organizationRepository) GetByID(ctx context.Context, id uuid.UUID) (*mo
|
||||
} else {
|
||||
org.Settings = make(models.JSON)
|
||||
}
|
||||
|
||||
|
||||
return org, nil
|
||||
}
|
||||
|
||||
@@ -87,26 +88,26 @@ func (r *organizationRepository) Update(ctx context.Context, org *models.Organiz
|
||||
SET name = $2, type = $3, settings = $4
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
|
||||
// Конвертируем JSON в строку
|
||||
settingsJSON, err := json.Marshal(org.Settings)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal settings: %w", err)
|
||||
}
|
||||
|
||||
|
||||
result, err := r.db.ExecContext(ctx, query, org.ID, org.Name, org.Type, string(settingsJSON))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update organization: %w", err)
|
||||
}
|
||||
|
||||
|
||||
rowsAffected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get rows affected: %w", err)
|
||||
}
|
||||
|
||||
|
||||
if rowsAffected == 0 {
|
||||
return fmt.Errorf("organization not found")
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user