feat: 积分商城-供应商
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Context } from '../utils/handler.js'
|
||||
import { guardMethod } from '../utils/method.js'
|
||||
import { readJson } from '../utils/request.js'
|
||||
import { withErrorBoundary } from '../utils/handler.js'
|
||||
import { productService } from '../services/product.service.js'
|
||||
import { toHttpResponse } from './controller-response.js'
|
||||
@@ -25,3 +26,28 @@ export const productDetailController = withErrorBoundary(async (request: Request
|
||||
|
||||
return toHttpResponse(await productService.getProductDetail(id, sku))
|
||||
})
|
||||
|
||||
export const merchantProductListController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<{ keyword?: string; categoryId?: string }>(request)
|
||||
return toHttpResponse(await productService.listManageProducts(String(body.keyword || '').trim(), String(body.categoryId || '').trim()))
|
||||
})
|
||||
|
||||
export const merchantProductSaveController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await productService.saveManageProduct(
|
||||
await readJson<Parameters<typeof productService.saveManageProduct>[0]>(request)
|
||||
))
|
||||
})
|
||||
|
||||
export const merchantProductDeleteController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<{ id?: number }>(request)
|
||||
return toHttpResponse(await productService.deleteManageProduct(Number(body.id || 0)))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user