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 4d471c11
authored
Sep 11, 2024
by
yixinjj
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
947ffcc1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
25 deletions
src/modules/device/device.controller.ts
src/modules/device/device.service.ts
test.http
src/modules/device/device.controller.ts
View file @
4d471c1
...
...
@@ -8,7 +8,7 @@ export class DeviceController {
@
Get
()
@
UseInterceptors
(
TransformInterceptor
)
findAll
(@
Query
()
{
user
,
mobile
,
sn
,
pageindex
,
pageSize
}:
Api
.
Device
.
QueryDevice
):
Promise
<
ResponseDto
>
{
findAll
(@
Query
()
{
user
,
mobile
,
sn
,
pageindex
,
pageSize
}:
Api
.
Device
.
QueryDevice
):
Promise
<
Api
.
Device
.
DeviceInfo
[]
>
{
return
this
.
deviceService
.
findAll
({
user
,
mobile
,
sn
,
pageindex
,
pageSize
})
}
...
...
src/modules/device/device.service.ts
View file @
4d471c1
...
...
@@ -9,11 +9,10 @@ export class DeviceService {
// @InjectRepository(DeviceEntity)/
// private readonly deviceRepository: Repository<DeviceEntity>,
@
Inject
(
PrismaService
)
private
readonly
prisma
:
PrismaService
)
// private connection: Connection,
{}
private
readonly
prisma
:
PrismaService
// private connection: Connection,
)
{}
async
findAll
({
user
,
mobile
,
sn
,
pageSize
,
pageindex
}:
Api
.
Device
.
QueryDevice
):
Promise
<
Api
.
Device
.
DeviceInfo
[]
>
{
async
findAll
({
user
,
mobile
,
sn
,
pageSize
,
pageindex
}:
Api
.
Device
.
QueryDevice
):
Promise
<
Api
.
Device
.
DeviceInfo
[]
>
{
const
result
=
await
this
.
prisma
.
device
.
findMany
({
// skip,
// take,
...
...
@@ -29,41 +28,44 @@ export class DeviceService {
'user_fields'
:
{
select
:
{
'log_user_field'
:
{
select
:{
name
:
true
,
select
:
{
name
:
true
}
}
}
}
}
}
},
where
:{
mobile
,
user
}
}
},
where
:
{
sn
:{
contains
:
sn
},
AND
:
{
'device_info'
:
{
mobile
:
{
contains
:
mobile
},
where
:{
sn
user
:
{
contains
:
user
}
}
}
}
})
const
data
=
result
.
reduce
((
pre
,
cur
)
=>
{
pre
.
push
({
sn
:
cur
.
sn
,
user
:
cur
.
device_info
?.
user
,
status
:
cur
.
device_info
?.
status
,
'log_saved_days'
:
cur
.
device_info
?.
log_config
?.
log_saved_days
,
'log_user_fields'
:
cur
.
device_info
?.
log_config
?.
user_fields
?.
map
(
item
=>
item
.
log_user_field
.
name
)
sn
:
cur
.
sn
,
user
:
cur
.
device_info
?.
user
,
status
:
cur
.
device_info
?.
status
,
'log_saved_days'
:
cur
.
device_info
?.
log_config
?.
log_saved_days
,
'log_user_fields'
:
cur
.
device_info
?.
log_config
?.
user_fields
?.
map
(
item
=>
item
.
log_user_field
.
name
)
})
return
pre
},[])
},
[])
return
data
// 或者使用queryBuilder
// return await getRepository(UsersEntity)
// .createQueryBuilder("user")
// .leftJoinAndSelect("user.photos", "photo")
// .getMany()
}
// async create(user): Promise<DeviceEntity[]> {
...
...
test.http
View file @
4d471c1
http://localhost:3000/device
\ No newline at end of file
http://localhost:3000/device?user=李四1
\ No newline at end of file
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