feat: add versioning entrypoint
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.onixbyte.deltaforceguide.config;
|
||||
|
||||
import com.onixbyte.deltaforceguide.properties.AppProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(AppProperties.class)
|
||||
public class AppConfig {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.onixbyte.deltaforceguide.controller;
|
||||
|
||||
import com.onixbyte.deltaforceguide.service.AppService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/versions")
|
||||
public class VersionController {
|
||||
|
||||
private final AppService appService;
|
||||
|
||||
public VersionController(AppService appService) {
|
||||
this.appService = appService;
|
||||
}
|
||||
|
||||
@Operation(description = "获取当前应用版本号")
|
||||
@GetMapping
|
||||
public String getVersion() {
|
||||
return appService.getVersion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.onixbyte.deltaforceguide.manager;
|
||||
|
||||
import com.onixbyte.deltaforceguide.properties.AppProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AppManager {
|
||||
|
||||
private final AppProperties appProperties;
|
||||
|
||||
public AppManager(AppProperties appProperties) {
|
||||
this.appProperties = appProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the application version.
|
||||
*
|
||||
* @return the version string of this application
|
||||
*/
|
||||
public String getVersion() {
|
||||
return appProperties.version();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.onixbyte.deltaforceguide.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "app.common")
|
||||
public record AppProperties(
|
||||
String version
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.onixbyte.deltaforceguide.service;
|
||||
|
||||
import com.onixbyte.deltaforceguide.manager.AppManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppService {
|
||||
|
||||
private final AppManager appManager;
|
||||
|
||||
public AppService(AppManager appManager) {
|
||||
this.appManager = appManager;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return appManager.getVersion();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user