mirror of https://github.com/halo-dev/halo
Support mode for getEnvironment api.
parent
006edf13d7
commit
186611d529
|
@ -16,4 +16,6 @@ public class EnvironmentDTO {
|
|||
private long startTime;
|
||||
|
||||
private String version;
|
||||
|
||||
private String mode;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package run.halo.app.service.impl;
|
|||
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
@ -63,6 +64,8 @@ public class AdminServiceImpl implements AdminService {
|
|||
|
||||
private final String driverClassName;
|
||||
|
||||
private final String mode;
|
||||
|
||||
public AdminServiceImpl(PostService postService,
|
||||
SheetService sheetService,
|
||||
AttachmentService attachmentService,
|
||||
|
@ -74,7 +77,8 @@ public class AdminServiceImpl implements AdminService {
|
|||
LinkService linkService,
|
||||
StringCacheStore cacheStore,
|
||||
ApplicationEventPublisher eventPublisher,
|
||||
@Value("${spring.datasource.driver-class-name}") String driverClassName) {
|
||||
@Value("${spring.datasource.driver-class-name}") String driverClassName,
|
||||
@Value("${spring.profiles.active}") String mode) {
|
||||
this.postService = postService;
|
||||
this.sheetService = sheetService;
|
||||
this.attachmentService = attachmentService;
|
||||
|
@ -87,6 +91,7 @@ public class AdminServiceImpl implements AdminService {
|
|||
this.cacheStore = cacheStore;
|
||||
this.eventPublisher = eventPublisher;
|
||||
this.driverClassName = driverClassName;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -189,6 +194,12 @@ public class AdminServiceImpl implements AdminService {
|
|||
|
||||
environmentDTO.setVersion(HaloConst.HALO_VERSION);
|
||||
|
||||
if (StringUtils.isNotEmpty(mode)) {
|
||||
environmentDTO.setMode(StringUtils.equals("dev", mode) ? "development" : "production");
|
||||
} else {
|
||||
environmentDTO.setMode("test");
|
||||
}
|
||||
|
||||
return environmentDTO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue