device.dto.ts
3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import { IsString, IsNumber, IsNotEmpty, MaxLength, IsMobilePhone, IsOptional, isNotEmpty } from 'class-validator'
import { ApiProperty } from '@nestjs/swagger'
import { BaseDto } from './base.dto'
export class DeviceQueryDto extends BaseDto {
@ApiProperty({
type: String,
description: '设备SN',
required: false,
default: ''
})
sn?: string
@ApiProperty({
type: String,
description: '设备用户',
required: false,
default: ''
})
user?: string
@ApiProperty({
type: String,
description: '使用者手机号',
required: false,
default: ''
})
mobile?: string
}
export class DeviceFindOneDto {
@ApiProperty({
type: String,
description: '设备用户',
required: true,
default: ''
})
@IsNotEmpty({ message: '用户不能为空' })
user: string
@ApiProperty({
type: String,
description: '使用者手机号',
required: true,
default: ''
})
@IsNotEmpty({ message: '手机号不能为空' })
mobile: string
}
export class AddDeviceDto {
@ApiProperty({
type: String,
description: '设备SN',
required: true,
default: ''
})
@MaxLength(20, { message: '设备SN不能超过20个字符' })
@IsNotEmpty({ message: '设备SN不能为空' })
sn: string
}
/**
* model device_info {
id Int @id @default(autoincrement())
device_id Int @unique(map: "device_id") @default(0)
user String? @db.VarChar(20)
status Int? @db.TinyInt
last_log_upload_time String? @db.VarChar(30)
last_log_remove_time String? @db.VarChar(30)
created_at DateTime @default(now()) @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
mobile String? @db.VarChar(20)
merchant_name String? @db.VarChar(50)
log_config log_config?
}
*/
export class AddDeviceInfoDto {
@ApiProperty({
type: Number,
description: '设备信息ID',
default: 0
})
id: number
@ApiProperty({
type: Number,
description: '设备ID',
default: 0
})
@IsNumber({}, { message: '设备ID必须是数字' })
@IsNotEmpty({ message: '设备ID不能为空' })
device_id: number
@ApiProperty({
type: String,
description: '设备用户',
default: ''
})
user: string
@ApiProperty({
type: Number,
description: '设备状态',
default: 0
})
status: number
@ApiProperty({
type: String,
description: '最后一次上传日志的时间',
default: ''
})
last_log_upload_time: string
@ApiProperty({
type: String,
description: '最后一次移除日志的时间',
default: ''
})
last_log_remove_time: string
@ApiProperty({
type: Number,
description: '创建时间',
default: ''
})
created_at: Date
@ApiProperty({
type: Date,
description: '更新时间',
default: ''
})
updated_at: Date
@IsMobilePhone('zh-CN', {}, { message: '手机号格式不正确' })
@IsOptional()
@ApiProperty({
type: String,
description: '使用者手机号',
default: ''
})
mobile: string
@ApiProperty({
type: String,
description: '使用者商户名称',
default: ''
})
merchant_name: string
@ApiProperty({
type: Object,
description: '日志配置',
default: {}
})
log_config: {}
}