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.enums.AuthMethod;
import app.annotations.interfaces.CheckPermitionFlag; import app.annotations.interfaces.CheckPermitionFlag;
import app.annotations.interfaces.CheckWebAccess; import app.annotations.interfaces.CheckWebAccess;
import app.annotations.interfaces.CollectStatistic;
import app.entities.VipGiveMethod; import app.entities.VipGiveMethod;
import app.entities.VipPrice; import app.entities.VipPrice;
import app.services.db.VIPService; import app.services.db.VIPService;
import app.utils.SteamIDConverter; import app.utils.SteamIDConverter;
import com.google.common.collect.ImmutableMap;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -26,13 +26,10 @@ public class ExternalVIPController {
List<VipPrice> prices; List<VipPrice> prices;
private boolean steam = true;
private boolean qiwi = true;
@Autowired @Autowired
public ExternalVIPController(VIPService vipService) { public ExternalVIPController(VIPService vipService) {
this.vipService = vipService; this.vipService = vipService;
this.unique_set = new HashSet(); this.unique_set = new HashSet<>();
setupPrices(); setupPrices();
} }
@ -47,7 +44,7 @@ public class ExternalVIPController {
@PostMapping @PostMapping
@CheckWebAccess(auth_method = AuthMethod.SECRET_KEY) @CheckWebAccess(auth_method = AuthMethod.SECRET_KEY)
public ResponseEntity addVIP(HttpServletRequest request, public ResponseEntity<Integer> addVIP(HttpServletRequest request,
@RequestParam String steam, @RequestParam String steam,
@RequestParam int amount, @RequestParam int amount,
@RequestParam String service, @RequestParam String service,
@ -55,7 +52,7 @@ public class ExternalVIPController {
@RequestParam(required = false, defaultValue = "") String unique) { @RequestParam(required = false, defaultValue = "") String unique) {
if (!unique.isEmpty()) { 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); else unique_set.add(unique);
} }
@ -64,28 +61,26 @@ public class ExternalVIPController {
amount, amount,
VipGiveMethod.valueOf(service.toUpperCase()), VipGiveMethod.valueOf(service.toUpperCase()),
extra); extra);
return new ResponseEntity(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping @GetMapping
public ResponseEntity getPricesResponse() { public ResponseEntity<List<VipPrice>> getPricesResponse() {
return new ResponseEntity(getPrices(), HttpStatus.OK); return new ResponseEntity<>(getPrices(), HttpStatus.OK);
} }
public List<VipPrice> getPrices() { public List<VipPrice> getPrices() {
return prices.stream() return prices.stream()
.peek(price -> price.setQiwi(qiwi)) .peek(prices -> prices.changeEnabled(vipService.getServices()))
.peek(price -> price.setSteam(steam)).collect(Collectors.toList()); .collect(Collectors.toList());
} }
@GetMapping("/change") @GetMapping("/change")
@CheckWebAccess @CheckWebAccess
@CollectStatistic
@CheckPermitionFlag(flag = "z") @CheckPermitionFlag(flag = "z")
public ResponseEntity disable(HttpServletRequest request, @RequestParam(value = "type", required = false) String type) { public ResponseEntity<HashMap> disable(HttpServletRequest request, @RequestParam(value = "type", required = false) String type) {
switch (type) { if (vipService.getServices().containsKey(type)) vipService.getServices().put(type, !vipService.getServices().get(type));
case "steam": this.steam = !this.steam; return new ResponseEntity<>(vipService.getServices(), HttpStatus.OK);
case "qiwi": this.qiwi = !this.qiwi;
}
return new ResponseEntity(ImmutableMap.of("steam", this.steam, "qiwi", this.qiwi), 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.ProfileService;
import app.services.ReportService; import app.services.ReportService;
import app.services.db.FreeVIPService; import app.services.db.FreeVIPService;
import app.services.db.VIPService;
import app.utils.SteamIDConverter; import app.utils.SteamIDConverter;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -18,9 +19,10 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("api/profile/current") @RequestMapping("api/profile/current")
public class ProfileController { public class ProfileController {
private ProfileService profileService; private final ProfileService profileService;
private FreeVIPService freeVIPService; private final FreeVIPService freeVIPService;
private ReportService reportService; private final ReportService reportService;
private final VIPService vipService;
@Value("${backend.vip.buy.steam}") @Value("${backend.vip.buy.steam}")
private String STEAM_TRADE; private String STEAM_TRADE;
@ -33,10 +35,12 @@ public class ProfileController {
@Autowired @Autowired
public ProfileController(ProfileService profileService, public ProfileController(ProfileService profileService,
FreeVIPService freeVIPService, FreeVIPService freeVIPService,
ReportService reportService) { ReportService reportService,
VIPService vipService) {
this.profileService = profileService; this.profileService = profileService;
this.freeVIPService = freeVIPService; this.freeVIPService = freeVIPService;
this.reportService = reportService; this.reportService = reportService;
this.vipService = vipService;
} }
@GetMapping @GetMapping
@ -96,6 +100,10 @@ public class ProfileController {
@RequestParam(value = "steam64", defaultValue = "") String steam64, @RequestParam(value = "steam64", defaultValue = "") String steam64,
@RequestParam String buy_type, @RequestParam String buy_type,
@RequestParam(required = false, defaultValue = "") Integer cost) { @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) { switch (buy_type) {
case "steam":{ case "steam":{
return ResponseEntity.status(HttpStatus.FOUND) return ResponseEntity.status(HttpStatus.FOUND)

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

@ -1,8 +1,11 @@
package app.entities; package app.entities;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.util.HashMap;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class VipPrice { public class VipPrice {
@ -15,4 +18,11 @@ public class VipPrice {
boolean qiwi = true; boolean qiwi = true;
boolean donationalerts = true; boolean donationalerts = true;
int da_percent = 10; 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 @Service
public class VIPService { public class VIPService {
@Autowired @Autowired
@Qualifier("jt_rw") @Qualifier("jt_rw")
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
private HashMap<String, Boolean> services;
RestTemplate restTemplate; RestTemplate restTemplate;
@Value("${backend.vip.discord}") @Value("${backend.vip.discord}")
@ -43,6 +43,16 @@ public class VIPService {
this.permitionService = permitionService; this.permitionService = permitionService;
this.serverService = serverService; this.serverService = serverService;
this.donateService = donateService; 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