Объединены файлы правил системы в единую базу знаний 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:
@ -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) {
|
||||
|
Reference in New Issue
Block a user