SystemParamServiceImpl.java
1.04 KB
package com.bsth.service.impl;
import com.bsth.entity.SystemParam;
import com.bsth.repository.SystemParamRepository;
import com.bsth.service.SystemParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @author Hill
*/
@Service
@EnableScheduling
public class SystemParamServiceImpl extends BaseServiceImpl<SystemParam, Integer> implements SystemParamService {
@Autowired
private SystemParamRepository systemParamRepository;
private Map<String, String> pairs = new HashMap<>();
@Scheduled(cron = "0 0/30 * * * ?")
public void refresh() {
for (SystemParam sp : systemParamRepository.findAll()) {
pairs.put(sp.getKey(), sp.getValue());
}
}
public String getValue(String key) {
return pairs.get(key);
}
}