mirror of https://github.com/halo-dev/halo
Update start information
parent
ca78680b3a
commit
4ec6604dcb
|
@ -1,14 +1,10 @@
|
|||
package cc.ryanc.halo;
|
||||
|
||||
import cc.ryanc.halo.config.properties.HaloProperties;
|
||||
import cc.ryanc.halo.logging.Logger;
|
||||
import cc.ryanc.halo.repository.base.BaseRepositoryImpl;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
@ -34,18 +30,4 @@ public class Application {
|
|||
// Run application
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
CommandLineRunner runner(ApplicationContext context, HaloProperties haloProperties) {
|
||||
return args -> {
|
||||
// Get server port
|
||||
String serverPort = context.getEnvironment().getProperty("server.port");
|
||||
|
||||
LOG.debug("Halo started at {}:{}", "http://localhost", serverPort);
|
||||
|
||||
if (!haloProperties.getDocDisabled()) {
|
||||
LOG.debug("Halo doc enable at {}:{}/{}", "http://localhost", serverPort, "swagger-ui.html");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package cc.ryanc.halo.listener;
|
||||
|
||||
import cc.ryanc.halo.config.properties.HaloProperties;
|
||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||
import cc.ryanc.halo.model.support.HaloConst;
|
||||
import cc.ryanc.halo.model.support.Theme;
|
||||
import cc.ryanc.halo.service.OptionsService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
|
@ -10,6 +12,7 @@ import freemarker.template.TemplateModelException;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
@ -37,6 +40,12 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
@Autowired
|
||||
private freemarker.template.Configuration configuration;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private HaloProperties haloProperties;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationStartedEvent event) {
|
||||
// save halo version to database
|
||||
|
@ -49,6 +58,26 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
this.loadOptions();
|
||||
this.loadThemes();
|
||||
this.loadOwo();
|
||||
|
||||
this.printStartInfo();
|
||||
}
|
||||
|
||||
private void printStartInfo() {
|
||||
// Get server port
|
||||
String serverPort = applicationContext.getEnvironment().getProperty("server.port");
|
||||
|
||||
String blogUrl = HaloConst.OPTIONS.get(BlogPropertiesEnum.BLOG_URL.getProp());
|
||||
if (StrUtil.isNotBlank(blogUrl)) {
|
||||
blogUrl = StrUtil.removeSuffix(blogUrl, "/");
|
||||
} else {
|
||||
blogUrl = "http://localhost:" + serverPort;
|
||||
}
|
||||
|
||||
log.info("Halo started at {}", blogUrl);
|
||||
log.info("Halo admin is at {}/admin", blogUrl);
|
||||
if (!haloProperties.getDocDisabled()) {
|
||||
log.debug("Halo doc enable at {}/swagger-ui.html", blogUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,26 +55,11 @@ public class OptionsServiceImpl extends AbstractCrudService<Options, String> imp
|
|||
*/
|
||||
@Override
|
||||
public void saveOption(String key, String value) {
|
||||
if (StrUtil.equals(value, "")) {
|
||||
// options = new Options();
|
||||
// options.setOptionName(key);
|
||||
// this.remove(options);
|
||||
|
||||
if (StrUtil.isBlank(value)) {
|
||||
// If value is empty
|
||||
removeByIdOfNullable(key);
|
||||
} else if (StrUtil.isNotEmpty(key)) {
|
||||
//如果查询到有该设置选项则做更新操作,反之保存新的设置选项
|
||||
|
||||
// if (null == optionsRepository.findOptionsByOptionName(key)) {
|
||||
// options = new Options();
|
||||
// options.setOptionName(key);
|
||||
// options.setOptionValue(value);
|
||||
// optionsRepository.save(options);
|
||||
// } else {
|
||||
// options = optionsRepository.findOptionsByOptionName(key);
|
||||
// options.setOptionValue(value);
|
||||
// optionsRepository.save(options);
|
||||
// }
|
||||
|
||||
Options options = fetchById(key).map(option -> {
|
||||
// Exist
|
||||
option.setOptionValue(value);
|
||||
|
@ -99,13 +84,6 @@ public class OptionsServiceImpl extends AbstractCrudService<Options, String> imp
|
|||
*/
|
||||
@Override
|
||||
public Map<String, String> findAllOptions() {
|
||||
// final Map<String, String> options = new HashMap<>();
|
||||
// final List<Options> optionsList = optionsRepository.findAll();
|
||||
// if (null != optionsList) {
|
||||
// optionsList.forEach(option -> options.put(option.getOptionName(), option.getOptionValue()));
|
||||
// }
|
||||
// return options;
|
||||
|
||||
return ServiceUtils.convertToMap(listAll(), Options::getOptionName, Options::getOptionValue);
|
||||
}
|
||||
|
||||
|
@ -117,12 +95,6 @@ public class OptionsServiceImpl extends AbstractCrudService<Options, String> imp
|
|||
*/
|
||||
@Override
|
||||
public String findOneOption(String key) {
|
||||
// final Options options = getByIdOfNullable(key);
|
||||
// if (null != options) {
|
||||
// return options.getOptionValue();
|
||||
// }
|
||||
// return null;
|
||||
|
||||
return fetchById(key).map(Options::getOptionValue).orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue