added version control & cloudflare cache clearing

This commit is contained in:
Prince
2026-06-21 00:25:15 +02:00
parent a367acd81d
commit caf4e4bc89
16 changed files with 348 additions and 45 deletions

View File

@@ -0,0 +1,57 @@
package zw.qantra.tm.domain.controllers;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import zw.qantra.tm.domain.models.AppVersion;
import zw.qantra.tm.domain.services.AppVersionService;
import java.util.Optional;
@RestController
@RequestMapping("/public/app-version")
@RequiredArgsConstructor
public class AppVersionController {
private final AppVersionService appVersionService;
/**
* Client checks if a newer app build is available.
* Pass the current build number as a query param.
*/
@GetMapping("/check/app")
public ResponseEntity<AppVersion> checkAppUpdate(@RequestParam Integer currentBuildNumber) {
Optional<AppVersion> update = appVersionService.checkForAppUpdate(currentBuildNumber);
return update.map(ResponseEntity::ok)
.orElse(ResponseEntity.noContent().build());
}
/**
* Client checks if a newer web build is available.
* Pass the current build number as a query param.
*/
@GetMapping("/check/web")
public ResponseEntity<AppVersion> checkWebUpdate(@RequestParam Integer currentBuildNumber) {
Optional<AppVersion> update = appVersionService.checkForWebUpdate(currentBuildNumber);
return update.map(ResponseEntity::ok)
.orElse(ResponseEntity.noContent().build());
}
/**
* Get the latest version record.
*/
@GetMapping("/latest")
public ResponseEntity<AppVersion> getLatestVersion() {
Optional<AppVersion> latest = appVersionService.getLatestVersion();
return latest.map(ResponseEntity::ok)
.orElse(ResponseEntity.noContent().build());
}
/**
* Persist a new version record (internal/admin use).
*/
@PostMapping
public ResponseEntity<AppVersion> save(@RequestBody AppVersion appVersion) {
return ResponseEntity.ok(appVersionService.save(appVersion));
}
}