首页>代码>基于SSM框架开发的在线考试系统>/OnlineExamSystem/src/main/java/com/xhu/controller/ExamMaController.java
package com.xhu.controller;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.ibatis.annotations.Param;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xhu.entity.Student;
import com.xhu.entity.Teacher;
import com.xhu.entity.Texam;
import com.xhu.entity.User;
import com.xhu.service.ExamService;
import com.xhu.service.StudentService;

@Controller
public class ExamMaController {
	@Autowired
	ExamService examService;
	@Autowired
	StudentService studentService;

	@RequestMapping(method=RequestMethod.GET,value="exam.do")
	public String exam() {
		return "exam";
	}



	@RequestMapping(method=RequestMethod.POST,value="saveExam1.do")
	@ResponseBody
	
	public String addExam(Texam a,HttpSession session){
       
		//获取session中username的值
       String username=(String) session.getAttribute("username");

	//根据username获取accountId
        User user=examService.getUserIdByUsername(username);
         int account_id=user.getId();
 
         //根据accountId获取教师id
         Teacher teacher=examService.getTeacherIdByUserId(account_id);
   
         String teacherId=teacher.getTeacher_id();
       System.out.println(teacherId);
         
	//根据老师id获取学生id list,	
	List<String> list=studentService.getStudentService(teacherId);
	

		try{
			examService.insertExam(a, list);
		
		}catch(Exception e){
			return "error";
		}
		return "success";
		
	}
	
	@RequestMapping(method=RequestMethod.POST,value="delBat.do")
	@ResponseBody
	public String  delBat(Texam a){
		/*System.out.println("---------------------------");
	System.out.println(a.getPaperId());*/
		try{
			examService.delBats(a);
		
		}catch(Exception e){
			return "error";
		}
		return "success";
		
	}
		
	
	
	

	@RequestMapping(method=RequestMethod.POST,value="updateExam.do")
	@ResponseBody
	public String updateExam(Texam a){
	
		try{
			examService.updateExam(a);
		
		}catch(Exception e){
			return "error";
		}
		return "success";
		
	}

	@RequestMapping(method=RequestMethod.GET,value="stuExam.do")
	public String stuExam() {
		return "stuExam";
	}
	@RequestMapping(method=RequestMethod.POST,value="searchStuExam.do ")
	@ResponseBody
	public  HashMap<String, Object> searchExam(Texam e,HttpSession session){
				 	String username=(String) session.getAttribute("username");
					 //根据username的值在student表中找到对应的学生id
					 Student student=studentService.getStudentByUsername(username);
					 String s=student.getStuId();
					 e.setStuId(s);
					return examService.searchExams(e);
				}

}
最近下载更多
nyb4613  LV8 4月13日
736101636  LV19 2月27日
Lemon12138  LV1 1月19日
微信网友_6709209201250304  LV2 2023年12月11日
灵依ziNing  LV7 2023年7月29日
泓鼎168  LV19 2023年6月19日
lbsers  LV5 2023年5月6日
tujf13763823976  LV3 2023年3月28日
微信网友_6350447134265344  LV2 2023年2月15日
1222222tcyy  LV8 2022年12月17日
最近浏览更多
nyb4613  LV8 4月13日
wmxhahah  LV7 4月8日
zayuchuan 4月6日
暂无贡献等级
wddq123 4月2日
暂无贡献等级
暂无贡献等级
qqttuu  LV3 3月6日
taoshen95  LV14 2月29日
MHMHMHMH  LV12 2月28日
wahtloop 2月27日
暂无贡献等级
736101636  LV19 2月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友