package com.iailab.module.infra.api.config;
|
|
import com.iailab.framework.common.pojo.CommonResult;
|
import com.iailab.module.infra.dal.dataobject.config.ConfigDO;
|
import com.iailab.module.infra.service.config.ConfigService;
|
import org.apache.commons.lang3.ObjectUtils;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
@Validated
|
public class ConfigApiImpl implements ConfigApi {
|
|
@Resource
|
private ConfigService configService;
|
|
@Override
|
public String queryConfigByCode(String configCode) {
|
ConfigDO configByKey = configService.getConfigByKey(configCode);
|
return ObjectUtils.isNotEmpty(configByKey) ? configByKey.getValue() : "";
|
}
|
|
@Override
|
public CommonResult<String> getConfigValueByKey(String key) {
|
ConfigDO config = configService.getConfigByKey(key);
|
return success(config != null ? config.getValue() : null);
|
}
|
|
|
}
|