MAJOR UPPDATE: "First Ai"

feat: add AI categorization for products and enhance user management

- Integrated AI service for category suggestions in receipt import and product management.
- Added premium subscription feature for users with corresponding API endpoints.
- Implemented admin interface for managing pending product suggestions.
- Enhanced user management to include premium status and corresponding UI updates.
- Updated database schema to support new fields for premium status and product status.
This commit is contained in:
Nils-Johan Gynther
2026-04-19 10:34:21 +02:00
parent 0286ab0991
commit 054a19ed7c
30 changed files with 917 additions and 77 deletions
+23
View File
@@ -407,4 +407,27 @@ export class ProductsService {
await this.prisma.product.updateMany({ where: { id: { in: ids } }, data: updateData });
return { updated: ids.length };
}
async findUncategorized(): Promise<{ id: number; name: string; canonicalName: string | null }[]> {
return this.prisma.product.findMany({
where: { isActive: true, categoryId: null, status: 'active' },
select: { id: true, name: true, canonicalName: true },
orderBy: { name: 'asc' },
});
}
async findPending() {
return this.prisma.product.findMany({
where: { status: 'pending' },
include: {
categoryRef: { include: { parent: true } },
owner: { select: { id: true, username: true } },
},
orderBy: { createdAt: 'desc' },
});
}
setStatus(id: number, status: string) {
return this.prisma.product.update({ where: { id }, data: { status } });
}
}