174 lines
4.1 KiB
TypeScript
174 lines
4.1 KiB
TypeScript
import { ApiProperty } from '@midwayjs/swagger';
|
|
import { Rule, RuleType } from '@midwayjs/validate';
|
|
import { Stock } from '../entity/stock.entity';
|
|
import {
|
|
PurchaseOrderStatus,
|
|
StockRecordOperationType,
|
|
} from '../enums/base.enum';
|
|
import { PurchaseOrderItem } from '../entity/purchase_order_item.entity';
|
|
import { PurchaseOrder } from '../entity/purchase_order.entity';
|
|
import { StockRecord } from '../entity/stock_record.entity';
|
|
|
|
export class QueryStockDTO {
|
|
@ApiProperty({ example: '1', description: '页码' })
|
|
@Rule(RuleType.number())
|
|
current: number; // 页码
|
|
|
|
@ApiProperty({ example: '10', description: '每页大小' })
|
|
@Rule(RuleType.number())
|
|
pageSize: number; // 每页大小
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
productName: string;
|
|
}
|
|
export class QueryPointDTO {
|
|
@ApiProperty({ example: '1', description: '页码' })
|
|
@Rule(RuleType.number())
|
|
current: number; // 页码
|
|
|
|
@ApiProperty({ example: '10', description: '每页大小' })
|
|
@Rule(RuleType.number())
|
|
pageSize: number; // 每页大小
|
|
}
|
|
export class QueryStockRecordDTO {
|
|
@ApiProperty({ example: '1', description: '页码' })
|
|
@Rule(RuleType.number())
|
|
current: number; // 页码
|
|
|
|
@ApiProperty({ example: '10', description: '每页大小' })
|
|
@Rule(RuleType.number())
|
|
pageSize: number; // 每页大小
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
stockPointId: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
productSku: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
productName: string;
|
|
}
|
|
export class QueryPurchaseOrderDTO {
|
|
@ApiProperty({ example: '1', description: '页码' })
|
|
@Rule(RuleType.number())
|
|
current: number; // 页码
|
|
|
|
@ApiProperty({ example: '10', description: '每页大小' })
|
|
@Rule(RuleType.number())
|
|
pageSize: number; // 每页大小
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
orderNumber?: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
stockPointId?: number;
|
|
}
|
|
export class StockDTO extends Stock {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
productName: string;
|
|
|
|
@ApiProperty({
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'number' },
|
|
name: { type: 'string' },
|
|
quantity: { type: 'number' },
|
|
},
|
|
isArray: true,
|
|
})
|
|
@Rule(RuleType.array())
|
|
stockPoint: Array<{
|
|
id: number;
|
|
name: string;
|
|
quantity: number;
|
|
}>;
|
|
}
|
|
export class StockRecordDTO extends StockRecord {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
productName: string;
|
|
}
|
|
export class PurchaseOrderDTO extends PurchaseOrder {
|
|
@ApiProperty({ type: PurchaseOrderItem, isArray: true })
|
|
@Rule(RuleType.array())
|
|
items: PurchaseOrderItem[];
|
|
}
|
|
|
|
export class UpdateStockDTO {
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
stockPointId: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
productSku: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
quantityChange: number;
|
|
|
|
@ApiProperty({ type: 'enum', enum: StockRecordOperationType })
|
|
@Rule(RuleType.string().valid(...Object.values(StockRecordOperationType)))
|
|
operationType: StockRecordOperationType;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
operatorId: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string().allow(''))
|
|
note: string;
|
|
}
|
|
|
|
export class CreateStockPointDTO {
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
name: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
location: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
contactPerson: string;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string())
|
|
contactPhone: string;
|
|
}
|
|
export class UpdateStockPointDTO extends CreateStockPointDTO {}
|
|
|
|
export class CreatePurchaseOrderDTO {
|
|
@ApiProperty()
|
|
@Rule(RuleType.number())
|
|
stockPointId: number;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.date())
|
|
expectedArrivalTime: Date;
|
|
|
|
@ApiProperty({ type: 'enum', enum: PurchaseOrderStatus })
|
|
@Rule(RuleType.string().valid(...Object.values(PurchaseOrderStatus)))
|
|
status: PurchaseOrderStatus;
|
|
|
|
@ApiProperty()
|
|
@Rule(RuleType.string().allow(''))
|
|
note?: string;
|
|
|
|
@ApiProperty({
|
|
type: PurchaseOrderItem,
|
|
isArray: true,
|
|
})
|
|
@Rule(RuleType.array())
|
|
items: PurchaseOrderItem[];
|
|
}
|
|
export class UpdatePurchaseOrderDTO extends CreatePurchaseOrderDTO {}
|