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
441c62d5
Commit
441c62d5
authored
May 14, 2022
by
Will
Browse files
impl agent api
parent
499efde9
Pipeline
#139328
passed with stage
in 1 minute and 29 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/ApiUris.java
View file @
441c62d5
...
...
@@ -11,5 +11,7 @@ public abstract class ApiUris {
public
static
final
String
URI_COUNTRIES
=
"/countries"
;
public
static
final
String
URI_REPORTS
=
"/reports"
;
public
static
final
String
URI_AGENTS
=
"/agents"
;
}
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/controller/AgentController.java
0 → 100644
View file @
441c62d5
package
cz.muni.fi.pa165.rest.controller
;
import
cz.muni.fi.pa165.dto.AgentCountDto
;
import
cz.muni.fi.pa165.dto.AgentDetailDto
;
import
cz.muni.fi.pa165.dto.AgentListDto
;
import
cz.muni.fi.pa165.facade.AgentFacade
;
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_AGENTS
)
@Tag
(
name
=
"Agents"
,
description
=
"Management of agents"
)
public
class
AgentController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
MissionController
.
class
);
private
final
AgentFacade
agentFacade
;
@Autowired
public
AgentController
(
AgentFacade
agentFacade
)
{
this
.
agentFacade
=
agentFacade
;
}
@Operation
(
description
=
"Retrieve all agents of specified mission"
)
@GetMapping
(
"/missions/{missionId}"
)
public
final
ResponseEntity
<
List
<
AgentListDto
>>
getMissionAgents
(
@PathVariable
long
missionId
,
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getMissionAgents
(
missionId
,
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve agents of specified mission"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves agent detail"
)
@GetMapping
(
"/{agentId}"
)
public
final
ResponseEntity
<
AgentDetailDto
>
getAgent
(
@PathVariable
long
agentId
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAgent
(
agentId
));
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve specified agent"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves agent count for specified mission"
)
@GetMapping
(
"/missions/{missionId}/count"
)
public
final
ResponseEntity
<
AgentCountDto
>
getAgentCount
(
@PathVariable
long
missionId
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAgentCount
(
missionId
));
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve agent count of specified mission"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves agents with specified skill"
)
@GetMapping
(
"/skills/{skill}"
)
public
final
ResponseEntity
<
List
<
AgentListDto
>>
getAgentWithSkill
(
@PathVariable
String
skill
,
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAgentWithSkill
(
skill
,
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve agents with specified skill"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves agents with experience from specified country"
)
@GetMapping
(
"/countries/{countryId}"
)
public
final
ResponseEntity
<
List
<
AgentListDto
>>
getAgentWithCountryXp
(
@PathVariable
long
countryId
,
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAgentWithCountryXp
(
countryId
,
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve agents with experience from specified country"
,
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