Browse Source

у пельменя охуенные идеи

master
gsd 2 years ago
parent
commit
52d90434b3
  1. 30
      src/main/java/app/controllers/bot/DiscordBanController.java
  2. 6
      src/main/java/app/services/db/BanService.java

30
src/main/java/app/controllers/bot/DiscordBanController.java

@ -0,0 +1,30 @@
package app.controllers.bot;
import app.annotations.enums.AuthMethod;
import app.annotations.interfaces.CheckWebAccess;
import app.services.db.BanService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("api/bot/discord")
public class DiscordBanController {
BanService banService;
@Autowired
public DiscordBanController(BanService banService) {
this.banService = banService;
}
@GetMapping("/banlist")
@CheckWebAccess(auth_method = AuthMethod.SECRET_KEY)
public ResponseEntity getDiscordIDsBanList(
HttpServletRequest request) {
return new ResponseEntity(banService.getUsersDiscordWithBanOnServers(), HttpStatus.OK);
}
}

6
src/main/java/app/services/db/BanService.java

@ -88,4 +88,10 @@ public class BanService {
serverService.kickPlayer(user, "banned");
return getBan(user.getSteamids()).getId();
}
public List<Long> getUsersDiscordWithBanOnServers() {
return entityManager.createNativeQuery("SELECT `discord_id` FROM `light_bans` INNER JOIN `steam2discord` ON `light_bans`.`active` = ?1 AND `light_bans`.`steam_id` COLLATE utf8mb4_unicode_ci LIKE `steam2discord`.`steam_id`")
.setParameter(1,1)
.getResultList();
}
}

Loading…
Cancel
Save