Commit e0b71115 by fengshuonan

更新初始化常量的过程

parent 37a0d572
package cn.stylefeng.guns.sys.modular.consts.service;
import cn.stylefeng.guns.base.consts.ConstantsContext;
import cn.stylefeng.guns.sys.modular.consts.entity.SysConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* <p>
* 参数配置 服务类
* </p>
*
* @author stylefeng
* @since 2019-06-20
*/
@Component
@Slf4j
public class SysConfigInit implements CommandLineRunner {
@Autowired
private SysConfigService sysConfigService;
@Override
public void run(String... args) {
//初始化所有的常量
List<SysConfig> list = sysConfigService.list();
if (list != null && list.size() > 0) {
for (SysConfig sysConfig : list) {
ConstantsContext.putConstant(sysConfig.getCode(), sysConfig.getValue());
}
log.info("初始化常量" + list.size() + "条!");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment