forked from yoone/API
1
0
Fork 0
API/src/dto/site.dto.ts

120 lines
3.2 KiB
TypeScript

import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
export class SiteConfig {
@ApiProperty({ example: '1', description: '站点 ID' })
@Rule(RuleType.string())
id: string;
@ApiProperty({ description: '站点 URL' })
@Rule(RuleType.string())
apiUrl: string;
@ApiProperty({ description: '站点 rest key' })
@Rule(RuleType.string())
consumerKey: string;
@ApiProperty({ description: '站点 rest 秘钥' })
@Rule(RuleType.string())
consumerSecret: string;
@ApiProperty({ description: '站点名' })
@Rule(RuleType.string())
name: string;
@ApiProperty({ description: '描述' })
@Rule(RuleType.string().allow('').optional())
description?: string;
@ApiProperty({ description: '平台类型', enum: ['woocommerce', 'shopyy'] })
@Rule(RuleType.string().valid('woocommerce', 'shopyy'))
type: string;
@ApiProperty({ description: 'SKU 前缀' })
@Rule(RuleType.string())
skuPrefix: string;
}
export class CreateSiteDTO {
@Rule(RuleType.string().optional())
apiUrl?: string;
@Rule(RuleType.string().optional())
websiteUrl?: string;
@Rule(RuleType.string().optional())
consumerKey?: string;
@Rule(RuleType.string().optional())
consumerSecret?: string;
@Rule(RuleType.string().optional())
token?: string;
@Rule(RuleType.string())
name: string;
@Rule(RuleType.string().allow('').optional())
description?: string;
@Rule(RuleType.string().valid('woocommerce', 'shopyy').optional())
type?: string;
@Rule(RuleType.string().optional())
skuPrefix?: string;
// 区域
@ApiProperty({ description: '区域' })
@Rule(RuleType.array().items(RuleType.string()).optional())
areas?: string[];
// 绑定仓库
@ApiProperty({ description: '绑定仓库ID列表' })
@Rule(RuleType.array().items(RuleType.number()).optional())
stockPointIds?: number[];
}
export class UpdateSiteDTO {
@Rule(RuleType.string().optional())
apiUrl?: string;
@Rule(RuleType.string().optional())
consumerKey?: string;
@Rule(RuleType.string().optional())
consumerSecret?: string;
@Rule(RuleType.string().optional())
token?: string;
@Rule(RuleType.string().optional())
name?: string;
@Rule(RuleType.string().allow('').optional())
description?: string;
@Rule(RuleType.boolean().optional())
isDisabled?: boolean;
@Rule(RuleType.string().valid('woocommerce', 'shopyy').optional())
type?: string;
@Rule(RuleType.string().optional())
skuPrefix?: string;
// 区域
@ApiProperty({ description: '区域' })
@Rule(RuleType.array().items(RuleType.string()).optional())
areas?: string[];
// 绑定仓库
@ApiProperty({ description: '绑定仓库ID列表' })
@Rule(RuleType.array().items(RuleType.number()).optional())
stockPointIds?: number[];
@ApiProperty({ description: '站点网站URL' })
@Rule(RuleType.string().optional())
websiteUrl?: string;
}
export class QuerySiteDTO {
@Rule(RuleType.number().optional())
current?: number;
@Rule(RuleType.number().optional())
pageSize?: number;
@Rule(RuleType.string().optional())
keyword?: string;
@Rule(RuleType.boolean().optional())
isDisabled?: boolean;
@Rule(RuleType.string().optional())
ids?: string;
}
export class DisableSiteDTO {
@Rule(RuleType.boolean())
disabled: boolean;
}