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:
@@ -8,6 +8,12 @@ export type CategoryNode = {
|
||||
children: CategoryNode[];
|
||||
};
|
||||
|
||||
export type FlatCategory = {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class CategoriesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
@@ -30,4 +36,15 @@ export class CategoriesService {
|
||||
});
|
||||
return roots;
|
||||
}
|
||||
|
||||
async findFlattened(): Promise<FlatCategory[]> {
|
||||
const all = await this.prisma.category.findMany({ orderBy: { name: 'asc' } });
|
||||
const nameMap = new Map<number, string>();
|
||||
all.forEach((c) => nameMap.set(c.id, c.name));
|
||||
return all.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
path: c.parentId ? `${nameMap.get(c.parentId) ?? ''} > ${c.name}` : c.name,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user