oak-general-business/src/entities/ExtraFile.ts

143 lines
4.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { String, Int, Text, Float, Boolean } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { EntityDesc } from 'oak-domain/lib/types/EntityDesc';
import { Schema as Application } from './Application';
import { CosOrigin } from '../types/Config';
type ChunkInfo = {
chunkSize: number;
partCount: number;
uploadId: string;
merged: boolean;
parts: Array<string>; // 记录etag
}
export interface Schema extends EntityShape {
origin: CosOrigin;
type: 'image' | 'video' | 'audio' | 'file';
bucket?: String<32>; // 七牛、腾讯、阿里、天翼其它cos可忽略
objectId?: String<64>; // 七牛、腾讯、阿里、天翼其它cos可忽略
tag1?: String<32>;
tag2?: String<32>;
filename: String<256>;
md5?: Text;
entity: String<32>;
entityId: String<64>;
extra1?: Text;
extra2?: Object;
extension?: String<16>;
size?: Int<8>;
sort?: Float<22, 10>;
fileType?: String<128>;
isBridge?: Boolean;
uploadState: 'success' | 'failed' | 'uploading';
uploadMeta?: Object;
application: Application;
// 分片续传配置
enableChunkedUpload?: Boolean;
chunkInfo?: ChunkInfo;
};
export const entityDesc: EntityDesc<
Schema,
'',
'',
{
origin: Schema['origin'];
type: Schema['type'];
uploadState: Schema['uploadState'];
}
> = {
locales: {
zh_CN: {
name: '文件',
attr: {
origin: '源',
type: '类型',
bucket: '桶',
objectId: '对象编号',
tag1: '标签一',
tag2: '标签二',
filename: '文件名',
md5: 'md5',
entity: '关联对象',
entityId: '关联对象id',
extra1: '额外信息',
extra2: '非结构化额外信息',
extension: '后缀名',
size: '文件大小',
sort: '排序',
fileType: '文件类型',
isBridge: '是否桥接访问',
uploadState: '上传状态',
uploadMeta: '上传需要的metadata',
application: '来源应用',
enableChunkedUpload: '是否启用分片续传',
chunkInfo: '分片续传信息',
},
v: {
origin: {
qiniu: '七牛云',
ctyun: '天翼云',
wechat: '微信',
aliyun: '阿里云',
tencent: '腾讯云',
local: '本地',
unknown: '未知',
s3: 'S3',
},
type: {
image: '图像',
video: '视频',
audio: '音频',
file: '文件',
},
uploadState: {
success: '上传成功',
failed: '上传失败',
uploading: '上传中',
},
},
},
},
indexes: [
{
name: 'objectId_deleteAt',
attributes: [
{
name: 'objectId',
},
{
name: '$$deleteAt$$',
},
],
},
],
style: {
color: {
origin: {
s3: '#FFA500',
qiniu: '#37caff',
wechat: '#2aae67',
ctyun: '#ff0000',
aliyun: '#1677ff',
tencent: '#0052d9',
local: '#A9A9A9',
unknown: '#A9A9A9',
},
type: {
image: '#0000FF',
video: '#008000',
audio: '#F5DEB3',
file: '#EEE8AA',
},
uploadState: {
success: '#008000',
failed: '#FF0000',
uploading: '#0000FF',
},
},
},
};