SystemVariableService.java 857 B

123456789101112131415161718192021222324252627
  1. package com.izouma.walkchina.service;
  2. import com.izouma.walkchina.domain.SystemVariable;
  3. import com.izouma.walkchina.exception.ServiceException;
  4. import com.izouma.walkchina.repo.SystemVariableRepository;
  5. import lombok.extern.slf4j.Slf4j;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. @Service
  9. @Slf4j
  10. public class SystemVariableService {
  11. @Autowired
  12. private SystemVariableRepository systemVariableRepository;
  13. public String getStringVariable(String name) {
  14. log.info("getStringVariable {}", name);
  15. SystemVariable variable = systemVariableRepository.findByName(name);
  16. if (variable == null) {
  17. log.error("systemVariable {} is null", name);
  18. throw new ServiceException("不存在");
  19. }
  20. return variable.getValue();
  21. }
  22. }