package cclotus.cloud.gateway.web

import com.ruoyi.common.core.domain.AjaxResult
import com.ruoyi.system.service.impl.SysConfigServiceImpl
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/config")
class SystemConfigController {

    @Autowired
    lateinit var systemConfigService: SysConfigServiceImpl

    /**
     * 获取配置
     * @param path 配置键
     * @return 配置信息
     */
    @GetMapping("/{*path}")
    fun getConfig(@PathVariable("path") path: String): AjaxResult {
        val configKey = path.removePrefix("/").replace("/", ".")
        return AjaxResult.success(systemConfigService.getConfigByKey(configKey))
    }
}
