package com.njcn.msgpush.module.system.api.config;

import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.module.system.dal.dataobject.config.ConfigDO;
import com.njcn.msgpush.module.system.service.config.ConfigService;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
@Hidden
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);
    }

}
