|
|
@ -3,11 +3,11 @@ package app.controllers.other; |
|
|
|
import app.annotations.enums.AuthMethod; |
|
|
|
import app.annotations.interfaces.CheckPermitionFlag; |
|
|
|
import app.annotations.interfaces.CheckWebAccess; |
|
|
|
import app.annotations.interfaces.CollectStatistic; |
|
|
|
import app.entities.VipGiveMethod; |
|
|
|
import app.entities.VipPrice; |
|
|
|
import app.services.db.VIPService; |
|
|
|
import app.utils.SteamIDConverter; |
|
|
|
import com.google.common.collect.ImmutableMap; |
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
@ -26,13 +26,10 @@ public class ExternalVIPController { |
|
|
|
|
|
|
|
List<VipPrice> prices; |
|
|
|
|
|
|
|
private boolean steam = true; |
|
|
|
private boolean qiwi = true; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
public ExternalVIPController(VIPService vipService) { |
|
|
|
this.vipService = vipService; |
|
|
|
this.unique_set = new HashSet(); |
|
|
|
this.unique_set = new HashSet<>(); |
|
|
|
setupPrices(); |
|
|
|
} |
|
|
|
|
|
|
@ -47,7 +44,7 @@ public class ExternalVIPController { |
|
|
|
|
|
|
|
@PostMapping |
|
|
|
@CheckWebAccess(auth_method = AuthMethod.SECRET_KEY) |
|
|
|
public ResponseEntity addVIP(HttpServletRequest request, |
|
|
|
public ResponseEntity<Integer> addVIP(HttpServletRequest request, |
|
|
|
@RequestParam String steam, |
|
|
|
@RequestParam int amount, |
|
|
|
@RequestParam String service, |
|
|
@ -55,7 +52,7 @@ public class ExternalVIPController { |
|
|
|
@RequestParam(required = false, defaultValue = "") String unique) { |
|
|
|
|
|
|
|
if (!unique.isEmpty()) { |
|
|
|
if (unique_set.contains(unique)) return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); |
|
|
|
if (unique_set.contains(unique)) return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); |
|
|
|
else unique_set.add(unique); |
|
|
|
} |
|
|
|
|
|
|
@ -64,28 +61,26 @@ public class ExternalVIPController { |
|
|
|
amount, |
|
|
|
VipGiveMethod.valueOf(service.toUpperCase()), |
|
|
|
extra); |
|
|
|
return new ResponseEntity(result, HttpStatus.OK); |
|
|
|
return new ResponseEntity<>(result, HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping |
|
|
|
public ResponseEntity getPricesResponse() { |
|
|
|
return new ResponseEntity(getPrices(), HttpStatus.OK); |
|
|
|
public ResponseEntity<List<VipPrice>> getPricesResponse() { |
|
|
|
return new ResponseEntity<>(getPrices(), HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
|
public List<VipPrice> getPrices() { |
|
|
|
return prices.stream() |
|
|
|
.peek(price -> price.setQiwi(qiwi)) |
|
|
|
.peek(price -> price.setSteam(steam)).collect(Collectors.toList()); |
|
|
|
.peek(prices -> prices.changeEnabled(vipService.getServices())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/change") |
|
|
|
@CheckWebAccess |
|
|
|
@CollectStatistic |
|
|
|
@CheckPermitionFlag(flag = "z") |
|
|
|
public ResponseEntity disable(HttpServletRequest request, @RequestParam(value = "type", required = false) String type) { |
|
|
|
switch (type) { |
|
|
|
case "steam": this.steam = !this.steam; |
|
|
|
case "qiwi": this.qiwi = !this.qiwi; |
|
|
|
} |
|
|
|
return new ResponseEntity(ImmutableMap.of("steam", this.steam, "qiwi", this.qiwi), HttpStatus.OK); |
|
|
|
public ResponseEntity<HashMap> disable(HttpServletRequest request, @RequestParam(value = "type", required = false) String type) { |
|
|
|
if (vipService.getServices().containsKey(type)) vipService.getServices().put(type, !vipService.getServices().get(type)); |
|
|
|
return new ResponseEntity<>(vipService.getServices(), HttpStatus.OK); |
|
|
|
} |
|
|
|
} |
|
|
|