Объединены файлы правил системы в единую базу знаний v3.0 с устранением противоречий и дублирования. Создан rules-unified.md на основе rules.md, rules1.md и rules2.md с добавлением всех уникальных разделов. Обновлена терминология системы с соответствием реальной схеме БД (ТОВАР→PRODUCT, РАСХОДНИКИ→CONSUMABLE). Архивированы старые файлы правил в папку archive. Обновлены ссылки в CLAUDE.md и development-checklist.md на новый единый источник истины.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Veronika Smirnova
2025-08-05 00:19:17 +03:00
parent 17ffd6c9ed
commit ee72a9488b
21 changed files with 9147 additions and 174 deletions

View File

@ -595,6 +595,51 @@ export const GET_ALL_PRODUCTS = gql`
}
`;
// Запрос товаров конкретной организации (для формы создания поставки)
export const GET_ORGANIZATION_PRODUCTS = gql`
query GetOrganizationProducts($organizationId: ID!, $search: String, $category: String, $type: String) {
organizationProducts(organizationId: $organizationId, search: $search, category: $category, type: $type) {
id
name
article
description
price
quantity
type
category {
id
name
}
brand
color
size
weight
dimensions
material
images
mainImage
isActive
createdAt
updatedAt
organization {
id
inn
name
fullName
type
address
phones
emails
users {
id
avatar
managerName
}
}
}
}
`;
export const GET_MY_CART = gql`
query GetMyCart {
myCart {

View File

@ -1748,6 +1748,76 @@ export const resolvers = {
return products;
},
// Товары конкретной организации (для формы создания поставки)
organizationProducts: async (
_: unknown,
args: { organizationId: string; search?: string; category?: string; type?: string },
context: Context
) => {
console.log("🏢 ORGANIZATION_PRODUCTS RESOLVER - ВЫЗВАН:", {
userId: context.user?.id,
organizationId: args.organizationId,
search: args.search,
category: args.category,
type: args.type,
timestamp: new Date().toISOString(),
});
if (!context.user) {
throw new GraphQLError("Требуется авторизация", {
extensions: { code: "UNAUTHENTICATED" },
});
}
const where: Record<string, unknown> = {
isActive: true, // Показываем только активные товары
organizationId: args.organizationId, // Фильтруем по конкретной организации
type: args.type || "ТОВАР", // Показываем только товары по умолчанию, НЕ расходники согласно development-checklist.md
};
if (args.search) {
where.OR = [
{ name: { contains: args.search, mode: "insensitive" } },
{ article: { contains: args.search, mode: "insensitive" } },
{ description: { contains: args.search, mode: "insensitive" } },
{ brand: { contains: args.search, mode: "insensitive" } },
];
}
if (args.category) {
where.categoryId = args.category;
}
const products = await prisma.product.findMany({
where,
include: {
category: true,
organization: {
include: {
users: true,
},
},
},
orderBy: { createdAt: "desc" },
take: 100, // Ограничиваем количество результатов
});
console.log("🔥 ORGANIZATION_PRODUCTS RESOLVER DEBUG:", {
organizationId: args.organizationId,
searchArgs: args,
whereCondition: where,
totalProducts: products.length,
productTypes: products.map((p) => ({
id: p.id,
name: p.name,
type: p.type,
isActive: p.isActive,
})),
});
return products;
},
// Все категории
categories: async (_: unknown, __: unknown, context: Context) => {
if (!context.user && !context.admin) {

View File

@ -70,6 +70,9 @@ export const typeDefs = gql`
# Все товары всех поставщиков для маркета
allProducts(search: String, category: String): [Product!]!
# Товары конкретной организации (для формы создания поставки)
organizationProducts(organizationId: ID!, search: String, category: String, type: String): [Product!]!
# Все категории
categories: [Category!]!
@ -467,10 +470,8 @@ export const typeDefs = gql`
OZON
}
enum ProductType {
PRODUCT
CONSUMABLE
}
# ProductType теперь String, чтобы поддерживать кириллические значения из БД
# Возможные значения: "ТОВАР", "БРАК", "РАСХОДНИКИ", "ПРОДУКТ"
enum CounterpartyRequestStatus {
PENDING
@ -746,7 +747,7 @@ export const typeDefs = gql`
inTransit: Int
stock: Int
sold: Int
type: ProductType
type: String
category: Category
brand: String
color: String
@ -774,7 +775,7 @@ export const typeDefs = gql`
inTransit: Int
stock: Int
sold: Int
type: ProductType
type: String
categoryId: ID
brand: String
color: String