Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
iotgateway
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
0Tyler
iotgateway
Commits
7d0a9238
Commit
7d0a9238
authored
May 13, 2019
by
0Tyler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway api update
parent
1bd0abe5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
10 deletions
+45
-10
gateway/src/main/java/edu/prlab/tyler/iotgateway/gateway/controllers/GatewayController.java
...ler/iotgateway/gateway/controllers/GatewayController.java
+45
-10
No files found.
gateway/src/main/java/edu/prlab/tyler/iotgateway/gateway/controllers/GatewayController.java
View file @
7d0a9238
...
...
@@ -3,36 +3,71 @@ package edu.prlab.tyler.iotgateway.gateway.controllers;
import
edu.prlab.tyler.iotgateway.cloud.pojo.device.Device
;
import
edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyChoice
;
import
edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyPolicyReport
;
import
edu.prlab.tyler.iotgateway.gateway.pojo.PrivacyChoiceIndex
;
import
edu.prlab.tyler.iotgateway.gateway.services.DeviceService
;
import
edu.prlab.tyler.iotgateway.gateway.services.PrivacyService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Optional
;
@RestController
public
class
GatewayController
{
private
DeviceService
deviceService
;
private
PrivacyService
privacyService
;
public
GatewayController
(
PrivacyService
privacyService
)
{
@Autowired
public
GatewayController
(
PrivacyService
privacyService
,
DeviceService
deviceService
)
{
this
.
deviceService
=
deviceService
;
this
.
privacyService
=
privacyService
;
}
// TODO
// @GetMapping("")
// public ResponseEntity<Iterable<Device>> readDevicesOfUser() {
//
// }
// TODO
//區塊鍊上綁定
//回傳Device(暫時從DB撈)
@PostMapping
(
"/device/{udn}"
)
public
ResponseEntity
<
Device
>
bindDeviceAndGateway
(
@PathVariable
(
value
=
"udn"
)
String
udn
)
{
return
deviceService
.
bindDeviceAndGateway
(
udn
)
.
map
(
ResponseEntity:
:
ok
)
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
}
@GetMapping
(
"/privacy/{UDN}"
)
// TODO
//取得與該gateway所綁定的裝置列表
//回傳Device列表(暫時從DB撈)
@GetMapping
(
"/device"
)
public
ResponseEntity
<
Iterable
<
Device
>>
readDevices
()
{
return
deviceService
.
readDevices
()
.
map
(
ResponseEntity:
:
ok
)
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
}
@GetMapping
(
"/device/{UDN}"
)
public
ResponseEntity
<
PrivacyPolicyReport
>
readPrivacyPolicyReportByDevice
(
@PathVariable
(
value
=
"UDN"
)
String
UDN
)
{
return
privacyService
.
getRelatedPrivacyPolicies
(
UDN
)
.
map
(
ResponseEntity:
:
ok
)
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
}
@PostMapping
(
"/choice"
)
public
ResponseEntity
<
PrivacyChoice
>
setPrivacyChoice
(
@RequestBody
PrivacyChoice
privacyChoice
)
{
public
ResponseEntity
<
PrivacyChoice
>
setPrivacyChoice
(
@RequestBody
PrivacyChoice
privacyChoice
)
{
return
privacyService
.
setPrivacyPolicyChoice
(
privacyChoice
)
.
map
(
ResponseEntity:
:
ok
)
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
}
// TODO
//根據使用者取得在此gateway上該使用者的隱私選擇列表(根據時間排序),
//暫時從DB撈,無特定使用者
@GetMapping
(
"/choice"
)
public
ResponseEntity
<
Iterable
<
PrivacyChoiceIndex
>>
readPrivacyChoiceRecordsByUser
()
{
return
Optional
.
of
(
privacyService
.
getPrivacyPolicyChoices
())
.
map
(
ResponseEntity:
:
ok
)
.
orElseGet
(()
->
ResponseEntity
.
noContent
().
build
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment