Files
Montech_Landing/apps/api/src/gallery/gallery.service.ts
T
MahdiandCursor 7e8e1b1f1b Initial Montech monorepo: Nuxt landing, Vue admin, Nest API.
Scaffold SSR site with CMS/blog/gallery/SEO admin and deploy configs for montech.ir.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-30 18:42:28 +03:30

48 lines
1.0 KiB
TypeScript

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 } });
}
}