Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-05-06 03:19:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e22487babf93dcc7225776920b2350410730de9b
e22487ba
1 parent
96a36f8c
feat. mqtt protocol and db connect
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
11 deletions
server/src/api/hub/hub.ctrl.js
server/src/api/medicine/medicine.ctrl.js
server/src/api/hub/hub.ctrl.js
View file @
e22487b
//허브(Mqtt Broker)등록 및 삭제
const
Hub
=
require
(
'../../models/hub'
);
const
Mqtt
=
require
(
'../../lib/MqttModule'
);
exports
.
hubRegister
=
async
(
ctx
)
=>
{
ctx
.
body
=
'hubRegister'
exports
.
hubRegister
=
async
(
ctx
)
=>
{
const
{
host
,
port
,
hubId
,
topic
}
=
ctx
.
request
.
body
;
const
hub
=
new
Hub
({
hubId
,
hosting
:
{
host
,
port
}
});
await
Hub
.
findOneAndUpdate
({
hubId
},
hub
,
{
upsert
:
true
});
const
client
=
Mqtt
.
mqttOn
({
host
,
port
});
Mqtt
.
mqttSubscribe
(
client
,
topic
);
ctx
.
body
=
'host :'
+
host
;
ctx
.
status
=
200
;
}
\ No newline at end of file
...
...
server/src/api/medicine/medicine.ctrl.js
View file @
e22487b
...
...
@@ -2,27 +2,39 @@
const
Medicine
=
require
(
'../../models/medicine'
);
exports
.
medicineSearch
=
async
(
ctx
)
=>
{
const
{
name
,
company
,
target
}
=
ctx
.
request
.
body
;
let
result
=
null
;
if
(
name
&&
name
!==
''
&&
name
!==
undefined
)
result
=
await
medicineSearch_ByName
(
name
);
else
if
(
company
&&
company
!==
''
&&
company
!==
undefined
)
result
=
await
medicineSearch_ByCompany
(
company
);
else
if
(
target
&&
target
!==
''
&&
target
!==
undefined
)
result
=
await
medicineSearch_ByTarget
(
target
);
ctx
.
body
=
{
medicineSearch
:
'search..'
totalItem
:
result
.
length
,
result
}
}
//이름으로 약 검색
const
medicineSearch_ByName
=
async
(
name
)
=>
{
const
result
=
await
Medicine
.
findByName
(
name
);
return
result
;
}
//제조사명으로 약 검색
const
medicineSearch_ByCompany
=
async
(
company
)
=>
{
}
//효능으로 약 검색
const
medicineSearch_ByEfficacy
=
async
(
efficacy
)
=>
{
const
result
=
await
Medicine
.
findByCompany
(
company
);
return
result
;
}
//타겟 병명으로 약 검색
const
medicineSearch_ByTarget
=
async
(
target
)
=>
{
const
result
=
await
Medicine
.
findByTarget
(
target
);
return
result
;
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment