package com.bonus.auth.controller;

import com.bonus.common.core.domain.R;
import com.bonus.config.SystemConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author bonus 系统配置层
 */
@RestController
@Slf4j
@RefreshScope
public class ConfigController {
    @Resource
    private SystemConfig systemConfig;

    @GetMapping("getConfig")
    public R<Object> getConfig() {
        Map<String, Object> map = new HashMap<>();
        map.put("loginConfig", systemConfig.getLoginConfig());
        map.put("registersConfig", systemConfig.getRegistersConfig());
        map.put("isAdmin", systemConfig.isAdmin());
        map.put("webSocketurl", systemConfig.getWebsocketurl());
        map.put("isAddRootCompany", systemConfig.isAddRootCompany());
        map.put("requestConfig", systemConfig.getRequestConfig());
        map.put("passwordConfig", systemConfig.getPasswordConfig());
        map.put("addAddress", systemConfig.isAddAddress());
        return R.ok(map);
    }
}
