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>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4e932c2347
commit
42d41eb199
@@ -0,0 +1,26 @@
|
||||
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 },
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user