Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
node
/
app-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d01edbac
authored
Sep 27, 2024
by
yixinjj
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改表结构
1 parent
03473b33
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
80 additions
and
145 deletions
prisma/schema.prisma
src/modules/config/config.service.ts
src/modules/device/device.service.ts
src/modules/file/file.service.ts
src/typings/common.d.ts
src/typings/config.d.ts
src/typings/device.d.ts
src/typings/device.status.d.ts
src/typings/relations.d.ts
prisma/schema.prisma
View file @
d01edba
...
@@ -8,40 +8,37 @@ datasource db {
...
@@ -8,40 +8,37 @@ datasource db {
}
}
model device {
model device {
id Int
@id
@default(autoincrement())
id Int
@id @unique(map: "id")
@default(autoincrement())
sn String @unique @db.VarChar(20)
sn String @unique @db.VarChar(20)
created_at DateTime @default(dbgenerated("(now())")) @db.Timestamp(0)
created_at DateTime @default(dbgenerated("(now())")) @db.Timestamp(0)
device_info device_info?
device_info device_info?
device_status device_status?
device_status device_status?
fields field_relation[]
logs file[]
logs file[]
log_config log_config?
log_config log_config?
}
}
model device_info {
model device_info {
id Int @id @default(autoincrement())
device_id Int @id @unique(map: "device_id") @default(0)
device_id Int @unique @default(0)
user String? @db.VarChar(20)
user String? @db.VarChar(20)
created_at DateTime @default(now()) @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
mobile String? @db.VarChar(20)
mobile String? @db.VarChar(20)
merchant_name String? @db.VarChar(50)
merchant_name String? @db.VarChar(50)
last_login_time DateTime? @db.Timestamp(0)
created_at DateTime @default(now()) @db.Timestamp(0)
last_offline_time DateTime? @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
last_log_remove_time DateTime? @db.Timestamp(0)
last_log_upload_time DateTime? @db.Timestamp(0)
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_device_info_device")
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_device_info_device")
device_status device_status?
logs file[]
log_config log_config?
}
}
model device_status {
model device_status {
device_id
Int @id
device_id
Int @id @unique(map: "device_id")
status Int @default(0) @db.TinyInt
status Int @default(0) @db.TinyInt
last_login_time DateTime? @db.Timestamp(0)
last_offline_time DateTime? @db.Timestamp(0)
last_log_upload_time DateTime? @db.Timestamp(0)
last_log_remove_time DateTime? @db.Timestamp(0)
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK__device")
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK__device")
device_info device_info @relation(fields: [device_id], references: [device_id], onDelete: NoAction, onUpdate: NoAction, map: "FK__device_info")
}
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model file {
model file {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
device_id Int @default(0)
device_id Int @default(0)
...
@@ -53,38 +50,35 @@ model file {
...
@@ -53,38 +50,35 @@ model file {
created_at DateTime @default(now()) @db.Timestamp(0)
created_at DateTime @default(now()) @db.Timestamp(0)
type String @default("other") @db.VarChar(10)
type String @default("other") @db.VarChar(10)
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_device")
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_device")
device_info device_info @relation(fields: [device_id], references: [device_id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_device_info")
@@index([device_id], map: "FK_
log_device_info
")
@@index([device_id], map: "FK_
file_device
")
}
}
model log_config {
model log_config {
id Int @id @default(autoincrement())
device_id Int @id @unique(map: "device_id") @default(0)
device_id Int @unique @default(0)
log_saved_days Int? @default(7) @db.TinyInt
log_saved_days Int? @default(7) @db.TinyInt
created_at DateTime @default(now()) @db.Timestamp(0)
created_at DateTime @default(now()) @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
fields config_field_relation[]
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_config_device")
device device @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_config_device")
device_info device_info @relation(fields: [device_id], references: [device_id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_config_device_info")
}
model config_field_relation {
id Int @id @default(autoincrement())
config_id Int @default(0)
field_id Int @default(0)
log_config log_config @relation(fields: [config_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_config_userfield_relation_log_config")
field field @relation(fields: [field_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_log_config_userfield_relation_log_user_field")
@@index([config_id], map: "FK_log_config_userfield_relation_log_config")
@@index([field_id], map: "FK_log_config_userfield_relation_log_user_field")
}
}
model field {
model field {
id
Int @id
@default(autoincrement())
id
Int @id @unique(map: "id")
@default(autoincrement())
name String @db.VarChar(20)
name String @db.VarChar(20)
type String @default("user") @db.VarChar(10)
created_at DateTime @default(now()) @db.Timestamp(0)
created_at DateTime @default(now()) @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
updated_at DateTime @default(now()) @db.Timestamp(0)
type String @default("user") @db.VarChar(10)
fields field_relation[]
config_field_relation config_field_relation[]
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model field_relation {
id Int @id @default(autoincrement())
device_id Int?
field_id Int?
device device? @relation(fields: [device_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK__field_relation_device")
field field? @relation(fields: [field_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK__field_relation_field")
@@index([device_id], map: "FK__field_relation_device")
@@index([field_id], map: "FK__field_relation_field")
}
}
src/modules/config/config.service.ts
View file @
d01edba
...
@@ -7,7 +7,7 @@ export class ConfigService {
...
@@ -7,7 +7,7 @@ export class ConfigService {
@
Inject
(
PrismaService
)
@
Inject
(
PrismaService
)
private
readonly
prisma
:
PrismaService
// private connection: Connection,
private
readonly
prisma
:
PrismaService
// private connection: Connection,
)
{}
)
{}
async
findAll
({
device_id
,
skip
,
take
}:
ConfigTypes
.
LogConfigQuery
):
Promise
<
CommonTypes
.
IResData
<
ConfigTypes
.
LogConfigRes
ponse
[]
>>
{
async
findAll
({
device_id
,
skip
,
take
}:
ConfigTypes
.
LogConfigQuery
):
Promise
<
CommonTypes
.
IResData
<
ConfigTypes
.
LogConfigRes
ult
[]
>>
{
const
where
:
any
=
{
const
where
:
any
=
{
device_id
device_id
}
}
...
@@ -15,63 +15,21 @@ export class ConfigService {
...
@@ -15,63 +15,21 @@ export class ConfigService {
skip
,
skip
,
take
,
take
,
select
:
{
select
:
{
id
:
true
,
device_id
:
true
,
device_id
:
true
,
log_saved_days
:
true
,
log_saved_days
:
true
fields
:
{
select
:
{
field
:
{
select
:
{
name
:
true
,
type
:
true
}
}
}
}
},
},
where
where
})
})
const
data
:
ConfigTypes
.
LogConfigResponse
[]
=
result
.
map
(
item
=>
{
return
{
id
:
item
.
id
,
device_id
:
item
.
device_id
,
log_saved_days
:
item
.
log_saved_days
,
fields
:
item
.
fields
.
map
(
item
=>
({
name
:
item
.
field
.
name
,
type
:
item
.
field
.
type
}))
}
})
const
total
=
await
this
.
prisma
.
log_config
.
count
({
const
total
=
await
this
.
prisma
.
log_config
.
count
({
where
where
})
})
const
resBody
:
CommonTypes
.
IResData
<
ConfigTypes
.
LogConfigRes
ponse
[]
>
=
{
total
,
data
,
code
:
RESPONSE_CODE
.
SUCCESS
,
message
:
'查询成功'
}
const
resBody
:
CommonTypes
.
IResData
<
ConfigTypes
.
LogConfigRes
ult
[]
>
=
{
total
,
data
:
result
,
code
:
RESPONSE_CODE
.
SUCCESS
,
message
:
'查询成功'
}
return
resBody
return
resBody
}
}
async
addConfig
(
config
:
ConfigTypes
.
LogConfigAdd
):
Promise
<
CommonTypes
.
IResData
>
{
async
addConfig
(
config
:
ConfigTypes
.
ILogConfig
):
Promise
<
CommonTypes
.
IResData
>
{
const
{
user_fields
,
...
data
}
=
config
const
now
=
new
Date
()
let
config_id
:
number
=
0
await
this
.
prisma
.
log_config
.
upsert
({
where
:
{
device_id
:
config
.
device_id
},
update
:
{
...
config
,
updated_at
:
now
},
create
:
{
...
config
,
created_at
:
now
,
updated_at
:
now
}
})
await
this
.
prisma
.
$transaction
(
async
prisma
=>
{
const
date
=
new
Date
()
const
{
id
}
=
(
await
prisma
.
log_config
.
findUnique
({
where
:
{
device_id
:
data
.
device_id
},
select
:
{
id
:
true
}
}))
||
{}
config
.
updated_at
=
date
if
(
id
)
{
config_id
=
id
await
prisma
.
log_config
.
update
({
where
:
{
device_id
:
data
.
device_id
},
data
})
await
prisma
.
config_field_relation
.
deleteMany
({
where
:
{
config_id
:
id
}
})
}
else
{
config
.
created_at
=
date
const
{
id
}
=
await
prisma
.
log_config
.
create
({
data
,
select
:
{
id
:
true
}
})
config_id
=
id
}
const
relations
:
RelationsTypes
.
LogConfigUserFieldsRel
[]
=
user_fields
.
map
((
ufid
:
number
)
=>
{
return
{
config_id
,
field_id
:
ufid
}
})
await
prisma
.
config_field_relation
.
createMany
({
data
:
relations
,
skipDuplicates
:
true
})
})
return
{
code
:
RESPONSE_CODE
.
SUCCESS
,
message
:
'设备状态更新成功'
}
return
{
code
:
RESPONSE_CODE
.
SUCCESS
,
message
:
'设备状态更新成功'
}
}
}
}
}
src/modules/device/device.service.ts
View file @
d01edba
...
@@ -18,12 +18,11 @@ export class DeviceService implements OnModuleInit {
...
@@ -18,12 +18,11 @@ export class DeviceService implements OnModuleInit {
async
onModuleInit
()
{
async
onModuleInit
()
{
this
.
resetAllDeviceStatus
()
this
.
resetAllDeviceStatus
()
}
}
async
findAll
({
user
,
mobile
,
sn
,
skip
,
take
}:
DeviceTypes
.
IQueryDevices
):
Promise
<
CommonTypes
.
IResData
<
DeviceTypes
.
TDevice
InfoResult
[]
>>
{
async
findAll
({
user
,
mobile
,
sn
,
skip
,
take
}:
DeviceTypes
.
IQueryDevices
):
Promise
<
CommonTypes
.
IResData
<
DeviceTypes
.
TDevice
[]
>>
{
const
where
=
{
const
where
=
{
sn
:
{
sn
:
{
contains
:
sn
contains
:
sn
},
},
AND
:
{
device_info
:
{
device_info
:
{
mobile
:
{
mobile
:
{
contains
:
mobile
contains
:
mobile
...
@@ -33,7 +32,6 @@ export class DeviceService implements OnModuleInit {
...
@@ -33,7 +32,6 @@ export class DeviceService implements OnModuleInit {
}
}
}
}
}
}
}
const
result
:
DeviceTypes
.
IDeviceResult
[]
=
await
this
.
prisma
.
device
.
findMany
({
const
result
:
DeviceTypes
.
IDeviceResult
[]
=
await
this
.
prisma
.
device
.
findMany
({
skip
,
skip
,
take
,
take
,
...
@@ -44,14 +42,14 @@ export class DeviceService implements OnModuleInit {
...
@@ -44,14 +42,14 @@ export class DeviceService implements OnModuleInit {
select
:
{
select
:
{
user
:
true
,
user
:
true
,
mobile
:
true
,
mobile
:
true
,
merchant_name
:
true
,
merchant_name
:
true
last_log_remove_time
:
true
,
}
last_log_upload_time
:
true
,
},
last_login_time
:
true
,
last_offline_time
:
true
,
log_config
:
{
log_config
:
{
select
:
{
select
:
{
log_saved_days
:
true
,
log_saved_days
:
true
}
},
fields
:
{
fields
:
{
select
:
{
select
:
{
field
:
{
field
:
{
...
@@ -61,13 +59,9 @@ export class DeviceService implements OnModuleInit {
...
@@ -61,13 +59,9 @@ export class DeviceService implements OnModuleInit {
}
}
}
}
}
}
}
}
},
},
device_status
:
{
device_status
:
{
select
:
{
status
:
true
}
select
:
{
status
:
true
,
last_log_remove_time
:
true
,
last_log_upload_time
:
true
,
last_login_time
:
true
,
last_offline_time
:
true
}
}
}
}
}
},
},
where
where
...
@@ -75,35 +69,35 @@ export class DeviceService implements OnModuleInit {
...
@@ -75,35 +69,35 @@ export class DeviceService implements OnModuleInit {
const
total
:
number
=
await
this
.
prisma
.
device
.
count
({
const
total
:
number
=
await
this
.
prisma
.
device
.
count
({
where
where
})
})
const
data
:
DeviceTypes
.
TDevice
InfoResult
[]
=
result
.
reduce
((
pre
:
DeviceTypes
.
TDeviceInfoResult
[],
cur
:
DeviceTypes
.
IDeviceResult
)
=>
{
const
data
:
DeviceTypes
.
TDevice
[]
=
result
.
reduce
((
pre
:
DeviceTypes
.
TDevice
[],
cur
:
DeviceTypes
.
IDeviceResult
)
=>
{
pre
.
push
({
pre
.
push
({
id
:
cur
.
id
,
id
:
cur
.
id
,
sn
:
cur
.
sn
,
sn
:
cur
.
sn
,
user
:
cur
.
device_info
?.
user
,
user
:
cur
.
device_info
?.
user
,
mobile
:
cur
.
device_info
?.
mobile
,
mobile
:
cur
.
device_info
?.
mobile
,
status
:
cur
.
device_
info
?.
device_
status
?.
status
,
status
:
cur
.
device_status
?.
status
,
merchant_name
:
cur
.
device_info
?.
merchant_name
,
merchant_name
:
cur
.
device_info
?.
merchant_name
,
last_log_remove_time
:
cur
.
device_
info
?.
last_log_remove_time
,
last_log_remove_time
:
cur
.
device_
status
?.
last_log_remove_time
,
last_log_upload_time
:
cur
.
device_
info
?.
last_log_upload_time
,
last_log_upload_time
:
cur
.
device_
status
?.
last_log_upload_time
,
last_login_time
:
cur
.
device_
info
?.
last_login_time
,
last_login_time
:
cur
.
device_
status
?.
last_login_time
,
last_offline_time
:
cur
.
device_
info
?.
last_offline_time
,
last_offline_time
:
cur
.
device_
status
?.
last_offline_time
,
log_saved_days
:
cur
.
device_info
?.
log_config
?.
log_saved_days
,
log_saved_days
:
cur
?.
log_config
?.
log_saved_days
,
fields
:
cur
.
device_info
?.
log_config
?.
fields
?.
map
((
item
:
DeviceTypes
.
IFields
)
=>
({
name
:
item
.
field
.
name
,
type
:
item
.
field
.
type
}))
fields
:
cur
?.
fields
?.
map
((
item
:
DeviceTypes
.
IFields
)
=>
({
name
:
item
.
field
.
name
,
type
:
item
.
field
.
type
}))
})
})
return
pre
return
pre
},
[])
},
[])
const
resBody
:
CommonTypes
.
IResData
<
DeviceTypes
.
TDevice
InfoResult
[]
>
=
{
total
,
data
}
const
resBody
:
CommonTypes
.
IResData
<
DeviceTypes
.
TDevice
[]
>
=
{
total
,
data
}
return
resBody
return
resBody
}
}
async
findOne
({
user
,
mobile
}:
Pick
<
CommonTypes
.
IUser
,
'mobile'
|
'user'
>
):
Promise
<
CommonTypes
.
IResData
<
DeviceTypes
.
TOneDeviceInfo
>>
{
async
findOne
({
user
,
mobile
}:
Pick
<
CommonTypes
.
IUser
,
'mobile'
|
'user'
>
):
Promise
<
CommonTypes
.
IResData
<
DeviceTypes
.
TOneDeviceInfo
>>
{
const
deviceInfo
:
DeviceTypes
.
TOneDeviceInfo
=
await
this
.
prisma
.
device_info
.
findFirstOrThrow
({
const
deviceInfo
:
DeviceTypes
.
TOneDeviceInfo
=
await
this
.
prisma
.
device_info
.
findFirstOrThrow
({
where
:
{
user
,
mobile
}
where
:
{
user
,
mobile
}
})
})
return
{
code
:
RESPONSE_CODE
.
SUCCESS
,
data
:
deviceInfo
}
return
{
code
:
RESPONSE_CODE
.
SUCCESS
,
data
:
deviceInfo
}
}
}
async
addDevice
(
device
:
Omit
<
DeviceTypes
.
TDevice
,
'id'
>
):
Promise
<
CommonTypes
.
IResData
>
{
async
addDevice
(
device
:
CommonTypes
.
ISn
):
Promise
<
CommonTypes
.
IResData
>
{
await
this
.
prisma
.
$transaction
(
async
prisma
=>
{
await
this
.
prisma
.
$transaction
(
async
prisma
=>
{
const
{
id
}
=
await
prisma
.
device
.
create
({
data
:
device
,
select
:
{
id
:
true
}
})
const
{
id
}
=
await
prisma
.
device
.
create
({
data
:
device
,
select
:
{
id
:
true
}
})
// await this.addDeviceInfo({device_id:id})
// await this.addDeviceInfo({device_id:id})
...
@@ -163,12 +157,12 @@ export class DeviceService implements OnModuleInit {
...
@@ -163,12 +157,12 @@ export class DeviceService implements OnModuleInit {
const
{
id
}
=
await
prisma
.
device
.
create
({
data
:
{
sn
:
el
.
设备编号
},
select
:
{
id
:
true
}
})
const
{
id
}
=
await
prisma
.
device
.
create
({
data
:
{
sn
:
el
.
设备编号
},
select
:
{
id
:
true
}
})
await
prisma
.
device_info
.
create
({
data
:
{
device_id
:
id
,
mobile
:
el
.
手机号
,
merchant_name
:
el
.
最近使用人所在门店
||
''
,
user
:
el
.
保管人
,
created_at
:
new
Date
(),
updated_at
:
new
Date
()
}
})
await
prisma
.
device_info
.
create
({
data
:
{
device_id
:
id
,
mobile
:
el
.
手机号
,
merchant_name
:
el
.
最近使用人所在门店
||
''
,
user
:
el
.
保管人
,
created_at
:
new
Date
(),
updated_at
:
new
Date
()
}
})
await
prisma
.
device_status
.
create
({
data
:
{
device_id
:
id
,
status
:
WsStatus
.
Offline
}
})
await
prisma
.
device_status
.
create
({
data
:
{
device_id
:
id
,
status
:
WsStatus
.
Offline
}
})
const
{
id
:
cfgid
}
=
await
prisma
.
log_config
.
create
({
data
:
{
device_id
:
id
,
log_saved_days
:
7
},
select
:
{
id
:
true
}
})
await
prisma
.
log_config
.
create
({
data
:
{
device_id
:
id
,
log_saved_days
:
7
}
})
await
prisma
.
config_
field_relation
.
createMany
({
await
prisma
.
field_relation
.
createMany
({
data
:
[
data
:
[
{
config_id
:
cfg
id
,
field_id
:
1
},
{
device_id
:
id
,
field_id
:
1
},
{
config_id
:
cfg
id
,
field_id
:
2
},
{
device_id
:
id
,
field_id
:
2
},
{
config_id
:
cfg
id
,
field_id
:
3
}
{
device_id
:
id
,
field_id
:
3
}
]
]
})
})
})
})
...
@@ -177,7 +171,7 @@ export class DeviceService implements OnModuleInit {
...
@@ -177,7 +171,7 @@ export class DeviceService implements OnModuleInit {
}
}
async
removeFilesTask
():
Promise
<
CommonTypes
.
IResData
>
{
async
removeFilesTask
():
Promise
<
CommonTypes
.
IResData
>
{
const
results
:
(
CommonTypes
.
IDeviceId
&
Pick
<
DeviceTypes
.
IDeviceInfo
,
'log_saved_days'
>
)[]
=
await
this
.
prisma
.
$queryRaw
<
(
CommonTypes
.
IDeviceId
&
Pick
<
DeviceTypes
.
IDeviceInfo
,
'log_saved_days'
>
)[]
>
`
const
results
:
(
CommonTypes
.
IDeviceId
&
Pick
<
ConfigTypes
.
ILogConfig
,
'log_saved_days'
>
)[]
=
await
this
.
prisma
.
$queryRaw
<
(
CommonTypes
.
IDeviceId
&
Pick
<
ConfigTypes
.
ILogConfig
,
'log_saved_days'
>
)[]
>
`
SELECT d.device_id, c.log_saved_days
SELECT d.device_id, c.log_saved_days
FROM device_info d
FROM device_info d
JOIN log_config c ON c.device_id = d.device_id
JOIN log_config c ON c.device_id = d.device_id
...
...
src/modules/file/file.service.ts
View file @
d01edba
...
@@ -64,7 +64,7 @@ export class FileService {
...
@@ -64,7 +64,7 @@ export class FileService {
}
else
{
}
else
{
await
prisma
.
file
.
create
({
data
:
file
})
await
prisma
.
file
.
create
({
data
:
file
})
}
}
await
prisma
.
device_
info
.
update
({
where
:
{
device_id
:
file
.
device_id
},
data
:
{
last_log_upload_time
:
created_at
}
})
await
prisma
.
device_
status
.
update
({
where
:
{
device_id
:
file
.
device_id
},
data
:
{
last_log_upload_time
:
created_at
}
})
})
})
return
{
code
:
RESPONSE_CODE
.
SUCCESS
,
message
:
'文件保存成功'
}
return
{
code
:
RESPONSE_CODE
.
SUCCESS
,
message
:
'文件保存成功'
}
}
}
...
...
src/typings/common.d.ts
View file @
d01edba
...
@@ -109,7 +109,7 @@ declare namespace CommonTypes {
...
@@ -109,7 +109,7 @@ declare namespace CommonTypes {
sn
:
string
sn
:
string
}
}
interface
IUser
extends
IDeviceId
,
ISn
{
interface
IUser
{
user
:
string
user
:
string
mobile
:
string
mobile
:
string
merchant_name
:
string
merchant_name
:
string
...
...
src/typings/config.d.ts
View file @
d01edba
...
@@ -11,13 +11,11 @@ model log_config {
...
@@ -11,13 +11,11 @@ model log_config {
}*/
}*/
declare
namespace
ConfigTypes
{
declare
namespace
ConfigTypes
{
interface
ILogConfig
extends
CommonTypes
.
I
Id
,
CommonTypes
.
I
DeviceId
,
CommonTypes
.
ITime
{
interface
ILogConfig
extends
CommonTypes
.
IDeviceId
,
CommonTypes
.
ITime
{
log_saved_days
:
number
log_saved_days
:
number
fields
:
DeviceTypes
.
IFields
[]
//
fields: DeviceTypes.IFields[]
}
}
type
LogConfigQuery
=
Pick
<
Partial
<
ILogConfig
>
,
'device_id'
>
&
CommonTypes
.
IQueryBase
type
LogConfigQuery
=
Pick
<
Partial
<
ILogConfig
>
,
'device_id'
>
&
CommonTypes
.
IQueryBase
type
LogConfigAdd
=
Omit
<
Partial
<
ILogConfig
>
,
'id'
|
'fields'
>
&
{
user_fields
:
number
[]
}
type
LogConfigResult
=
Partial
<
ILogConfig
>
type
LogConfigResult
=
Partial
<
ILogConfig
>
type
LogConfigResponse
=
Omit
<
LogConfigResult
,
'fields'
>
&
{
fields
:
CommonTypes
.
Optional
<
Partial
<
FieldTypes
.
IFiled
>
,
'name'
|
'type'
>
[]
}
type
LogConfigUpdate
=
CommonTypes
.
Optional
<
ILogConfig
,
'device_id'
>
type
LogConfigUpdate
=
CommonTypes
.
Optional
<
ILogConfig
,
'device_id'
>
}
}
src/typings/device.d.ts
View file @
d01edba
...
@@ -8,21 +8,9 @@ declare namespace DeviceTypes {
...
@@ -8,21 +8,9 @@ declare namespace DeviceTypes {
* @param skip - 可选,跳过的记录数量
* @param skip - 可选,跳过的记录数量
* @param take - 可选,获取的记录数量
* @param take - 可选,获取的记录数量
*/
*/
type
IQueryDevices
=
Partial
<
CommonTypes
.
IQueryBase
&
CommonTypes
.
ISn
&
IDeviceInfoData
>
type
IQueryDevices
=
Partial
<
CommonTypes
.
IQueryBase
&
CommonTypes
.
ISn
&
CommonTypes
.
IUser
>
interface
IDeviceInfoData
extends
CommonTypes
.
IId
,
CommonTypes
.
ITime
,
Omit
<
CommonTypes
.
IUser
,
'sn'
>
{
type
IDeviceInfo
=
CommonTypes
.
ITime
&
CommonTypes
.
IUser
last_log_upload_time
?:
string
|
Date
last_log_remove_time
?:
string
|
Date
last_login_time
?:
string
|
Date
last_offline_time
?:
string
|
Date
}
type
IDeviceInfo
=
{
fields
?:
FieldTypes
.
TFieldRequird
[]
}
&
IDeviceInfoData
&
CommonTypes
.
ISn
&
DeviceStatus
.
Status
&
ConfigTypes
.
ILogConfig
type
TDeviceInfoResult
=
Omit
<
IDeviceInfo
,
'created_at'
|
'updated_at'
|
'device_id'
>
type
TDeviceInfoResult
=
Omit
<
IDeviceInfo
,
'created_at'
|
'updated_at'
|
'device_id'
>
...
@@ -41,23 +29,23 @@ declare namespace DeviceTypes {
...
@@ -41,23 +29,23 @@ declare namespace DeviceTypes {
log_config log_config?
log_config log_config?
}*/
}*/
type
TOneDeviceInfo
=
Omit
<
IDeviceInfo
,
'sn'
|
'status'
|
'fields'
|
'log_saved_days'
>
type
TOneDeviceInfo
=
IDeviceInfo
&
CommonTypes
.
IDeviceId
/**
/**
* 表示设备结果的接口
* 表示设备结果的接口
*/
*/
type
TDevice
=
{
fields
:
FieldTypes
.
TFieldRequird
[]
}
&
CommonTypes
.
IId
&
CommonTypes
.
IUser
&
DeviceStatus
.
Status
&
Partial
<
IDeviceInfo
>
&
Partial
<
ConfigTypes
.
ILogConfig
>
&
CommonTypes
.
ISn
type
IDeviceResult
=
{
type
IDeviceResult
=
{
/**
device_info
:
Partial
<
IDeviceInfo
>
* 与设备关联的详细信息
*/
device_info
:
Partial
<
IDeviceInfo
>
&
{
log_config
:
Partial
<
ConfigTypes
.
ILogConfig
>
log_config
:
Partial
<
ConfigTypes
.
ILogConfig
>
device_status
:
DeviceStatus
.
Status
device_status
:
DeviceStatus
.
Status
}
fields
:
IFields
[]
}
&
TDevice
&
CommonTypes
.
IId
}
&
CommonTypes
.
IId
&
CommonTypes
.
ISn
&
Partial
<
Pick
<
CommonTypes
.
ITime
,
'created_at'
>>
type
TDevice
=
CommonTypes
.
IId
&
CommonTypes
.
ISn
&
Partial
<
Pick
<
CommonTypes
.
ITime
,
'created_at'
>>
/**
/**
* 表示日志用户字段的接口
* 表示日志用户字段的接口
...
...
src/typings/device.status.d.ts
View file @
d01edba
declare
namespace
DeviceStatus
{
declare
namespace
DeviceStatus
{
interface
IDeviceStatus
extends
CommonTypes
.
IDeviceId
{
interface
IDeviceStatus
extends
CommonTypes
.
IDeviceId
{
status
:
number
status
:
number
,
last_log_upload_time
?:
string
|
Date
last_log_remove_time
?:
string
|
Date
last_login_time
?:
string
|
Date
last_offline_time
?:
string
|
Date
}
}
type
Status
=
Omit
<
IDeviceStatus
,
'device_id'
>
type
Status
=
Omit
<
IDeviceStatus
,
'device_id'
>
}
}
src/typings/relations.d.ts
View file @
d01edba
declare
namespace
RelationsTypes
{
declare
namespace
RelationsTypes
{
interface
IRelation
extends
CommonTypes
.
IId
{
interface
IRelation
extends
CommonTypes
.
IId
,
CommonTypes
.
IDeviceId
{
config_id
:
number
field_id
:
number
field_id
:
number
}
}
type
LogConfigUserFieldsRel
=
Omit
<
IRelation
,
'id'
>
type
LogConfigUserFieldsRel
=
Omit
<
IRelation
,
'id'
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment