Scaffold SSR site with CMS/blog/gallery/SEO admin and deploy configs for montech.ir. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.0 KiB
TypeScript
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 } });
|
|
}
|
|
}
|