mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
start rmser
This commit is contained in:
43
internal/domain/recommendations/entity.go
Normal file
43
internal/domain/recommendations/entity.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package recommendations
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Типы проблем
|
||||
const (
|
||||
TypeUnused = "UNUSED_IN_RECIPES" // Товар не используется в техкартах
|
||||
TypeNoIncoming = "NO_INCOMING" // Ингредиент (GOODS) в техкарте, но нет приходов
|
||||
TypeStale = "STALE_GOODS" // Есть приходы, но нет продаж
|
||||
TypeDishInRecipe = "DISH_IN_RECIPE" // Блюдо (DISH) в составе другого блюда
|
||||
TypePurchasedButUnused = "PURCHASED_BUT_UNUSED" // Активно закупается, но нет в техкартах
|
||||
TypeUsageNoIncoming = "USAGE_NO_INCOMING" // Есть расходы, но нет приходов
|
||||
)
|
||||
|
||||
// Recommendation - Результат анализа
|
||||
type Recommendation struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
|
||||
Type string `gorm:"type:varchar(50);index"`
|
||||
ProductID uuid.UUID `gorm:"type:uuid;index"`
|
||||
ProductName string `gorm:"type:varchar(255)"`
|
||||
Reason string `gorm:"type:text"`
|
||||
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// Repository отвечает за аналитические выборки и хранение результатов
|
||||
type Repository interface {
|
||||
// Методы анализа (возвращают список структур, но не пишут в БД)
|
||||
FindUnusedGoods() ([]Recommendation, error)
|
||||
FindNoIncomingIngredients(days int) ([]Recommendation, error)
|
||||
FindStaleGoods(days int) ([]Recommendation, error)
|
||||
FindDishesInRecipes() ([]Recommendation, error)
|
||||
FindPurchasedButUnused(days int) ([]Recommendation, error)
|
||||
FindUsageWithoutPurchase(days int) ([]Recommendation, error)
|
||||
|
||||
// Методы "Кэша" в БД
|
||||
SaveAll(items []Recommendation) error // Удаляет старые и пишет новые
|
||||
GetAll() ([]Recommendation, error)
|
||||
}
|
||||
Reference in New Issue
Block a user