62 lines
2.3 KiB
62 lines
2.3 KiB
package app.controllers.admin;
|
|
|
|
import app.annotations.enums.CollectStages;
|
|
import app.annotations.interfaces.*;
|
|
import app.entities.PlayerProfile;
|
|
import app.services.ProfileService;
|
|
import app.services.ServerService;
|
|
import app.services.db.PermitionService;
|
|
import app.utils.SteamIDConverter;
|
|
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.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* контролллер кикать игроков
|
|
*/
|
|
@RestController
|
|
@RequestMapping("api/admin/kick")
|
|
public class KickController {
|
|
ServerService serverService;
|
|
ProfileService profileService;
|
|
PermitionService permitionService;
|
|
|
|
@Autowired
|
|
public KickController(ServerService serverService,
|
|
ProfileService profileService,
|
|
PermitionService permitionService) {
|
|
this.serverService = serverService;
|
|
this.profileService = profileService;
|
|
this.permitionService = permitionService;
|
|
}
|
|
|
|
@PostMapping
|
|
@CheckWebAccess
|
|
@CheckPermitionFlag(flag = "c")
|
|
@BurstUpdatePlayers
|
|
@WaitAfterNext(order = "kick")
|
|
@CollectStatistic(stage = CollectStages.COMBINED)
|
|
public ResponseEntity kickPlayer(
|
|
HttpServletRequest request,
|
|
@CookieValue(value = "steam64") String steam64,
|
|
@RequestParam(value = "steam64", required = false, defaultValue = "") String kicked_steam64,
|
|
@RequestParam(value = "player_name", required = false, defaultValue = "") String player_name,
|
|
@RequestParam(value = "reason", required = false, defaultValue = "kicked from backend") String reason
|
|
) {
|
|
PlayerProfile profile = profileService.prepareProfileToAction(steam64, kicked_steam64, player_name);
|
|
boolean result = serverService.kickPlayer(profile, reason);
|
|
|
|
if (result) return new ResponseEntity(HttpStatus.OK);
|
|
else return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
}
|
|
|
|
@RequestMapping(method = RequestMethod.OPTIONS)
|
|
@CheckPermitionFlag(flag = "c")
|
|
public ResponseEntity checkKickPlayer(HttpServletRequest request) {
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
|