Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Matúš Valko
Online Gaming Management System
Commits
fda2af20
Commit
fda2af20
authored
May 20, 2022
by
Adrián Piaček
Browse files
Added possibility to assign team to player
parent
b7bd53ff
Pipeline
#141628
passed with stage
in 1 minute and 5 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gaming-api/src/main/java/cz/muni/fi/pa165/dto/CreatePlayerDTO.java
deleted
100644 → 0
View file @
b7bd53ff
package
cz.muni.fi.pa165.dto
;
public
class
CreatePlayerDTO
extends
PlayerDTO
{
}
gaming-api/src/main/java/cz/muni/fi/pa165/dto/PlayerDTO.java
View file @
fda2af20
...
...
@@ -5,6 +5,7 @@ import cz.muni.fi.pa165.entity.TeamEntity;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashSet
;
import
java.util.Set
;
...
...
@@ -15,8 +16,6 @@ import java.util.Set;
@Setter
public
class
PlayerDTO
extends
PersonDTO
{
private
TeamEntity
team
;
private
Set
<
MatchEntity
>
matches
=
new
HashSet
<>();
private
int
killStat
;
...
...
@@ -24,4 +23,10 @@ public class PlayerDTO extends PersonDTO {
private
int
deathStat
;
private
int
assistStat
;
private
TeamEntity
team
;
@NotNull
private
String
teamId
;
}
gaming-rest/src/main/java/cz/muni/fi/pa165/rest/controllers/PlayerController.java
View file @
fda2af20
package
cz.muni.fi.pa165.rest.controllers
;
import
cz.muni.fi.pa165.dto.CreatePlayerDTO
;
import
cz.muni.fi.pa165.dto.PlayerDTO
;
import
cz.muni.fi.pa165.entity.PlayerEntity
;
import
cz.muni.fi.pa165.facade.PlayerFacade
;
import
cz.muni.fi.pa165.rest.RootUris
;
import
cz.muni.fi.pa165.rest.exception.ResourceAlreadyExistsException
;
...
...
@@ -14,9 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
@RestController
@RequestMapping
(
RootUris
.
restPlayer
)
...
...
gaming-service/src/main/java/cz/muni/fi/pa165/facade/PlayerFacadeImpl.java
View file @
fda2af20
...
...
@@ -4,6 +4,7 @@ import cz.muni.fi.pa165.dto.PlayerDTO;
import
cz.muni.fi.pa165.entity.PlayerEntity
;
import
cz.muni.fi.pa165.services.BeanMappingService
;
import
cz.muni.fi.pa165.services.player.PlayerService
;
import
cz.muni.fi.pa165.services.team.TeamService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -17,6 +18,8 @@ public class PlayerFacadeImpl implements PlayerFacade {
@Autowired
private
PlayerService
playerService
;
@Autowired
private
TeamService
teamService
;
@Autowired
private
BeanMappingService
beanMappingService
;
...
...
@@ -38,6 +41,7 @@ public class PlayerFacadeImpl implements PlayerFacade {
player
.
setName
(
playerDTO
.
getName
());
player
.
setCountry
(
playerDTO
.
getCountry
());
player
.
setTeam
(
teamService
.
findById
(
playerDTO
.
getTeamId
()));
player
.
setKillStat
(
playerDTO
.
getKillStat
());
player
.
setDeathStat
(
playerDTO
.
getDeathStat
());
player
.
setAssistStat
(
playerDTO
.
getAssistStat
());
...
...
gaming-spring-mvc/src/main/java/cz/muni/fi/pa165/mvc/controllers/PlayerController.java
View file @
fda2af20
...
...
@@ -67,10 +67,10 @@ public class PlayerController {
return
"player/new"
;
}
//create product
String
id
=
playerFacade
.
createPlayer
(
formBean
);
String
playerID
=
playerFacade
.
createPlayer
(
formBean
);
//report success
redirectAttributes
.
addFlashAttribute
(
"alert_success"
,
"Player "
+
id
+
" was created"
);
return
"redirect:"
+
uriBuilder
.
path
(
"/player/view/{id}"
).
buildAndExpand
(
id
).
encode
().
toUriString
();
redirectAttributes
.
addFlashAttribute
(
"alert_success"
,
"Player "
+
formBean
.
getName
()
+
" was created
!
"
);
return
"redirect:"
+
uriBuilder
.
path
(
"/player/view/{id}"
).
buildAndExpand
(
playerID
).
encode
().
toUriString
();
}
@RequestMapping
(
value
=
"/delete/{uuid}"
,
method
=
RequestMethod
.
POST
)
...
...
gaming-spring-mvc/src/main/webapp/WEB-INF/jsp/player/new.jsp
View file @
fda2af20
...
...
@@ -30,16 +30,17 @@
</div>
<div
class=
"form-group"
>
<form:label
path=
"team"
cssClass=
"col-sm-2 control-label"
>
Team
</form:label>
<form:label
path=
"team
Id
"
cssClass=
"col-sm-2 control-label"
>
Team
</form:label>
<div
class=
"col-sm-10"
>
<form:select
path=
"team"
cssClass=
"form-control"
>
<form:select
path=
"team
Id
"
cssClass=
"form-control"
>
<c:forEach
items=
"
${
teams
}
"
var=
"c"
>
<form:option
value=
"
${
c
}
"
>
${c.name}
</form:option>
<form:option
value=
"
${
c
.
id
}
"
>
${c.name}
</form:option>
</c:forEach>
</form:select>
<form:errors
path=
"team"
cssClass=
"error"
/>
<p
class=
"help-block"
>
<form:errors
path=
"team
Id
"
cssClass=
"error"
/>
</p>
</div>
</div>
<div
class=
"form-group ${killStat_error?'has-error':''}"
>
<form:label
path=
"killStat"
cssClass=
"col-sm-2 control-label"
>
Kill stat
</form:label>
<div
class=
"col-sm-10"
>
...
...
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