package com.tashow.cloud.infra.api.config;

import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.infra.service.config.ConfigService;
import com.tashow.cloud.infraapi.api.config.ConfigApi;
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.tashow.cloud.common.pojo.CommonResult.success;


@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class ConfigApiImpl implements ConfigApi {

    @Resource
    private ConfigService configService;

    @Override
    public CommonResult<String> getConfigValueByKey(String key) {
        ConfigDO config = configService.getConfigByKey(key);
        return success(config != null ? config.getValue() : null);
    }

}
