import { Injectable } from "@nestjs/common"; import { PrismaService } from "../prisma/prisma.service"; @Injectable() export class GalleryService { constructor(private prisma: PrismaService) {} listPublic() { return this.prisma.galleryItem.findMany({ where: { published: true }, orderBy: [{ sortOrder: "asc" }, { createdAt: "desc" }], }); } listAdmin() { return this.prisma.galleryItem.findMany({ orderBy: [{ sortOrder: "asc" }, { createdAt: "desc" }], }); } create(data: { title: string; imageUrl: string; category?: string; sortOrder?: number; published?: boolean; }) { return this.prisma.galleryItem.create({ data }); } update( id: string, data: { title?: string; imageUrl?: string; category?: string | null; sortOrder?: number; published?: boolean; }, ) { return this.prisma.galleryItem.update({ where: { id }, data }); } remove(id: string) { return this.prisma.galleryItem.delete({ where: { id } }); } }