package com.community.huiju.controller;

import com.community.commom.mode.ResponseBean;
import com.community.huiju.common.perproties.LoginCodePerproties;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author weiximei
 */
@RestController
@RefreshScope
@RequestMapping("/")
@Api(value = "根据code获取url API", description = "根据code获取url API")
public class LoginCodeController {

    @Autowired
    private LoginCodePerproties loginCodePerproties;

    @RequestMapping(value = "/url", method = RequestMethod.GET)
    public ResponseBean getUrl(@RequestParam String code) {
        ResponseBean responseBean = new ResponseBean();
        String url = loginCodePerproties.getLoginCode().get(code);
        Map<String, String> map = Maps.newHashMap();
        map.put("url", url);
        responseBean.addSuccess(map);
        return responseBean;
    }

}
