门店开通流程
This commit is contained in:
@@ -6,7 +6,7 @@ import type {
|
||||
OssUploadTokenInput,
|
||||
OssUploadTokenResult,
|
||||
} from './oss.interface';
|
||||
import { buildOssObjectKey } from './oss.key.util';
|
||||
import { buildOssObjectKey, resolveOssUploadDir } from './oss.key.util';
|
||||
import { createAliyunOssClient, resolveOssUploadHost } from './oss.aliyun.client';
|
||||
|
||||
const DEFAULT_EXPIRE_SECONDS = 15 * 60;
|
||||
@@ -64,13 +64,14 @@ export class OssAliyunProvider implements IOssProvider {
|
||||
const ossKey = buildOssObjectKey(this.uploadPrefix, dto.bizType, dto.fileName);
|
||||
const expireAt = new Date(Date.now() + this.expireSeconds * 1000);
|
||||
const host = resolveOssUploadHost(this.bucket, this.region);
|
||||
const keyPrefix = resolveOssUploadDir(this.uploadPrefix, dto.bizType);
|
||||
|
||||
const policy = {
|
||||
expiration: expireAt.toISOString(),
|
||||
conditions: [
|
||||
['content-length-range', 0, this.maxUploadBytes],
|
||||
['eq', '$bucket', this.bucket],
|
||||
['starts-with', '$key', `${this.uploadPrefix}/${dto.bizType.toLowerCase()}/`],
|
||||
['starts-with', '$key', keyPrefix],
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ export class WechatApiProvider implements IWechatProvider {
|
||||
timestamp,
|
||||
nonceStr,
|
||||
signature,
|
||||
jsApiList: ['getLocation', 'scanQRCode', 'chooseWXPay'],
|
||||
jsApiList: ['getLocation', 'scanQRCode', 'chooseWXPay', 'chooseImage', 'getLocalImgData'],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user