cn.edu.henu.rjxy.lms.controller.Acdemic.java Source code

Java tutorial

Introduction

Here is the source code for cn.edu.henu.rjxy.lms.controller.Acdemic.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.edu.henu.rjxy.lms.controller;

import cn.edu.henu.rjxy.lms.dao.CourseDao;
import cn.edu.henu.rjxy.lms.dao.StudentDao;
import cn.edu.henu.rjxy.lms.dao.TeacherDao;
import cn.edu.henu.rjxy.lms.dao.TempStudentDao;
import cn.edu.henu.rjxy.lms.dao.TempTeacherDao;
import cn.edu.henu.rjxy.lms.dao.TermCourseDao;
import cn.edu.henu.rjxy.lms.model.Classes;
import cn.edu.henu.rjxy.lms.model.Classes1;
import cn.edu.henu.rjxy.lms.model.Course;
import cn.edu.henu.rjxy.lms.model.MasterCourseResult;
import cn.edu.henu.rjxy.lms.model.PageBean;
import cn.edu.henu.rjxy.lms.model.Student;
import cn.edu.henu.rjxy.lms.model.StudentWithoutPwd;
import cn.edu.henu.rjxy.lms.model.Teacher;
import cn.edu.henu.rjxy.lms.model.TempStudent;
import cn.edu.henu.rjxy.lms.model.TempTeacher;
import cn.edu.henu.rjxy.lms.model.TempTeacherWithoutPwd;
import cn.edu.henu.rjxy.lms.model.TermCourseResult;
import cn.edu.henu.rjxy.lms.server.ClassesMethod;
import cn.edu.henu.rjxy.lms.server.CourseMethod;
import cn.edu.henu.rjxy.lms.server.StudentMethod;
import cn.edu.henu.rjxy.lms.server.TeacherMethod;
import cn.edu.henu.rjxy.lms.server.TempStudentMethod;
import cn.edu.henu.rjxy.lms.server.TempTeacherMethod;
import cn.edu.henu.rjxy.lms.server.TermClassMethod;
import cn.edu.henu.rjxy.lms.server.TermCourseMethod;
import cn.edu.henu.rjxy.lms.server.TermOpenCourseMethod;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONObject;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.security.core.context.SecurityContextHolder;
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 org.springframework.web.multipart.MultipartFile;

/**
 *
 * @author Name : liubingxu Email : 2727826327qq.com
 */
@Controller
public class Acdemic {

    //
    @RequestMapping(value = "scstu", method = RequestMethod.POST)
    public @ResponseBody String scstu(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        for (String param : params) {
            TempStudentDao.deleteTempStudentById(Integer.parseInt(param)); //
        }
        return "??";
    }

    ////
    @RequestMapping(value = "pzstu", method = RequestMethod.POST)
    public @ResponseBody String pzstu(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        System.out.println(params.length);
        for (String param : params) {
            new StudentMethod().addStudentFromtempStudent(Integer.parseInt(param));
            TempStudentDao.deleteTempStudentById(Integer.parseInt(param)); //?
        }
        return "??";
    }

    //? 
    @RequestMapping("/fh_zs_stume")
    public @ResponseBody JSONObject fhstume(HttpServletRequest request, HttpServletResponse response) {
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        System.out.println(pc);
        System.out.println(ps);
        PageBean<Student> pb = new StudentMethod().findAll(pc, ps);
        Map<String, Object> jsonMap;
        jsonMap = new HashMap<>();
        jsonMap.put("total", pb.getTr());//total   
        jsonMap.put("rows", pb.getBeanList());//rows ? list  
        //?result   ?JSONObject  
        return JSONObject.fromObject(jsonMap);
    }

