Browse Source

qiwi disable

master
gsd 11 months ago
parent
commit
3d52d5b4b3
  1. 31
      src/main/java/app/controllers/other/ExternalVIPController.java
  2. 16
      src/main/java/app/controllers/user/ProfileController.java
  3. 10
      src/main/java/app/entities/VipPrice.java
  4. 14
      src/main/java/app/services/db/VIPService.java

31
src/main/java/app/controllers/other/ExternalVIPController.java

@ -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);
}
}

16
src/main/java/app/controllers/user/ProfileController.java

@ -7,6 +7,7 @@ import app.entities.SocialAuth;
import app.services.ProfileService;
import app.services.ReportService;
import app.services.db.FreeVIPService;
import app.services.db.VIPService;
import app.utils.SteamIDConverter;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,9 +19,10 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("api/profile/current")
public class ProfileController {
private ProfileService profileService;
private FreeVIPService freeVIPService;
private ReportService reportService;
private final ProfileService profileService;
private final FreeVIPService freeVIPService;
private final ReportService reportService;
private final VIPService vipService;
@Value("${backend.vip.buy.steam}")
private String STEAM_TRADE;
@ -33,10 +35,12 @@ public class ProfileController {
@Autowired
public ProfileController(ProfileService profileService,
FreeVIPService freeVIPService,
ReportService reportService) {
ReportService reportService,
VIPService vipService) {
this.profileService = profileService;
this.freeVIPService = freeVIPService;
this.reportService = reportService;
this.vipService = vipService;
}
@GetMapping
@ -96,6 +100,10 @@ public class ProfileController {
@RequestParam(value = "steam64", defaultValue = "") String steam64,
@RequestParam String buy_type,
@RequestParam(required = false, defaultValue = "") Integer cost) {
if (!vipService.getServices().getOrDefault(buy_type, true)) {
return new ResponseEntity("Service " + buy_type.toUpperCase() + " is not active long time", HttpStatus.OK);
}
switch (buy_type) {
case "steam":{
return ResponseEntity.status(HttpStatus.FOUND)

10
src/main/java/app/entities/VipPrice.java

@ -1,8 +1,11 @@
package app.entities;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.HashMap;
@Data
@AllArgsConstructor
public class VipPrice {
@ -15,4 +18,11 @@ public class VipPrice {
boolean qiwi = true;
boolean donationalerts = true;
int da_percent = 10;
@JsonIgnore
public void changeEnabled(HashMap<String, Boolean> services) {
steam = services.get("steam");
qiwi = services.get("qiwi");
donationalerts = services.get("donationalerts");
}
}

14
src/main/java/app/services/db/VIPService.java

@ -21,12 +21,12 @@ import java.util.Map;
@Service
public class VIPService {
@Autowired
@Qualifier("jt_rw")
private JdbcTemplate jdbcTemplate;
private HashMap<String, Boolean> services;
RestTemplate restTemplate;
@Value("${backend.vip.discord}")
@ -43,6 +43,16 @@ public class VIPService {
this.permitionService = permitionService;
this.serverService = serverService;
this.donateService = donateService;
this.services = new HashMap<>(){{
put("steam", true);
put("qiwi", false);
put("donationalerts", true);
}};
}
public HashMap<String, Boolean> getServices() {
return services;
}
// Список ид из дискорда кто имеет платную випку

Loading…
Cancel
Save