package cn.com.qmth.stmms.student.controller;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.qmth.stmms.biz.exam.model.Exam;
import cn.com.qmth.stmms.biz.exam.service.ExamService;
import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;

@Controller
@RequestMapping("/student/condition")
public class StudentConditionController {

    @Autowired
    private ExamService examService;

    @Autowired
    private ExamSubjectService subjectService;

    @RequestMapping("/subjects")
    @ResponseBody
    public JSONArray getSubjects(@RequestParam Integer examId, HttpServletRequest request) {
        // User user = RequestUtils.getWebUser(request);
        JSONArray list = new JSONArray();
        Exam exam = examService.findById(examId);
        if (exam != null) {
            /*
             * List<Integer> ids = exam.getSubjectIdList(); for (Integer id :
             * ids) { list.add(subjectService.findById(id)); }
             */
        }
        return list;
    }

    @RequestMapping("/changemenu")
    @ResponseBody
    public void changeMenu(HttpServletRequest request, @RequestParam String menuNo) {
        request.getSession().setAttribute("menuNo", menuNo);
    }
}
