product admin crud

This commit is contained in:
user
2025-10-20 19:16:19 +03:00
parent e239b3bbf6
commit 2cc0ca4c51
22 changed files with 2601 additions and 35 deletions

View File

@@ -0,0 +1,39 @@
import { db } from "@pkg/db";
import type { CreateProductPayload, UpdateProductPayload } from "./data";
import { ProductRepository } from "./repository";
export class ProductUseCases {
private repo: ProductRepository;
constructor(repo: ProductRepository) {
this.repo = repo;
}
async getAllProducts() {
return this.repo.listAllProducts();
}
async getProductById(id: number) {
return this.repo.getProductById(id);
}
async createProduct(payload: CreateProductPayload) {
return this.repo.createProduct(payload);
}
async updateProduct(payload: UpdateProductPayload) {
return this.repo.updateProduct(payload);
}
async deleteProduct(id: number) {
return this.repo.deleteProduct(id);
}
async refreshProductLinkId(id: number) {
return this.repo.refreshProductLinkId(id);
}
}
export function getProductUseCases() {
return new ProductUseCases(new ProductRepository(db));
}