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 long startTime;
|
||||||
|
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
|
private String mode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package run.halo.app.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
|
@ -63,6 +64,8 @@ public class AdminServiceImpl implements AdminService {
|
||||||
|
|
||||||
private final String driverClassName;
|
private final String driverClassName;
|
||||||
|
|
||||||
|
private final String mode;
|
||||||
|
|
||||||
public AdminServiceImpl(PostService postService,
|
public AdminServiceImpl(PostService postService,
|
||||||
SheetService sheetService,
|
SheetService sheetService,
|
||||||
AttachmentService attachmentService,
|
AttachmentService attachmentService,
|
||||||
|
@ -74,7 +77,8 @@ public class AdminServiceImpl implements AdminService {
|
||||||
LinkService linkService,
|
LinkService linkService,
|
||||||
StringCacheStore cacheStore,
|
StringCacheStore cacheStore,
|
||||||
ApplicationEventPublisher eventPublisher,
|
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.postService = postService;
|
||||||
this.sheetService = sheetService;
|
this.sheetService = sheetService;
|
||||||
this.attachmentService = attachmentService;
|
this.attachmentService = attachmentService;
|
||||||
|
@ -87,6 +91,7 @@ public class AdminServiceImpl implements AdminService {
|
||||||
this.cacheStore = cacheStore;
|
this.cacheStore = cacheStore;
|
||||||
this.eventPublisher = eventPublisher;
|
this.eventPublisher = eventPublisher;
|
||||||
this.driverClassName = driverClassName;
|
this.driverClassName = driverClassName;
|
||||||
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,6 +194,12 @@ public class AdminServiceImpl implements AdminService {
|
||||||
|
|
||||||
environmentDTO.setVersion(HaloConst.HALO_VERSION);
|
environmentDTO.setVersion(HaloConst.HALO_VERSION);
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(mode)) {
|
||||||
|
environmentDTO.setMode(StringUtils.equals("dev", mode) ? "development" : "production");
|
||||||
|
} else {
|
||||||
|
environmentDTO.setMode("test");
|
||||||
|
}
|
||||||
|
|
||||||
return environmentDTO;
|
return environmentDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue