Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
all but the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Amelia0010 committed Jun 1, 2020
1 parent fd86d1b commit bf542c3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
14 changes: 12 additions & 2 deletions src/main/java/net/yogstation/api/controller/BanController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import lombok.AllArgsConstructor;
import net.yogstation.api.bean.AuthorizedSession;
import net.yogstation.api.jpa.entity.BanEntity;
import net.yogstation.api.service.BanService;
import org.springframework.data.domain.Page;
Expand All @@ -13,11 +14,20 @@
@AllArgsConstructor
public class BanController {
private BanService banService;
private AuthorizedSession authorizedSession;

@GetMapping("/api/v1/publicbans")
@GetMapping("/api/v1/bans")
public Page<BanEntity> getBans(@RequestParam(required = false, defaultValue = "0") int page,
@RequestParam(required = false, defaultValue = "25") int size) {

return banService.getBans(page, size);
Page<BanEntity> banPage = banService.getBans(page, size);

banPage.forEach(ban -> {
if (!authorizedSession.hasPermission("bans.GDPR")) {
ban.setComputerid("0000000000");
ban.setIp(0000000000);
}
});
return banPage;
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/yogstation/api/jpa/entity/BanEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public class BanEntity {
private int id;

private String ckey;
private String a_ckey;
private String aCkey;
@Column(columnDefinition="mediumtext")
private String reason;
private LocalDateTime expirationTime;
private LocalDateTime unbannedDatetime;
private LocalDateTime bantime;
private String role;
private int roundId;
private int ip;
private String computerid; // Why is this a string containing a number???
}
4 changes: 2 additions & 2 deletions src/main/java/net/yogstation/api/service/BanService.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package net.yogstation.api.service;

import lombok.AllArgsConstructor;
import net.yogstation.api.jpa.entity.BanEntity;
import net.yogstation.api.jpa.repository.BanRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class BanService {
private BanRepository banRepository;

public BanService(BanRepository banRepository) { this.banRepository = banRepository;}

public Page<BanEntity> getBans(int page, int size) {
return banRepository.findAll(PageRequest.of(page, size));
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/development/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ INSERT INTO `erro_library` (`id`,`author`,`title`,`content`,`category`,`ckey`,`d
INSERT INTO `erro_library` (`id`,`author`,`title`,`content`,`category`,`ckey`,`datetime`,`deleted`,`round_id_created`) VALUES (1931,'Anonymous','Darth Sidious','<font face=\"Comic Sans MS\" color=\"red\"><b>HONK HONK HONK HONK HONK HONK HONK<br>HOOOOOOOOOOOOOOOOOOOOOONK<br>APRIL FOOLS</b></font>','Religion','ckey6','2020-04-05 19:50:31',1,28644);
INSERT INTO `erro_library` (`id`,`author`,`title`,`content`,`category`,`ckey`,`datetime`,`deleted`,`round_id_created`) VALUES (1930,'Anonymous','Darth Sidious','<font face=\"Comic Sans MS\" color=\"red\"><b>HONK HONK HONK HONK HONK HONK HONK<br>HOOOOOOOOOOOOOOOOOOOOOONK<br>APRIL FOOLS</b></font>','Religion','ckey6','2020-04-05 19:50:17',NULL,28644);

INSERT INTO `erro_ban` (`id`, `bantime`, `round_id`, `role`, `expiration_time`, `reason`, `ckey`, `a_ckey`, `unbanned_datetime`,) VALUES
(1, '2014-05-04 23:21:19', 0, 'Server', NULL, 'Killed as a non antag because he was bored, and then logged out. ', 'scof', '05rhardy', '2015-11-18 10:48:11'),
(2, '2014-05-05 11:34:33', 0, 'Server', NULL, 'Joined as captain, started shooting his laser gun around, and then logged off.', 'sneakytiki', 'firestorm258', '2015-11-18 10:48:11'),
(3, '2014-05-05 17:44:33', 0, 'Chemist', NULL, 'Firing spacelube', 'deathbenotproud', '05rhardy', '2015-11-18 10:48:11'),
(4, '2014-05-05 17:44:45', 0, 'Janitor', NULL, 'Firing space lube', 'deathbenotproud', '05rhardy', '2015-11-18 10:48:11'),
(5, '2014-05-05 21:06:45', 0, 'Server', '2014-05-06 21:06:45', 'Beat the clown to death for messing around in medbay', 'wolffkran', 'oakboscage', '2015-11-18 10:48:11');
INSERT INTO `erro_ban` (`id`, `bantime`, `round_id`, `role`, `expiration_time`, `reason`, `ckey`, `ip`, `computerid`, `a_ckey`, `unbanned_datetime`,) VALUES
(1, '2014-05-04 23:21:19', 0, 'Server', NULL, 'Killed as a non antag because he was bored, and then logged out. ', 'scof', 1111111111, '1111111111', '05rhardy', '2015-11-18 10:48:11'),
(2, '2014-05-05 11:34:33', 0, 'Server', NULL, 'Joined as captain, started shooting his laser gun around, and then logged off.', 'sneakytiki', 1111111111, '1111111111', 'firestorm258', '2015-11-18 10:48:11'),
(3, '2014-05-05 17:44:33', 0, 'Chemist', NULL, 'Firing spacelube', 'deathbenotproud', 1111111111, '1111111111', '05rhardy', '2015-11-18 10:48:11'),
(4, '2014-05-05 17:44:45', 0, 'Janitor', NULL, 'Firing space lube', 'deathbenotproud', 1111111111, '1111111111', '05rhardy', '2015-11-18 10:48:11'),
(5, '2014-05-05 21:06:45', 0, 'Server', '2014-05-06 21:06:45', 'Beat the clown to death for messing around in medbay', 'wolffkran', 1111111111, '1111111111', 'oakboscage', '2015-11-18 10:48:11');

0 comments on commit bf542c3

Please sign in to comment.