6 changed files with 172 additions and 23 deletions
@ -0,0 +1,54 @@ |
|||
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); |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
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.MessageService; |
|||
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/messages") |
|||
public class MessagesController { |
|||
private MessageService messageService; |
|||
|
|||
@Autowired |
|||
MessagesController(MessageService messageService) { |
|||
this.messageService = messageService; |
|||
} |
|||
|
|||
@PostMapping |
|||
@CheckWebAccess(auth_method = AuthMethod.STEAM64) |
|||
@WaitAfterNext(order = "messages") |
|||
public ResponseEntity getMessages(HttpServletRequest request, |
|||
@RequestBody(required = false) String filter, |
|||
@RequestParam(required = false) String srv, |
|||
@RequestParam(required = false, defaultValue = "0") Integer offset, |
|||
@RequestParam(required = false, defaultValue = "20") Integer limit) { |
|||
if (limit > 20) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); |
|||
return new ResponseEntity(messageService.getAllMessages(srv, filter, offset, limit), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/account") |
|||
@CheckWebAccess(auth_method = AuthMethod.STEAM64) |
|||
@WaitAfterNext(order = "messages") |
|||
public ResponseEntity getAccountMessages(HttpServletRequest request, |
|||
@CookieValue(value = "steam64", defaultValue = "") String mysteam64, |
|||
@RequestParam(required = false) String steam64, |
|||
@RequestBody(required = false) String filter, |
|||
@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(messageService.getAccountMessages(steamID, srv, filter, offset, limit), HttpStatus.OK); |
|||
} |
|||
} |
Loading…
Reference in new issue