Skip to content

Commit

Permalink
Support mode for getEnvironment api.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Jun 10, 2019
1 parent 006edf1 commit 186611d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/run/halo/app/model/dto/EnvironmentDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public class EnvironmentDTO {
private long startTime;

private String version;

private String mode;
}
13 changes: 12 additions & 1 deletion src/main/java/run/halo/app/service/impl/AdminServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -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,
Expand All @@ -74,7 +77,8 @@ public AdminServiceImpl(PostService postService,
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;
Expand All @@ -87,6 +91,7 @@ public AdminServiceImpl(PostService postService,
this.cacheStore = cacheStore;
this.eventPublisher = eventPublisher;
this.driverClassName = driverClassName;
this.mode = mode;
}

@Override
Expand Down Expand Up @@ -189,6 +194,12 @@ public EnvironmentDTO getEnvironments() {

environmentDTO.setVersion(HaloConst.HALO_VERSION);

if (StringUtils.isNotEmpty(mode)) {
environmentDTO.setMode(StringUtils.equals("dev", mode) ? "development" : "production");
} else {
environmentDTO.setMode("test");
}

return environmentDTO;
}

Expand Down

0 comments on commit 186611d

Please sign in to comment.