    //??
    @RequestMapping("/xh_search")
    public @ResponseBody JSONObject search(HttpServletRequest request) {
        int min = Integer.parseInt(request.getParameter("min"));
        int max = Integer.parseInt(request.getParameter("max"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Student> list = StudentDao.findAllStudentBySn(min, max, pc, ps);
        Map<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //?
    @RequestMapping(value = "sc_zs_xs", method = RequestMethod.POST)
    public @ResponseBody String sczsxs(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        for (String param : params) {
            if (StudentDao.deleteStudentById(Integer.parseInt(param))) {
                System.out.println("success!");
            } else {
                System.out.println("???");
                return "1";
            }
        }
        return "??";
    }

    //??
    @RequestMapping("ls_xs_search")
    public @ResponseBody JSONObject search_ls(HttpServletRequest request) {
        int min = Integer.parseInt(request.getParameter("min"));
        int max = Integer.parseInt(request.getParameter("max"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<TempStudent> list = TempStudentDao.findAllTempStudentBySn(min, max, pc, ps);
        Map<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //
    @RequestMapping("/ls_xs_xy_ni__search")
    public @ResponseBody JSONObject search_ls1(HttpServletRequest request) {
        String min = request.getParameter("xueyuan");
        int max = Integer.parseInt(request.getParameter("nianji"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        if (pc == 0) {
            pc++;
        }
        PageBean<TempStudent> list = TempStudentDao.findAllTempStudentByCollegeGrade(min, max, pc, ps);
        Map<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        System.out.println(list.getTr());
        return JSONObject.fromObject(jsonMap);
    }

    //?
    @RequestMapping("/xy_nianji_search")
    public @ResponseBody JSONObject search_ls2(HttpServletRequest request) {
        String min = request.getParameter("xueyuan");
        System.out.println(min);
        int max = Integer.parseInt(request.getParameter("nianji"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Student> list = StudentDao.findAllStudentByCollegeSn(min, max, pc, ps);
        Map<String, Object> jsonMap;
        jsonMap = new HashMap<>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        System.out.println(list.getTr());
        return JSONObject.fromObject(jsonMap);
    }

    //??
    @RequestMapping("daochuxuesheng")
    public void daochuxuesheng(HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        session.setAttribute("state", null);
        // ????  
        response.setContentType("application/vnd.ms-excel");
        String codedFileName;
        codedFileName = "??";
        OutputStream fOut = null;
        try {
            // ????  
            codedFileName = java.net.URLEncoder.encode("", "UTF-8");
            response.setHeader("content-disposition", "attachment;filename=" + "student_messsage" + ".xls");
            HSSFWorkbook wb = new HSSFWorkbook();
            // webbooksheet,Excelsheet  
            HSSFSheet sheet = wb.createSheet("");
            // sheet0,??poiExcel?short  
            HSSFRow row = sheet.createRow((int) 0);
            // ?   
            HSSFCellStyle style = wb.createCellStyle();
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? 
            HSSFCell cell = row.createCell((short) 0);
            cell.setCellValue("?");
            cell.setCellStyle(style);
            cell = row.createCell((short) 1);
            cell.setCellValue("??");
            cell.setCellStyle(style);
            cell = row.createCell((short) 2);
            cell.setCellValue("??");
            cell.setCellStyle(style);
            cell = row.createCell((short) 3);
            cell.setCellValue("");
            cell.setCellStyle(style);
            cell = row.createCell((short) 4);
            cell.setCellValue("");
            cell.setCellStyle(style);
            cell = row.createCell((short) 5);
            cell.setCellValue("");
            cell.setCellStyle(style);
            cell = row.createCell((short) 6);
            cell.setCellValue("?");
            cell.setCellStyle(style);
            cell = row.createCell((short) 7);
            cell.setCellValue("qq");
            cell.setCellStyle(style);

            List allstudent = StudentDao.getAllStudent();

            for (int i = 0; i < allstudent.size(); i++) {
                StudentWithoutPwd tmp = (StudentWithoutPwd) allstudent.get(i);
                row = sheet.createRow((int) i + 1);
                row.createCell((short) 0).setCellValue(tmp.getStudentSn());
                row.createCell((short) 1).setCellValue(tmp.getStudentName());
                row.createCell((short) 2).setCellValue(tmp.getStudentIdcard());
                row.createCell((short) 3).setCellValue(tmp.getStudentGrade());
                row.createCell((short) 4).setCellValue((tmp.isStudentSex()) ? ("") : (""));
                row.createCell((short) 5).setCellValue(tmp.getStudentCollege());
                row.createCell((short) 6).setCellValue(tmp.getStudentTel());
                row.createCell((short) 7).setCellValue(tmp.getStudentQq());

            }

            fOut = response.getOutputStream();
            wb.write(fOut);
        } catch (UnsupportedEncodingException e1) {
        } catch (Exception e) {
        } finally {
            fOut.flush();
            fOut.close();
            session.setAttribute("state", "open");
        }
        System.out.println("?...");

    }

    @RequestMapping("/fhstume") //
    public @ResponseBody JSONObject fhstume1(HttpServletRequest request, HttpServletResponse response) {
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        System.out.println(pc);
        System.out.println(ps);
        PageBean<TempStudent> pb = TempStudentMethod.findAll(pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();//map  
        jsonMap.put("total", pb.getTr());//total   
        jsonMap.put("rows", pb.getBeanList());//rows ? list  
        //?result   ?JSONObject  
        return JSONObject.fromObject(jsonMap);
    }

    //
    @RequestMapping(value = "/fhjsxx", method = RequestMethod.GET)
    public @ResponseBody JSONObject json_test2(HttpServletRequest request, HttpServletResponse response) {
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        System.out.println(pc);
        System.out.println(ps);
        TempTeacherMethod teacherMethod = new TempTeacherMethod();
        PageBean<TempTeacher> pb = teacherMethod.findAll(pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();//map  
        jsonMap.put("total", pb.getTr());//total   
        jsonMap.put("rows", pb.getBeanList());//rows ? list  
        //?result   ?JSONObject  
        return JSONObject.fromObject(jsonMap);
    }

    //?
    @RequestMapping("sc")
    public @ResponseBody String pz(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        for (int i = 0; i < params.length; i++) {
            TempTeacherDao.deleteTempTeacherById(Integer.parseInt(params[i])); //??
        }
        return "?";
    }

    //??
    @RequestMapping(value = "pzscjs", method = RequestMethod.POST)
    public @ResponseBody String pzscjsxx(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        System.out.println(params.length + "j");
        for (int i = 0; i < params.length; i++) {
            TeacherDao.addTeacherFromTempTeacherById(Integer.parseInt(params[i]));
            TempTeacherDao.deleteTempTeacherById(Integer.parseInt(params[i]));
        }

        return "???";
    }

    //??
    @RequestMapping("fh_zs_jsme")
    public @ResponseBody JSONObject fhtecme(HttpServletRequest request, HttpServletResponse response) {
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Teacher> pb = new TeacherMethod().findAll(pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();//map  
        jsonMap.put("total", pb.getTr());//total   
        jsonMap.put("rows", pb.getBeanList());//rows ? list  
        //?result   ?JSONObject  
        return JSONObject.fromObject(jsonMap);
    }

    //???
    @RequestMapping(value = "pzsc_zs_jsxx", method = RequestMethod.POST)
    public @ResponseBody String pzsc_zs_jsxx(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        System.out.println(params.length + "j");
        for (int i = 0; i < params.length; i++) {
            if (TeacherDao.deleteTeacherById(Integer.parseInt(params[i]))) {
                System.out.println("success!");
            } else {
                System.out.println("???");
                return "1";
            }
        }
        return "???";
    }

    public static void main(String[] args) {
        List allteacher = TeacherDao.getAllTeacher();
        System.err.println(allteacher);
    }

    //???
    @RequestMapping("/zs_js_search")
    public @ResponseBody JSONObject search_ls_js(HttpServletRequest request) {
        int min = Integer.parseInt(request.getParameter("min"));
        int max = Integer.parseInt(request.getParameter("max"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Teacher> list = TeacherDao.findAllTeacherBySn(min, max, pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //???
    @RequestMapping("/ppjsxx")
    public @ResponseBody String[] ppjsxx(HttpServletRequest request, HttpServletResponse response)
            throws UnsupportedEncodingException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("UTF-8");
        String str[] = { "?" };
        String min = request.getParameter("value");
        if (TeacherDao.getTeacherNameBySn(request.getParameter("value")).equals("1")) {
            System.out.println("1");
            return str;
        } else {
            str[0] = TeacherDao.getTeacherNameBySn(request.getParameter("value"));
            System.out.println("2");
            return str;
        }
    }

    //??
    @RequestMapping("/ls_js_search")
    public @ResponseBody JSONObject search_zs(HttpServletRequest request) {
        int min = Integer.parseInt(request.getParameter("min"));
        int max = Integer.parseInt(request.getParameter("max"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<TempTeacher> list = TempTeacherDao.getTeachersBySn(min, max, pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //?
    @RequestMapping("/ls_js_xy_search")
    public @ResponseBody JSONObject ppjsxx1(HttpServletRequest request, HttpServletResponse response)
            throws UnsupportedEncodingException {
        String collage = request.getParameter("min");
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));

        PageBean<TempTeacher> list = TempTeacherDao.findAllTempTeacherByCollege(collage, pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //??
    @RequestMapping("/zs_js_xy_search")
    public @ResponseBody JSONObject ppjsxx2(HttpServletRequest request, HttpServletResponse response)
            throws UnsupportedEncodingException {
        String collage = request.getParameter("min");
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Teacher> list = TeacherDao.findAllTeacherByCollege(collage, pc, ps);
        Map<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("total", list.getTr());
        jsonMap.put("rows", list.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //??
    @RequestMapping("daochualltoxls")
    public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        System.out.println("1...");
        session.setAttribute("state", null);
        // ????  
        response.setContentType("application/vnd.ms-excel");
        String codedFileName;
        codedFileName = "??";
        OutputStream fOut = null;
        try {
            // ????  
            codedFileName = java.net.URLEncoder.encode("", "UTF-8");
            response.setHeader("content-disposition", "attachment;filename=" + "teacher_messsage" + ".xls");
            HSSFWorkbook wb = new HSSFWorkbook();
            // webbooksheet,Excelsheet  
            HSSFSheet sheet = wb.createSheet("");
            // sheet0,??poiExcel?short  
            HSSFRow row = sheet.createRow((int) 0);
            // ?   
            HSSFCellStyle style = wb.createCellStyle();
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? 
            HSSFCell cell = row.createCell((short) 0);
            cell.setCellValue("?");
            cell.setCellStyle(style);
            cell = row.createCell((short) 1);
            cell.setCellValue("??");
            cell.setCellStyle(style);
            cell = row.createCell((short) 2);
            cell.setCellValue("??");
            cell.setCellStyle(style);
            cell = row.createCell((short) 3);
            cell.setCellValue("?");
            cell.setCellStyle(style);
            cell = row.createCell((short) 4);
            cell.setCellValue("");
            cell.setCellStyle(style);
            cell = row.createCell((short) 5);
            cell.setCellValue("qq");
            cell.setCellStyle(style);
            cell = row.createCell((short) 6);
            cell.setCellValue("?");
            cell.setCellStyle(style);
            cell = row.createCell((short) 7);
            cell.setCellValue("");
            cell.setCellStyle(style);

            List allteacher = TeacherDao.getAllTeacher();

            for (int i = 0; i < allteacher.size(); i++) {
                TempTeacherWithoutPwd tmp = (TempTeacherWithoutPwd) allteacher.get(i);
                row = sheet.createRow((int) i + 1);
                row.createCell((short) 0).setCellValue(tmp.getTeacherSn());
                row.createCell((short) 1).setCellValue(tmp.getTeacherName());
                row.createCell((short) 2).setCellValue(tmp.getTeacherIdcard());
                row.createCell((short) 3).setCellValue(tmp.getTeacherPosition());
                row.createCell((short) 4).setCellValue(tmp.getTeacherCollege());
                row.createCell((short) 5).setCellValue(tmp.getTeacherQq());
                row.createCell((short) 6).setCellValue(tmp.getTeacherTel());
                row.createCell((short) 7).setCellValue((tmp.getTeacherSex()) ? ("") : (""));

            }

            fOut = response.getOutputStream();
            wb.write(fOut);
        } catch (UnsupportedEncodingException e1) {
        } catch (Exception e) {
        } finally {
            fOut.flush();
            fOut.close();
            session.setAttribute("state", "open");
        }
        System.out.println("?...");
    }

    //?  
    @RequestMapping(value = "/tjbj", method = RequestMethod.POST)
    public @ResponseBody String tjbj(HttpServletRequest request, @RequestParam("jssz[]") String[] params)
            throws UnsupportedEncodingException {
        request.setCharacterEncoding("utf-8");
        ClassesMethod cla = new ClassesMethod();
        cla.addClass(Integer.parseInt(params[0]), params[1]);
        System.out.println(params[0] + ":" + params[1] + "\n" + "?success");
        return "??";
    }

    //?
    @RequestMapping(value = "/ckbj_xx", method = RequestMethod.GET)
    public @ResponseBody JSONObject fhtjbj(HttpServletRequest request) {
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        ClassesMethod cla = new ClassesMethod();
        PageBean<Classes> pb = cla.findAll(pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();//map  
        jsonMap.put("total", pb.getTr());//total   
        jsonMap.put("rows", pb.getBeanList());//rows ? list  
        //?result   ?JSONObject  
        return JSONObject.fromObject(jsonMap);
    }

    //?
    @RequestMapping(value = "/scbj", method = RequestMethod.POST)
    public @ResponseBody String scbj(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        for (int i = 0; i < params.length; i++) {
            if (ClassesMethod.deleteClassById(Integer.parseInt(params[i]))) {
                System.out.println("success!");
            } else {
                System.out.println("???");
                return "1";
            }
        }
        return "???";
    }

    //
    @RequestMapping("tj_next_course")
    public @ResponseBody String tj_next_course(HttpServletRequest request, @RequestParam("jssz[]") String[] params,
            @RequestParam("tecgh[]") String[] tec_gh, @RequestParam("term[]") String[] term,
            @RequestParam("courseName[]") String[] courseName) {
        for (int i = 0; i < tec_gh.length; i++) {
            new TermOpenCourseMethod().saveOpenCourse(Integer.parseInt(term[0]), Integer.parseInt(params[i]));
            CourseDao.saveCourseMaster(Integer.parseInt(term[0]), tec_gh[i], courseName[i]);
        }
        return "?";
    }

    //
    @RequestMapping("next_cs_tr")
    public @ResponseBody JSONObject course_fanhui1(HttpServletRequest request, HttpServletResponse response) {
        int pc;
        if ((request.getParameter("page") == " ") || Integer.parseInt(request.getParameter("page")) == 0) {
            pc = 1;
        } else {
            pc = Integer.parseInt(request.getParameter("page"));
        }
        System.out.println(pc);
        int ps = Integer.parseInt(request.getParameter("rows"));
        String params = request.getParameter("term");
        PageBean<MasterCourseResult> pb = CourseDao.findAllCourseMaster(Integer.parseInt(params), pc, ps);
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", pb.getTr());
        jsonMap.put("rows", pb.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //?
    @RequestMapping(value = "/tj_next_bj", method = RequestMethod.POST)
    public @ResponseBody String tj_next_bj(HttpServletRequest request, @RequestParam("jssz[]") String[] params,
            @RequestParam("term[]") String[] terms) {
        for (int i = 0; i < params.length; i++) {
            new TermClassMethod().saveTermClass(Integer.parseInt(params[i]), Integer.parseInt(terms[0]));
        }
        return "sucess";
    }

    //?
    @RequestMapping(value = "/next_bj", method = RequestMethod.POST)
    public @ResponseBody JSONObject next_bj(HttpServletRequest request) {
        int pc;
        if ((request.getParameter("page") == " ") || Integer.parseInt(request.getParameter("page")) == 0) {
            pc = 1;
        } else {
            pc = Integer.parseInt(request.getParameter("page"));
        }
        int term = Integer.parseInt(request.getParameter("term"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Classes1> pb = new TermClassMethod().findAll(term, pc, ps);
        System.out.println(pb.getClass() + ":" + pb.getPs());
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", pb.getTr());
        jsonMap.put("rows", pb.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    //
    @RequestMapping(value = "courselist_add", method = RequestMethod.POST)
    public @ResponseBody String pz2(HttpServletRequest request, @RequestParam("tec_gh[]") String[] tec_gh,
            @RequestParam("classId[]") String[] classId) {
        String term = request.getParameter("xueqi");
        String courseName = request.getParameter("courseName");
        System.out.println(term);
        for (int i = 0; i < tec_gh.length; i++) {
            new TermCourseMethod().saveTermCourse(Integer.parseInt(term), tec_gh[i], courseName,
                    Integer.parseInt(classId[i]));
        }
        return "success";
    }

    //
    @RequestMapping("courselist_fanhui")
    public @ResponseBody JSONObject courselist_fanhui(HttpServletRequest request) {
        int term = Integer.parseInt(request.getParameter("term"));
        int pc = Integer.parseInt(request.getParameter("page"));
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<TermCourseResult> pb = TermCourseDao.findAll(term, pc, ps);
        System.out.println(pb.getClass() + ":" + pb.getPs());
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", pb.getTr());
        jsonMap.put("rows", pb.getBeanList());
        return JSONObject.fromObject(jsonMap);
    }

    @RequestMapping(value = "course_add", method = RequestMethod.POST)
    public @ResponseBody String pz2(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        String course_number = params[0];
        String course_name = params[1];
        String course_Ename = params[2];
        String courseType = params[3];
        int faceTeacherHourse = Integer.parseInt(params[4]);
        int testTeacherHourse = Integer.parseInt(params[5]);
        int course_cridet = Integer.parseInt(params[6]);
        System.out.println(courseType);
        CourseMethod.addCourse(course_number, course_name, course_Ename, courseType, faceTeacherHourse,
                testTeacherHourse, course_cridet);

        return "success";
    }

    //
    @RequestMapping("course_fanhui")
    public @ResponseBody JSONObject course_fanhui(HttpServletRequest request, HttpServletResponse response) {
        int pc;
        if ((request.getParameter("page") == " ") || Integer.parseInt(request.getParameter("page")) == 0) {
            pc = 1;
        } else {
            pc = Integer.parseInt(request.getParameter("page"));
        }
        int ps = Integer.parseInt(request.getParameter("rows"));
        PageBean<Course> pb = CourseMethod.findAllCourse(pc, ps);
        Map<String, Object> jsonMap = new HashMap<>();//map  
        jsonMap.put("total", pb.getTr());//total   
        jsonMap.put("rows", pb.getBeanList());//rows ? list  
        return JSONObject.fromObject(jsonMap);
    }

    //delete
    @RequestMapping("sckc")
    public @ResponseBody String sckc(HttpServletRequest request, @RequestParam("jssz[]") String[] params) {
        System.out.println(params[0]);
        for (String param : params) {
            if (CourseMethod.deleteCourse(Integer.parseInt(param))) {
                System.out.println("success!");
            } else {
                System.out.println("??");
                return "1";
            }
        }
        return "?";
    }

    //????
    @RequestMapping(value = "zdpqjsxm", method = RequestMethod.POST)
    public @ResponseBody String zdpq(HttpServletRequest request, @RequestParam("search-text") String params) {
        System.out.println(params);
        return "accccccccccccccc";
    }

    //?
    @RequestMapping("/kcdg_upload")
    public String kcdg_upload() {
        return "teacher/kcdg_upload";
    }

    //?
    @RequestMapping("/getAcdemic")
    public @ResponseBody String[] getAcdemic(HttpServletRequest request, HttpServletResponse response) {
        String sn = getCurrentUsername();
        Teacher tec = TeacherDao.getTeacherBySn(sn);
        String[] a = new String[6];
        a[0] = tec.getTeacherSn();
        a[1] = tec.getTeacherName();
        a[2] = tec.getTeacherSex() ? "" : "";
        a[3] = tec.getTeacherCollege();
        a[4] = tec.getTeacherPosition();
        a[5] = tec.getTeacherIdcard();
        return a;
    }

    public String getCurrentUsername() {
        return SecurityContextHolder.getContext().getAuthentication().getName();
    }

}