提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.sys.modular.consts.init; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.consts.ConstantsContext; |
|
4 |
import cn.stylefeng.guns.sys.modular.consts.entity.SysConfig; |
|
5 |
import cn.stylefeng.guns.sys.modular.consts.service.SysConfigService; |
|
6 |
import lombok.extern.slf4j.Slf4j; |
|
7 |
import org.springframework.beans.factory.annotation.Autowired; |
|
8 |
import org.springframework.boot.CommandLineRunner; |
|
9 |
import org.springframework.stereotype.Component; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
/** |
|
14 |
* <p> |
|
15 |
* 参数配置 服务类 |
|
16 |
* </p> |
|
17 |
* |
|
18 |
* @author stylefeng |
|
19 |
* @since 2019-06-20 |
|
20 |
*/ |
|
21 |
@Component |
|
22 |
@Slf4j |
|
23 |
public class SysConfigInit implements CommandLineRunner { |
|
24 |
|
|
25 |
@Autowired |
|
26 |
private SysConfigService sysConfigService; |
|
27 |
|
|
28 |
@Override |
|
29 |
public void run(String... args) { |
|
30 |
|
|
31 |
//初始化所有的常量 |
|
32 |
List<SysConfig> list = sysConfigService.list(); |
|
33 |
|
|
34 |
if (list != null && list.size() > 0) { |
|
35 |
for (SysConfig sysConfig : list) { |
|
36 |
ConstantsContext.putConstant(sysConfig.getCode(), sysConfig.getValue()); |
|
37 |
} |
|
38 |
|
|
39 |
log.info("初始化常量" + list.size() + "条!"); |
|
40 |
} |
|
41 |
|
|
42 |
} |
|
43 |
} |