dev add violation notion
Test Workflow / test (push) Successful in 4s

This commit is contained in:
vladp
2026-03-18 16:26:47 +07:00
parent 9e5ff7ce97
commit 9024d3aaca
2 changed files with 6 additions and 5 deletions
@@ -58,8 +58,9 @@ public class PaymentController {
}
}
@PostMapping("/auto-renewal/disable")
public ResponseEntity<?> disableAutoRenewal(@RequestHeader(value = "Authorization", required = false) String tokenHeader) {
@PostMapping("/auto-renewal")
public ResponseEntity<?> disableAutoRenewal(@RequestParam(value = "renewal") Boolean renewal,
@RequestHeader(value = "Authorization", required = false) String tokenHeader) {
try {
if (tokenHeader == null || tokenHeader.isBlank()) {
Map<String, Object> errorData = new HashMap<>();
@@ -68,7 +69,7 @@ public class PaymentController {
return ResponseEntity.ok().body(Map.of("error", errorData));
}
paymentService.disableAutoRenewal(authService.useUserAuthToken(tokenHeader));
paymentService.changeAutoRenewal(authService.useUserAuthToken(tokenHeader), renewal);
return ResponseEntity.ok(Map.of("message", "Auto-renewal disabled"));
} catch (UserNotFoundException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
@@ -120,12 +120,12 @@ public class PaymentService {
}
@Transactional
public void disableAutoRenewal(Long userId) {
public void changeAutoRenewal(Long userId, boolean autoRenewal) {
User user = userRepository.findById(userId).orElseThrow();
TariffInfo tariffInfo = user.getActiveTariffInfo();
if (tariffInfo != null) {
tariffInfo.setAutoRenewal(false);
tariffInfo.setAutoRenewal(autoRenewal);
tariffInfoRepository.save(tariffInfo);
}
}