Init project

This commit is contained in:
2025-08-27 12:47:23 +04:00
commit 9ee249de29
24 changed files with 2449 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
package models
import (
"time"
"github.com/google/uuid"
)
// 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"`
}
// 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"`
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"`
}
// 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"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
// ItemPlacement представляет размещение товара в месте хранения
type ItemPlacement struct {
ID uuid.UUID `json:"id" db:"id"`
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"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
// LoginRequest запрос на аутентификацию
type LoginRequest struct {
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required"`
}
// LoginResponse ответ на аутентификацию
type LoginResponse struct {
Token string `json:"token"`
RefreshToken string `json:"refresh_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"`
}
// CreateItemRequest запрос на создание товара
type CreateItemRequest struct {
Name string `json:"name" binding:"required"`
Description string `json:"description"`
Category string `json:"category" binding:"required"`
}
// 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"`
}
// SearchRequest запрос на поиск
type SearchRequest struct {
Query string `json:"query" binding:"required"`
Category string `json:"category"`
LocationID *uuid.UUID `json:"location_id"`
}
// SearchResponse результат поиска
type SearchResponse struct {
Items []ItemWithLocation `json:"items"`
TotalCount int `json:"total_count"`
}
// ItemWithLocation товар с информацией о месте размещения
type ItemWithLocation struct {
Item Item `json:"item"`
Location StorageLocation `json:"location"`
Quantity int `json:"quantity"`
}