Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Samuel Kulíšek
pa165-secret-service-archive
Commits
499efde9
Commit
499efde9
authored
May 13, 2022
by
Will
Browse files
impl report api
parent
f54c0fc8
Pipeline
#138918
passed with stage
in 1 minute and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/ApiUris.java
View file @
499efde9
...
...
@@ -9,5 +9,7 @@ public abstract class ApiUris {
public
static
final
String
URI_MISSIONS
=
"/missions"
;
public
static
final
String
URI_COUNTRIES
=
"/countries"
;
public
static
final
String
URI_REPORTS
=
"/reports"
;
}
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/controller/ReportController.java
0 → 100644
View file @
499efde9
package
cz.muni.fi.pa165.rest.controller
;
import
cz.muni.fi.pa165.dto.ReportDetailDto
;
import
cz.muni.fi.pa165.facade.ReportFacade
;
import
cz.muni.fi.pa165.rest.ApiUris
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
@RequestMapping
(
ApiUris
.
URI_REPORTS
)
@Tag
(
name
=
"Reports"
,
description
=
"Management of reports"
)
public
class
ReportController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ReportController
.
class
);
private
final
ReportFacade
reportFacade
;
@Autowired
public
ReportController
(
ReportFacade
reportFacade
)
{
this
.
reportFacade
=
reportFacade
;
}
@Operation
(
description
=
"Retrieve all mission reports"
)
@GetMapping
(
"/missions/{missionId}"
)
public
final
ResponseEntity
<
List
<
ReportDetailDto
>>
getAllMissionReports
(
@PathVariable
long
missionId
,
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
reportFacade
.
getAllMissionReports
(
missionId
,
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve reports of specified mission"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieve all reports of specific mission of specified agent"
)
@GetMapping
(
"/missions/{missionId}/agents/{agentId}"
)
public
final
ResponseEntity
<
List
<
ReportDetailDto
>>
getAllMissionAgentReports
(
@PathVariable
long
missionId
,
@PathVariable
long
agentId
,
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
reportFacade
.
getAllMissionAgentReports
(
missionId
,
agentId
,
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve reports of specified mission of specified agent"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieve all report of specified agent"
)
@GetMapping
(
"/agents/{agentId}"
)
public
final
ResponseEntity
<
List
<
ReportDetailDto
>>
getAllAgentReports
(
@PathVariable
long
agentId
,
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
reportFacade
.
getAllAgentReports
(
agentId
,
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve reports of specified agent"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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