Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
the creation of a frontend according to the task, an additionally made a modal window for Bootstrap 4
9 changes: 6 additions & 3 deletions src/main/java/com/game/controller/PlayerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public Integer getAllCount() {

@PostMapping
public ResponseEntity<PlayerInfo> createPlayer(@RequestBody PlayerInfo info) {
if (StringUtils.isEmpty(info.name) || info.name.length() > 12) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (StringUtils.isEmpty(info.name) || info.name.length() > 12)
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (info.title.length() > 30) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (isNull(info.race)) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (isNull(info.profession)) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
Expand All @@ -64,8 +65,10 @@ public ResponseEntity<PlayerInfo> createPlayer(@RequestBody PlayerInfo info) {
public ResponseEntity<PlayerInfo> updatePlayer(@PathVariable("ID") long id,
@RequestBody PlayerInfo info) {
if (id <= 0) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (nonNull(info.name) && (info.name.length() > 12 || info.name.isEmpty())) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (nonNull(info.title) && info.title.length() > 30) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (nonNull(info.name) && (info.name.length() > 12 || info.name.isEmpty()))
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
if (nonNull(info.title) && info.title.length() > 30)
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);

Player player = playerService.updatePlayer(id, info.name, info.title, info.race, info.profession, info.banned);
if (isNull(player)) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/game/repository/PlayerRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ public class PlayerRepository {
}};

public List<Player> getAll(int pageNumber, int pageSize) {
return storage.stream()
List<Player>playerList = storage.stream()
.sorted(Comparator.comparingLong(Player::getId))
.skip((long) pageNumber * pageSize)
.limit(pageSize)
.collect(Collectors.toList());
return playerList;

}

Expand Down
97 changes: 97 additions & 0 deletions src/main/webapp/css/my.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.html_body {
margin-left: 2%;
background: #f5f5dc;
}

th, td {
border: 1px solid black;
padding: 3px;
}


.click_active {
color: red;
}

#table_players {
width: 96%;
margin-bottom: 20px;
border: 1px solid #dddddd;
border-collapse: collapse;
}

#table_players th {
font-weight: bold;
padding: 5px;
background: #deb887;
border: 2px solid #8b0000;
}

#table_players td {
border: 2px solid #555555;
padding: 5px;
}

#table_players tbody tr:nth-child(odd) {
background: #a9a9a9;
}

#table_players tr:nth-child(even) {
background: #dddddd;
}

/*label*/
#create_block .label_create {
display: inline-block;
user-select: none;
background-color: #555;
color: white;
border: 1px solid black;
padding: 3px;
font-size: 16px;
cursor: pointer;
position: relative;
height: auto;
top: 1px;
width: calc(10% - 1px);
box-sizing: border-box;
}

#create-button {
background-color: #555;
color: white;
opacity: 0.8;
width: 80px;
height: 40px;
border: 3px solid black;
padding: 3px;
font-size: 20px;
font-style: italic;
}

#create_block{
background: #f5f5dc;
}


#data_win #create_block .label_create {
display: inline-block;
user-select: none;
background-color: #555;
color: white;
border: 1px solid black;
padding: 3px;
font-size: 16px;
cursor: pointer;
position: relative;
height: auto;
top: 1px;
width: calc(20% - 1px);
box-sizing: border-box;
}






Loading