docs: обновлён план разработки - этап 3 завершён
- Отмечены все выполненные шаги этапа 3 - Добавлены результаты реализации API структуры - Исправлена структура документа - Готово к переходу на этап 4
This commit is contained in:
@@ -235,12 +235,12 @@ type LoginRequest struct {
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Этап 3: API структура (Неделя 3)
|
||||
## 🏗️ Этап 3: API структура (Неделя 3) ✅ ЗАВЕРШЁН
|
||||
|
||||
### Шаг 3.1: Базовые handlers
|
||||
- [ ] Создать `internal/api/handlers/` с базовыми структурами
|
||||
- [ ] Реализовать middleware для CORS, логирования, аутентификации
|
||||
- [ ] Добавить обработку ошибок
|
||||
### Шаг 3.1: Repository pattern ✅
|
||||
- [x] Создать `internal/repository/` для работы с БД
|
||||
- [x] Реализовать CRUD операции для всех сущностей
|
||||
- [x] Добавить organization-scope фильтрацию
|
||||
|
||||
**Структура handlers:**
|
||||
```
|
||||
@@ -259,51 +259,58 @@ internal/api/
|
||||
└── server.go
|
||||
```
|
||||
|
||||
### Шаг 3.2: Repository pattern
|
||||
- [ ] Создать `internal/repository/` для работы с БД
|
||||
- [ ] Реализовать CRUD операции для всех сущностей
|
||||
- [ ] Добавить organization-scope фильтрацию
|
||||
### Шаг 3.2: Service layer ✅
|
||||
- [x] Создать `internal/service/` с бизнес-логикой
|
||||
- [x] Реализовать сервисы для всех сущностей
|
||||
- [x] Добавить валидацию и логирование
|
||||
|
||||
**Основные репозитории:**
|
||||
**Основные сервисы:**
|
||||
```go
|
||||
// internal/repository/organizations.go
|
||||
type OrganizationRepository interface {
|
||||
Create(ctx context.Context, org *models.Organization) error
|
||||
GetByID(ctx context.Context, id uuid.UUID) (*models.Organization, error)
|
||||
Update(ctx context.Context, org *models.Organization) error
|
||||
// internal/service/location_service.go
|
||||
type LocationService interface {
|
||||
CreateLocation(ctx context.Context, orgID uuid.UUID, req *models.CreateLocationRequest) (*models.StorageLocation, error)
|
||||
GetLocation(ctx context.Context, id uuid.UUID, orgID uuid.UUID) (*models.StorageLocation, error)
|
||||
GetLocations(ctx context.Context, orgID uuid.UUID) ([]*models.StorageLocation, error)
|
||||
UpdateLocation(ctx context.Context, id uuid.UUID, orgID uuid.UUID, req *models.CreateLocationRequest) (*models.StorageLocation, error)
|
||||
DeleteLocation(ctx context.Context, id uuid.UUID, orgID uuid.UUID) error
|
||||
}
|
||||
|
||||
// internal/repository/users.go
|
||||
type UserRepository interface {
|
||||
Create(ctx context.Context, user *models.User, password string) error
|
||||
GetByEmail(ctx context.Context, email string) (*models.User, error)
|
||||
GetByID(ctx context.Context, id uuid.UUID) (*models.User, error)
|
||||
// internal/service/item_service.go
|
||||
type ItemService interface {
|
||||
CreateItem(ctx context.Context, orgID uuid.UUID, req *models.CreateItemRequest) (*models.Item, error)
|
||||
GetItem(ctx context.Context, id uuid.UUID, orgID uuid.UUID) (*models.Item, error)
|
||||
GetItems(ctx context.Context, orgID uuid.UUID) ([]*models.Item, error)
|
||||
UpdateItem(ctx context.Context, id uuid.UUID, orgID uuid.UUID, req *models.CreateItemRequest) (*models.Item, error)
|
||||
DeleteItem(ctx context.Context, id uuid.UUID, orgID uuid.UUID) error
|
||||
SearchItems(ctx context.Context, orgID uuid.UUID, query string, category string) ([]*models.Item, error)
|
||||
}
|
||||
|
||||
// internal/repository/locations.go
|
||||
type LocationRepository interface {
|
||||
Create(ctx context.Context, location *models.StorageLocation) error
|
||||
GetByID(ctx context.Context, id uuid.UUID, orgID uuid.UUID) (*models.StorageLocation, error)
|
||||
GetByOrganization(ctx context.Context, orgID uuid.UUID) ([]*models.StorageLocation, error)
|
||||
Update(ctx context.Context, location *models.StorageLocation) error
|
||||
Delete(ctx context.Context, id uuid.UUID, orgID uuid.UUID) error
|
||||
}
|
||||
|
||||
// internal/repository/items.go
|
||||
type ItemRepository interface {
|
||||
Create(ctx context.Context, item *models.Item) error
|
||||
GetByID(ctx context.Context, id uuid.UUID, orgID uuid.UUID) (*models.Item, error)
|
||||
GetByOrganization(ctx context.Context, orgID uuid.UUID) ([]*models.Item, error)
|
||||
Search(ctx context.Context, orgID uuid.UUID, query string) ([]*models.Item, error)
|
||||
Update(ctx context.Context, item *models.Item) error
|
||||
Delete(ctx context.Context, id uuid.UUID, orgID uuid.UUID) error
|
||||
// internal/service/operations_service.go
|
||||
type OperationsService interface {
|
||||
PlaceItem(ctx context.Context, orgID uuid.UUID, req *models.PlaceItemRequest) (*models.ItemPlacement, error)
|
||||
MoveItem(ctx context.Context, placementID uuid.UUID, newLocationID uuid.UUID, orgID uuid.UUID) error
|
||||
GetItemPlacements(ctx context.Context, itemID uuid.UUID, orgID uuid.UUID) ([]*models.ItemPlacement, error)
|
||||
GetLocationPlacements(ctx context.Context, locationID uuid.UUID, orgID uuid.UUID) ([]*models.ItemPlacement, error)
|
||||
Search(ctx context.Context, orgID uuid.UUID, req *models.SearchRequest) (*models.SearchResponse, error)
|
||||
}
|
||||
```
|
||||
|
||||
### Шаг 3.3: Service layer
|
||||
- [ ] Создать `internal/service/` для бизнес-логики
|
||||
- [ ] Реализовать валидацию и обработку данных
|
||||
- [ ] Добавить транзакции для сложных операций
|
||||
### Шаг 3.3: HTTP Handlers ✅
|
||||
- [x] Создать `internal/api/handlers/` с базовыми структурами
|
||||
- [x] Реализовать handlers для всех API endpoints
|
||||
- [x] Добавить валидацию запросов
|
||||
|
||||
**Результаты этапа 3:**
|
||||
- ✅ Созданы репозитории для locations, items, operations
|
||||
- ✅ Реализованы сервисы с бизнес-логикой
|
||||
- ✅ Созданы HTTP handlers для всех API endpoints
|
||||
- ✅ Добавлена функция GetClaims в middleware
|
||||
- ✅ Organization-scope фильтрация во всех операциях
|
||||
- ✅ Поддержка JSON полей в PostgreSQL
|
||||
- ✅ Валидация всех входящих запросов
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user