门店开通流程
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
/** 门店资源上传目录(OSS object key 前缀) */
|
||||
const STORE_UPLOAD_DIRS: Record<string, string> = {
|
||||
STORE_TITLE: 'store/title',
|
||||
STORE_ENV: 'store/env',
|
||||
STORE_CONTRACT: 'store/contract',
|
||||
};
|
||||
|
||||
export function resolveOssUploadDir(uploadPrefix: string, bizType: string): string {
|
||||
const storeDir = STORE_UPLOAD_DIRS[bizType];
|
||||
if (storeDir) return `${storeDir}/`;
|
||||
return `${uploadPrefix.replace(/\/$/, '')}/${bizType.toLowerCase()}/`;
|
||||
}
|
||||
|
||||
export function buildOssObjectKey(uploadPrefix: string, bizType: string, fileName: string): string {
|
||||
const ext = fileName.includes('.') ? fileName.split('.').pop() : 'bin';
|
||||
const dir = `${uploadPrefix.replace(/\/$/, '')}/${bizType.toLowerCase()}/`;
|
||||
const dir = resolveOssUploadDir(uploadPrefix, bizType);
|
||||
return `${dir}${Date.now()}-${randomUUID().slice(0, 8)}.${ext}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user