Добавлены модели товаров и корзины для оптовиков, реализованы соответствующие мутации и запросы в GraphQL. Обновлен API для загрузки файлов с учетом новых типов данных. Улучшена обработка ошибок и добавлены новые функции для работы с категориями товаров.

This commit is contained in:
Bivekich
2025-07-17 16:36:07 +03:00
parent 6a94d51032
commit f377fbab5f
21 changed files with 3958 additions and 34 deletions

View File

@ -28,6 +28,18 @@ export const typeDefs = gql`
# Расходники организации
mySupplies: [Supply!]!
# Товары оптовика
myProducts: [Product!]!
# Все товары всех оптовиков для маркета
allProducts(search: String, category: String): [Product!]!
# Все категории
categories: [Category!]!
# Корзина пользователя
myCart: Cart
}
type Mutation {
@ -77,6 +89,17 @@ export const typeDefs = gql`
createSupply(input: SupplyInput!): SupplyResponse!
updateSupply(id: ID!, input: SupplyInput!): SupplyResponse!
deleteSupply(id: ID!): Boolean!
# Работа с товарами (для оптовиков)
createProduct(input: ProductInput!): ProductResponse!
updateProduct(id: ID!, input: ProductInput!): ProductResponse!
deleteProduct(id: ID!): Boolean!
# Работа с корзиной
addToCart(productId: ID!, quantity: Int = 1): CartResponse!
updateCartItem(productId: ID!, quantity: Int!): CartResponse!
removeFromCart(productId: ID!): CartResponse!
clearCart: Boolean!
}
# Типы данных
@ -160,6 +183,7 @@ export const typeDefs = gql`
input FulfillmentRegistrationInput {
phone: String!
inn: String!
type: OrganizationType!
}
input SellerRegistrationInput {
@ -349,6 +373,89 @@ export const typeDefs = gql`
supply: Supply
}
# Типы для категорий товаров
type Category {
id: ID!
name: String!
createdAt: String!
updatedAt: String!
}
# Типы для товаров оптовика
type Product {
id: ID!
name: String!
article: String!
description: String
price: Float!
quantity: Int!
category: Category
brand: String
color: String
size: String
weight: Float
dimensions: String
material: String
images: [String!]!
mainImage: String
isActive: Boolean!
createdAt: String!
updatedAt: String!
organization: Organization!
}
input ProductInput {
name: String!
article: String!
description: String
price: Float!
quantity: Int!
categoryId: ID
brand: String
color: String
size: String
weight: Float
dimensions: String
material: String
images: [String!]
mainImage: String
isActive: Boolean
}
type ProductResponse {
success: Boolean!
message: String!
product: Product
}
# Типы для корзины
type Cart {
id: ID!
items: [CartItem!]!
totalPrice: Float!
totalItems: Int!
createdAt: String!
updatedAt: String!
organization: Organization!
}
type CartItem {
id: ID!
product: Product!
quantity: Int!
totalPrice: Float!
isAvailable: Boolean!
availableQuantity: Int!
createdAt: String!
updatedAt: String!
}
type CartResponse {
success: Boolean!
message: String!
cart: Cart
}
# JSON скаляр
scalar JSON
`