feat: add admin catalog workflow
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-08 22:30:30 -04:00
parent 86c60f9381
commit a6d8b9bbf4
6 changed files with 139 additions and 1 deletions
@@ -25,6 +25,16 @@ export function createInventoryItemRepository(db) {
.orderBy(asc(inventoryItems.createdAt));
},
async listBySellerId(sellerId) {
return db
.select({ item: inventoryItems })
.from(inventoryItems)
.innerJoin(products, eq(products.id, inventoryItems.productId))
.where(eq(products.sellerId, sellerId))
.orderBy(asc(inventoryItems.createdAt))
.then((rows) => rows.map(({ item }) => item));
},
async searchPublic({ page = 1, limit = 20 } = {}) {
const conditions = [
eq(inventoryItems.status, 'ACTIVE'),
@@ -54,4 +54,8 @@ export async function registerAdminInventoryRoutes(app, options) {
return reply.code(201).send({ data: toAdminInventoryItemDto(inventoryItem) });
});
app.get('/inventory', async (request) => ({
data: (await inventoryItemService.listBySellerId(request.admin.sellerId)).map(toAdminInventoryItemDto),
}));
}
@@ -7,6 +7,10 @@ export function createInventoryItemService({
productRepository,
}) {
return {
async listBySellerId(sellerId) {
return inventoryItemRepository.listBySellerId(sellerId);
},
async create(input) {
const inventoryItem = createInventoryItem(input);
const [product, condition] = await Promise.all([