package app.controllers.user; import app.annotations.enums.AuthMethod; import app.annotations.interfaces.BurstUpdatePlayers; import app.annotations.interfaces.CheckWebAccess; import app.annotations.interfaces.WaitAfterNext; import app.entities.SocialAuth; import app.services.ProfileService; import app.services.ReportService; import app.services.db.FreeVIPService; import app.utils.SteamIDConverter; import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("api/profile/current") public class ProfileController { private ProfileService profileService; private FreeVIPService freeVIPService; private ReportService reportService; @Value("${backend.vip.buy.steam}") private String STEAM_TRADE; @Value("${backend.vip.buy.qiwi}") private String QIWI_LINK; @Autowired public ProfileController(ProfileService profileService, FreeVIPService freeVIPService, ReportService reportService) { this.profileService = profileService; this.freeVIPService = freeVIPService; this.reportService = reportService; } @GetMapping @CheckWebAccess @BurstUpdatePlayers @WaitAfterNext public ResponseEntity GetCurrentUser(HttpServletRequest request, @CookieValue(value = "steam64", defaultValue = "") String steam64, @RequestParam(value = "requests", defaultValue = "") String requests ){ if (requests.isEmpty()) { return new ResponseEntity(profileService.GetProfile(steam64), HttpStatus.OK); } else { return new ResponseEntity(profileService.GetProfile(steam64, requests), HttpStatus.OK); } } @PostMapping("/freevip") @CheckWebAccess @WaitAfterNext public ResponseEntity GetFreeVIP(HttpServletRequest request, @CookieValue(value = "steam64", defaultValue = "") String steam64, @RequestBody(required = false) SocialAuth socialAuth, @RequestParam(required = false, defaultValue = "false") Boolean test) { //return new ResponseEntity<>(freeVIPService.) //1.get social //2.get steam2discord //3.так уж и быть випка без анального зонда return new ResponseEntity(freeVIPService.addFreeVIP(SteamIDConverter.getSteamID(steam64), socialAuth, test), HttpStatus.OK); } @PostMapping("/report") @CheckWebAccess @BurstUpdatePlayers @WaitAfterNext public ResponseEntity ReportUser(HttpServletRequest request, @CookieValue(value = "steam64", defaultValue = "") String steam64, @RequestParam(value = "steam64", defaultValue = "") String reported_steam64, @RequestParam(value = "text", defaultValue = "") String text) { return new ResponseEntity(reportService.createReport( profileService.GetProfile(steam64, "permition,steam_data"), profileService.GetProfile(reported_steam64, "permition"), text ), HttpStatus.OK); } @GetMapping("/buyvip") public ResponseEntity BuyVIP(HttpServletRequest request, @RequestParam(value = "steam64", defaultValue = "") String steam64, @RequestParam String buy_type, @RequestParam(required = false, defaultValue = "") Integer cost) { switch (buy_type) { case "steam":{ return ResponseEntity.status(HttpStatus.FOUND) .header("Location", STEAM_TRADE) .build(); } case "qiwi": String steam2 = profileService.GetProfile(steam64, "").getSteamids().steam2; return ResponseEntity.status(HttpStatus.FOUND) .header("Location", String.valueOf(QIWI_LINK).replace("(AMOUNT)", String.valueOf(cost)).replace("(COMMENT)", steam2)) .build(); default: return ResponseEntity.status(HttpStatus.FOUND) .header("Location", "http://www.consultant.ru/document/cons_doc_LAW_6300/4e3d0ddc5edee16d48ad06866de7851fa2a55b3e/") .build(); } } }