feat: 积分商城-供应商-对账-发票4
This commit is contained in:
@@ -40,7 +40,19 @@ export const uploadController = withErrorBoundary(async (request: Request, _cont
|
||||
return toHttpResponse(await minioUploadService.upload(await readJson<UploadInput>(request)))
|
||||
})
|
||||
|
||||
export const fileController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['GET'])
|
||||
if (methodResponse) return methodResponse
|
||||
const result = await minioUploadService.imageUrl(new URL(request.url).searchParams.get('fid')?.trim() || '')
|
||||
if (!result.success) return toHttpResponse(result)
|
||||
return new Response(null, { status: 302, headers: { Location: result.data.url, 'Cache-Control': 'no-store' } })
|
||||
})
|
||||
|
||||
export const uploadPreviewController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
if (request.method === 'GET') {
|
||||
const fid = new URL(request.url).searchParams.get('fid') || ''
|
||||
return new Response(null, { status: 302, headers: { Location: `/api/file?fid=${encodeURIComponent(fid)}`, 'Cache-Control': 'no-store' } })
|
||||
}
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { withErrorBoundary } from '../utils/handler.js'
|
||||
import { guardMethod } from '../utils/method.js'
|
||||
import { getBearerToken, readJson } from '../utils/request.js'
|
||||
import { adminAuthService } from '../services/admin-auth.service.js'
|
||||
import { serviceFail } from '../types/service-result.js'
|
||||
import { merchantInvoiceService, type MerchantInvoiceListInput, type MerchantInvoiceFileInput } from '../services/merchant-invoice.service.js'
|
||||
import { toHttpResponse } from './controller-response.js'
|
||||
|
||||
export const merchantInvoiceListController = withErrorBoundary(async request => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
if (!await adminAuthService.findSession(getBearerToken(request))) return toHttpResponse(serviceFail('登录已失效,请重新登录', 401, 'UNAUTHORIZED'))
|
||||
return toHttpResponse(await merchantInvoiceService.list(await readJson<MerchantInvoiceListInput>(request)))
|
||||
})
|
||||
|
||||
export const merchantInvoiceFileController = withErrorBoundary(async request => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
if (!await adminAuthService.findSession(getBearerToken(request))) return toHttpResponse(serviceFail('登录已失效,请重新登录', 401, 'UNAUTHORIZED'))
|
||||
return toHttpResponse(await merchantInvoiceService.file(await readJson<MerchantInvoiceFileInput>(request)))
|
||||
})
|
||||
@@ -31,8 +31,8 @@ export const merchantProductListController = withErrorBoundary(async (request: R
|
||||
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()))
|
||||
const body = await readJson<{ keyword?: string; categoryId?: string; pageNumber?: number; pageSize?: number }>(request)
|
||||
return toHttpResponse(await productService.listManageProducts(String(body.keyword || '').trim(), String(body.categoryId || '').trim(), body.pageNumber, body.pageSize))
|
||||
})
|
||||
|
||||
export const merchantProductSaveController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
|
||||
Reference in New Issue
Block a user