feat: завершён этап 1 - Фундамент Core Service
- Удалены зависимости: grpc, redis, prometheus - Упрощена конфигурация (Server, Database, JWT) - Создан логгер на основе logrus - Добавлено подключение к PostgreSQL - Создана миграция с базовыми таблицами - Обновлены модели с валидацией - Создан базовый API сервер с health check - Добавлен .env.example Готово для этапа 2 - Аутентификация
This commit is contained in:
@@ -8,47 +8,43 @@ import (
|
||||
|
||||
// Organization представляет организацию/компанию
|
||||
type Organization struct {
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Type string `json:"type" db:"type"`
|
||||
Settings map[string]any `json:"settings" db:"settings"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Type string `json:"type"`
|
||||
Settings JSON `json:"settings"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
}
|
||||
|
||||
// User представляет пользователя системы
|
||||
type User struct {
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"`
|
||||
Email string `json:"email" db:"email"`
|
||||
Role string `json:"role" db:"role"`
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
PasswordHash string `json:"-" db:"password_hash"`
|
||||
Role string `json:"role"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||
}
|
||||
|
||||
// StorageLocation представляет место хранения
|
||||
type StorageLocation struct {
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"`
|
||||
ParentID *uuid.UUID `json:"parent_id" db:"parent_id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Address string `json:"address" db:"address"`
|
||||
Type string `json:"type" db:"type"`
|
||||
Coordinates map[string]any `json:"coordinates" db:"coordinates"`
|
||||
QRCode string `json:"qr_code" db:"qr_code"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"`
|
||||
ParentID *uuid.UUID `json:"parent_id,omitempty" db:"parent_id"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Address string `json:"address" validate:"required"`
|
||||
Type string `json:"type" validate:"required"`
|
||||
Coordinates JSON `json:"coordinates"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
}
|
||||
|
||||
// Item представляет товар/материал
|
||||
type Item struct {
|
||||
ID uuid.UUID `json:"id" db:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Description string `json:"description" db:"description"`
|
||||
Category string `json:"category" db:"category"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Description string `json:"description"`
|
||||
Category string `json:"category"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||
}
|
||||
|
||||
// ItemPlacement представляет размещение товара в месте хранения
|
||||
@@ -57,53 +53,64 @@ type ItemPlacement struct {
|
||||
OrganizationID uuid.UUID `json:"organization_id" db:"organization_id"`
|
||||
ItemID uuid.UUID `json:"item_id" db:"item_id"`
|
||||
LocationID uuid.UUID `json:"location_id" db:"location_id"`
|
||||
Quantity int `json:"quantity" db:"quantity"`
|
||||
Quantity int `json:"quantity" validate:"min=1"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||
}
|
||||
|
||||
// JSON тип для JSON полей
|
||||
type JSON map[string]interface{}
|
||||
|
||||
// LoginRequest запрос на аутентификацию
|
||||
type LoginRequest struct {
|
||||
Email string `json:"email" binding:"required,email"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
}
|
||||
|
||||
// RegisterRequest запрос на регистрацию
|
||||
type RegisterRequest struct {
|
||||
OrganizationName string `json:"organization_name" validate:"required"`
|
||||
UserEmail string `json:"user_email" validate:"required,email"`
|
||||
UserPassword string `json:"user_password" validate:"required,min=8"`
|
||||
OrganizationType string `json:"organization_type"`
|
||||
}
|
||||
|
||||
// LoginResponse ответ на аутентификацию
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
User User `json:"user"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
Token string `json:"token"`
|
||||
User User `json:"user"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
// CreateLocationRequest запрос на создание места хранения
|
||||
type CreateLocationRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Address string `json:"address" binding:"required"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
ParentID *uuid.UUID `json:"parent_id"`
|
||||
Coordinates map[string]any `json:"coordinates"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Address string `json:"address" validate:"required"`
|
||||
Type string `json:"type" validate:"required"`
|
||||
ParentID *uuid.UUID `json:"parent_id"`
|
||||
Coordinates JSON `json:"coordinates"`
|
||||
}
|
||||
|
||||
// CreateItemRequest запрос на создание товара
|
||||
type CreateItemRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Description string `json:"description"`
|
||||
Category string `json:"category" binding:"required"`
|
||||
Category string `json:"category"`
|
||||
}
|
||||
|
||||
// PlaceItemRequest запрос на размещение товара
|
||||
type PlaceItemRequest struct {
|
||||
ItemID uuid.UUID `json:"item_id" binding:"required"`
|
||||
LocationID uuid.UUID `json:"location_id" binding:"required"`
|
||||
Quantity int `json:"quantity" binding:"required,min=1"`
|
||||
ItemID uuid.UUID `json:"item_id" validate:"required"`
|
||||
LocationID uuid.UUID `json:"location_id" validate:"required"`
|
||||
Quantity int `json:"quantity" validate:"required,min=1"`
|
||||
}
|
||||
|
||||
// SearchRequest запрос на поиск
|
||||
type SearchRequest struct {
|
||||
Query string `json:"query" binding:"required"`
|
||||
Category string `json:"category"`
|
||||
LocationID *uuid.UUID `json:"location_id"`
|
||||
Query string `form:"q"`
|
||||
Category string `form:"category"`
|
||||
Address string `form:"address"`
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"page_size,default=20"`
|
||||
}
|
||||
|
||||
// SearchResponse результат поиска
|
||||
@@ -114,7 +121,7 @@ type SearchResponse struct {
|
||||
|
||||
// ItemWithLocation товар с информацией о месте размещения
|
||||
type ItemWithLocation struct {
|
||||
Item Item `json:"item"`
|
||||
Item Item `json:"item"`
|
||||
Location StorageLocation `json:"location"`
|
||||
Quantity int `json:"quantity"`
|
||||
Quantity int `json:"quantity"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user