package com.qmth.qrzk.config;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qmth.qrzk.analysis.controller.QrzkConfig;
import com.qmth.qrzk.repository.user.model.User;
import com.qmth.qrzk.web.controller.BaseAjaxController;

@Controller
@RequestMapping("/scoreanalysis")
public class ScoreAnalysisController extends BaseAjaxController {
	
	private static final Logger log = Logger.getLogger(ScoreAnalysisController.class);
	
	
	@Autowired
	QrzkConfig qrzkConfig;

	@RequestMapping("/login")
	public void getInputTaskCourses(HttpServletResponse response, HttpSession session) {
		User user = getCurUser(session);
		log.info("userid:" + user.getId() + "   username:" + user.getName() + " 登录成绩分析系统");
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		StringBuilder html = new StringBuilder();
		html.append("<script language=\"javascript\">window.onload=function(){document.pay_form.submit();}</script>\n");
		html.append("<form id=\"pay_form\" name=\"pay_form\"  action=\"").append(qrzkConfig.getLoginUrl())
				.append("\" method=\"get\">\n");
		html.append("<input type=\"hidden\" name=\"id\"  value=\"" + user.getId() + "\"/>\n"); // 主键id
		html.append("<input type=\"hidden\" name=\"name\"  value=\"" + user.getName() + "\"/>\n"); // 用户名
		html.append("<input type=\"hidden\" name=\"username\"  value=\"" + user.getLoginName() + "\"/>\n"); // 登录名
		html.append("<input type=\"hidden\" name=\"role\"  value=\"qrzk\"/>\n"); // 用户类型
		html.append("</form>\n");
		try {
			response.getWriter().write(html.toString());
		} catch (IOException e) {

		}
		response.setStatus(HttpServletResponse.SC_OK);
	}


}
