You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

84 lines
5.0 KiB

package app.controllers.user;
import app.annotations.enums.AuthMethod;
import app.annotations.interfaces.CheckWebAccess;
import app.annotations.interfaces.WaitAfterNext;
import app.entities.other.SteamID;
import app.services.db.KillfeedService;
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.*;
@RestController
@RequestMapping("api/profile/killfeed")
public class KillFeedController {
private KillfeedService killfeedService;
@Autowired
KillFeedController(KillfeedService killfeedService) {
this.killfeedService = killfeedService;
}
@GetMapping("/weapons")
@CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "weapons")
public ResponseEntity getPopulateWeapons(HttpServletRequest request,
@CookieValue(value = "steam64", defaultValue = "") String mysteam64,
@RequestParam(required = false) String steam64,
@RequestParam(required = false) String srv,
@RequestParam(required = false, defaultValue = "0") Integer offset,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64);
if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND);
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity(killfeedService.getPopulateWeapons(steamID, srv, offset, limit), HttpStatus.OK);
}
@GetMapping
@CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "kills")
public ResponseEntity getKills(HttpServletRequest request,
@CookieValue(value = "steam64", defaultValue = "") String mysteam64,
@RequestParam(required = false) String steam64,
@RequestParam(required = false) String srv,
@RequestParam(required = false, defaultValue = "0") Integer offset,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64);
if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND);
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity(killfeedService.getKills(steamID, srv, offset, limit), HttpStatus.OK);
}
@PutMapping
@CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "assists")
public ResponseEntity getAssists(HttpServletRequest request,
@CookieValue(value = "steam64", defaultValue = "") String mysteam64,
@RequestParam(required = false) String steam64,
@RequestParam(required = false) String srv,
@RequestParam(required = false, defaultValue = "0") Integer offset,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64);
if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND);
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity(killfeedService.getAssists(steamID, srv, offset, limit), HttpStatus.OK);
}
@DeleteMapping
@CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "deads")
public ResponseEntity getDeads(HttpServletRequest request,
@CookieValue(value = "steam64", defaultValue = "") String mysteam64,
@RequestParam(required = false) String steam64,
@RequestParam(required = false) String srv,
@RequestParam(required = false, defaultValue = "0") Integer offset,
@RequestParam(required = false, defaultValue = "20") Integer limit) {
SteamID steamID = steam64 == null || steam64.isEmpty() ? SteamIDConverter.getSteamID(mysteam64) : SteamIDConverter.getSteamID(steam64);
if (steamID == null) return new ResponseEntity(HttpStatus.NOT_FOUND);
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity(killfeedService.getDeads(steamID, srv, offset, limit), HttpStatus.OK);
}
}