package com.sptg.permissions.biz.controller;

import com.sptg.permissions.api.constant.ConfTokenName;
import com.sptg.permissions.api.entity.Conf;
import com.sptg.permissions.api.feigns.ConfFeign;
import com.sptg.permissions.biz.service.ConfServiceInterface;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * title: ConfController
 * package: com.sptg.permissions.biz.controller
 * description: 配置-控制器
 *
 *                  
 *                
 */
@RestController
@RequiredArgsConstructor
public class ConfController implements ConfFeign {

    private final ConfServiceInterface confServiceInterface;

    /* -------------------------------------------------------------------------------------------------------------- */

    @Override
    @GetMapping(value = "/conf/getFileServerHost")
    public String getFileServerHost() {
        Conf conf = this.getEntityByToken(ConfTokenName.FILE_SERVER_HOST);
        return conf.getConfValue();
    }

    @Override
    @GetMapping(value = "/conf/getEntityByToken")
    public Conf getEntityByToken(@RequestParam(value = "token") String token) {
        return this.confServiceInterface.selectEntityByToken(token);
    }
}
