package com.yihu.hos.qc.controller;

import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by llh on 2017/5/9.
 */
@Controller
@RequestMapping("/report")
//@SessionAttributes(SessionAttributeKeys.CurrentUser)
public class ReportController extends BaseController {
    @Value("${service-gateway.adminUrl}")
    private String comUrl;
    @Value("${service-gateway.oauth2authorize}")
    private String oauth2authUrl;
    @Value("${service-gateway.oauth2RedictUrl}")
    private String oauth2RedictUrl;
    @Value("${service-gateway.oauth2ReportClientId}")
    private String oauth2ReportClientId;


    /**
     * 单点登录-质控报告获取
     * @param request
     * @param response
     * @param user      门户登录用户
     * @throws Exception
     */
    @RequestMapping(value = "signin",method = RequestMethod.GET)
    public void signin(HttpServletRequest request,HttpServletResponse response, String user) throws Exception
    {
//        response.sendRedirect("http://localhost:10260/oauth/authorize?response_type=token&client_id=111111&redirect_uri=http://localhost:8011/login/test&user=me");
       String redict = oauth2authUrl + "oauth/authorize?response_type=token&client_id="+oauth2ReportClientId+"&redirect_uri="+oauth2RedictUrl+"&scope=read&user="+user;
        response.sendRedirect(redict);


    }

    /**
     * 趋势分析页
     * @param model
     * @return
     */
    @RequestMapping("initial")
    public String initial(Model model) {
        model.addAttribute("contentPage", "/qc/report/trendAnalysis");
        return "pageView";
    }

}
