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
f54c0fc8
Commit
f54c0fc8
authored
May 13, 2022
by
Will
Browse files
impl country api
parent
7147b704
Pipeline
#138914
passed with stage
in 1 minute and 27 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 @
f54c0fc8
...
...
@@ -6,13 +6,8 @@ public abstract class ApiUris {
*/
private
static
final
String
URI_CURRENT_USER
=
"/me"
;
public
static
final
String
URI_AGENTS
=
"/agents"
;
public
static
final
String
URI_MISSIONS
=
"/missions"
;
public
static
final
String
URI_MISSIONS_USER
=
URI_CURRENT_USER
+
URI_MISSIONS
;
public
static
final
String
URI_USERS
=
"/users"
;
public
static
final
String
URI_CO
NSUMPTION_EVENTS
=
"/consumption_event
s"
;
public
static
final
String
URI_CO
UNTRIES
=
"/countrie
s"
;
}
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/controller/CountryController.java
0 → 100644
View file @
f54c0fc8
package
cz.muni.fi.pa165.rest.controller
;
import
cz.muni.fi.pa165.dto.CountryDetailDto
;
import
cz.muni.fi.pa165.dto.CountryNameDto
;
import
cz.muni.fi.pa165.facade.CountryFacade
;
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
;
@RestController
@RequestMapping
(
ApiUris
.
URI_COUNTRIES
)
@Tag
(
name
=
"Countries"
,
description
=
"Management of countries"
)
public
class
CountryController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CountryController
.
class
);
private
final
CountryFacade
countryFacade
;
@Autowired
public
CountryController
(
CountryFacade
countryFacade
)
{
this
.
countryFacade
=
countryFacade
;
}
@Operation
(
description
=
"Returns details about a single country"
)
@GetMapping
(
"/{countryId}"
)
public
final
ResponseEntity
<
CountryDetailDto
>
getDetail
(
@PathVariable
long
countryId
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
countryFacade
.
getCountryDetail
(
countryId
));
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve country of specified id"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves name of country for a specified mission"
)
@GetMapping
(
"missions/{missionId}"
)
public
final
ResponseEntity
<
CountryNameDto
>
getMissionCountryName
(
@PathVariable
long
missionId
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
countryFacade
.
getCountryName
(
missionId
));
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve country of specified mission"
);
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