Files
prosapp-migration/backend/src/suggestions/suggestions.service.ts
T
Lizandro GuarnizoandClaude Sonnet 4.6 42d41eb199 feat: módulo de sugerencias (backend) + página pública /sugerencias (admin)
- Backend: POST /suggestions (público) + GET /suggestions (JWT admin)
- Admin: página pública /sugerencias con formulario de sugerencias
- schema.prisma: modelo suggestions
- AuthGuard + Sidebar: /sugerencias como ruta pública

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 19:05:58 -05:00

27 lines
714 B
TypeScript

import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class SuggestionsService {
constructor(private prisma: PrismaService) {}
create(data: { name?: string; message: string }) {
return this.prisma.suggestions.create({ data });
}
findAll(page = 1, limit = 50) {
const skip = (page - 1) * limit;
return Promise.all([
this.prisma.suggestions.findMany({
skip,
take: limit,
orderBy: { created_at: 'desc' },
}),
this.prisma.suggestions.count(),
]).then(([data, total]) => ({
data,
meta: { total, page, limit, totalPages: Math.ceil(total / limit) || 1 },
}));
}
}