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

Java tutorial

Introduction

Here is the source code for cn.edu.henu.rjxy.lms.controller.DeanController.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.StudentDao;
import cn.edu.henu.rjxy.lms.dao.TeacherDao;
import cn.edu.henu.rjxy.lms.model.ManageResult;
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.TempTeacherWithoutPwd;
import cn.edu.henu.rjxy.lms.server.StudentMethod;
import cn.edu.henu.rjxy.lms.server.TeacherMethod;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
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;

/**
 *
 * @author Administrator
 */
@Controller
public class DeanController {
    @RequestMapping("/dean")
    public String personal_InfInformation(HttpServletRequest request, HttpServletResponse response) {
        request.setAttribute("username", SecurityContextHolder.getContext().getAuthentication().getName());

        return "dean/Index";
    }

    @RequestMapping("/stu_index2")
    public String stu2(HttpServletRequest request, HttpServletResponse response) {

        return "stu_index2";
    }

    @RequestMapping("dean/personManage")
    public String PersonManage(HttpServletRequest request, HttpServletResponse response) {
        return "dean/personManage";
    }

    @RequestMapping("/dean/MyInfo")
    public String myInfo_InfInformation(HttpServletRequest request, HttpServletResponse response) {
        String sn = getCurrentUsername();
        Teacher teacher = TeacherDao.getTeacherBySn(sn);
        request.setAttribute("sn", sn);
        request.setAttribute("name", teacher.getTeacherName());
        request.setAttribute("idCard", teacher.getTeacherIdcard());
        request.setAttribute("qq", teacher.getTeacherQq());
        request.setAttribute("tel", teacher.getTeacherTel());
        return "dean/MyInfo";
    }

    @RequestMapping("/dean/deanButton")
    public String deanButton(HttpServletRequest request, HttpServletResponse response) {

        return "dean/deanButton";
    }

    @RequestMapping("/dean/szlsjsxx")
    public String szlsjsxx(HttpServletRequest request, HttpServletResponse response) {
        return "dean/teacherManager";
    }

    @RequestMapping("/dean/szxs")
    public String szxs(HttpServletRequest request, HttpServletResponse response) {
        return "dean/studentzs";
    }

    @RequestMapping("/dean/resetpw_p")
    public @ResponseBody String resetpw_p(HttpServletRequest request, HttpServletResponse response) {
        String sn = getCurrentUsername();
        Teacher teacher = TeacherDao.getTeacherBySn(sn);
        String pw = request.getParameter("pw");
        String repw = request.getParameter("repw");
        if (!pw.equals(teacher.getTeacherPwd().toLowerCase())) {
            return "1";
        }
        if (pw.equals(repw.toLowerCase())) {
            return "2";
        }
        teacher.setTeacherPwd(repw);
        TeacherDao.updateTeacherById(teacher);
        return "3";
    }

    @RequestMapping("/dean/update")
    public @ResponseBody String update(HttpServletRequest request, HttpServletResponse response) {
        String tsn = getCurrentUsername();
        Teacher teacher = TeacherDao.getTeacherBySn(tsn);
        String qq = request.getParameter("qq");
        teacher.setTeacherQq(qq);
        String name = request.getParameter("name");
        teacher.setTeacherName(name);
        String tel = request.getParameter("tel");
        teacher.setTeacherTel(tel);
        String idCard = request.getParameter("idCard");
        teacher.setTeacherIdcard(idCard);
        TeacherDao.updateTeacherById(teacher);
        System.out.println("ssssss");
        return "0";
    }

    @RequestMapping("/dean/end")
    public @ResponseBody String end(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("end");
        return "1";
    }

    @RequestMapping("/dean/start")
    public @ResponseBody String start(HttpServletRequest request, HttpServletResponse response) throws IOException {

        try {
            Properties p = new Properties();
            String x = System.getProperty("file.separator");
            File f = new File("D:" + x + "My.ini");
            System.out.println(f.getAbsolutePath());
            if (!f.exists()) {
                f.createNewFile();
                p.setProperty("term", "201602");//??
            } else {
                System.out.println(f.getAbsolutePath());//???
                p.load(new FileInputStream(f));//?
                String term = p.getProperty("term");
                char c = term.charAt(5);
                term = term.substring(0, term.length() - 1);
                if (c == '1') {
                    term += '2';
                } else if (c == '2') {
                    term += '3';
                } else {
                    String tempString = term.substring(4);
                    Integer tempInteger = new Integer(term.substring(0, 4)) + 1;
                    term = tempInteger + tempString + "1";
                }
                p.setProperty("term", term);

            }
            p.store(new FileOutputStream(f), "");//??

        } catch (Exception e) {
            System.out.println(e.toString());
            return "0";
        }

        return "1";
    }

    //???
    @RequestMapping("dean/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("dean/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(value = "dean/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 "???";
    }

    //??
    @RequestMapping("dean/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 = "dean/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("dean/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("dean/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("dean/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("dean/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("dean/reg/hq_xy")
    public @ResponseBody String[] xy(HttpServletRequest request) {
        String str[] = { " ", "", "", "?", "",
                "?", "", "", "", "?",
                "", "", "??", "?",
                "", "", "", "",
                "", "", "", "?", "?", "",
                "", "", "", "", "",
                "", "", "?",
                "", "", "?" };

        return str;
    }

    //??,
    @RequestMapping("dean/fhxq")
    public @ResponseBody String[] xq(HttpServletRequest request) {
        Calendar now = Calendar.getInstance();
        int year = now.get(Calendar.YEAR);
        String str[] = { "", year + "01", year + "02", year + "03", year - 1 + "01", year - 1 + "02",
                year - 1 + "03", year + 1 + "01" };
        return str;
    }

    //??,
    @RequestMapping("dean/reg/fhnj")
    public @ResponseBody String[] nj(HttpServletRequest request) {
        Calendar now = Calendar.getInstance();
        int year = now.get(Calendar.YEAR);
        String str[] = { " ", year + "", year - 1 + "", year - 2 + "", year - 3 + "", year - 4 + "",
                year - 5 + "", year - 6 + "" };
        return str;
    }

    //??
    @RequestMapping("dean/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("?...");
    }

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

    @RequestMapping("dean/search")
    public @ResponseBody List<ManageResult> search(HttpServletRequest request, HttpServletResponse response) {
        String flag = (String) request.getParameter("flag");
        String text = (String) request.getParameter("text");

        List<ManageResult> lists = new LinkedList();
        List<ManageResult> l = new LinkedList();
        if ("0".equals(flag)) {//???
            List list = TeacherDao.getAllTeacher();
            for (Object ob : list) {
                ManageResult mr = new ManageResult();
                mr.copy(ob);
                mr.setControl("<a herf=\"#\"  onclick=\"manage(" + mr.getSn() + "," + 0 + ")\">???</a>");
                l.add(mr);
            }
        } else {//??
            List list = StudentDao.getAllStudent();
            list.addAll(TeacherDao.getAllTeacher());
            for (Object ob : list) {//?
                ManageResult mr = new ManageResult();
                mr.copy(ob);
                mr.setControl("<a herf=\"#\" class = \"m\" onclick=\"manage(" + mr.getSn() + "," + 1
                        + ")\">??</a>");
                l.add(mr);
            }
        }

        for (ManageResult mr : l) {
            boolean b = false;

            String x;
            x = mr.getSn();
            if (x.matches(".*" + text + ".*")) {
                b = true;
                mr.setSn("<div class=\"text-primary\">" + x + "</div>");

            }
            x = mr.getTel();
            if (x.matches(".*" + text + ".*")) {
                b = true;

                mr.setTel("<div class=\"text-primary\">" + x + "</div>");
            }
            x = mr.getQq();
            if (x.matches(".*" + text + ".*")) {
                b = true;
                mr.setQq("<div class=\"text-primary\">" + x + "</div>");
            }
            x = mr.getPosition();
            if (x.matches(".*" + text + ".*")) {
                b = true;
                mr.setPosition("<div class=\"text-primary\">" + x + "</div>");
            }
            x = mr.getName();
            if (x.matches(".*" + text + ".*")) {
                b = true;

                mr.setName("<div class=\"text-primary\">" + x + "</div>");

            }
            x = mr.getIdCard();
            if (x.matches(".*" + text + ".*")) {
                b = true;
                mr.setIdCard("<div class=\"text-primary\">" + x + "</div>");
            }

            x = mr.getSex();
            if (x.matches(".*" + text + ".*")) {
                b = true;
                mr.setSex("<div class=\"text-primary\">" + x + "</div>");
            }
            if (b) {
                lists.add(mr);
            }
        }
        System.out.println("size" + lists.size());

        return lists;
    }

    @RequestMapping("dean/all")
    public @ResponseBody List<ManageResult> all(HttpServletRequest request, HttpServletResponse response) {
        List list = StudentDao.getAllStudent();
        list.addAll(TeacherDao.getAllTeacher());
        List<ManageResult> l = new LinkedList();
        for (Object ob : list) {
            ManageResult mr = new ManageResult();
            mr.copy(ob);
            mr.setControl("<a herf=\"#\" class = \"m\" onclick=\"manage(" + mr.getSn() + "," + 1
                    + ")\">??</a>");
            l.add(mr);
        }
        return l;
    }

    @RequestMapping("dean/czmm")
    public @ResponseBody String czmm(HttpServletRequest request, HttpServletResponse response) {
        String sn = request.getParameter("sn");
        Teacher t = TeacherDao.getTeacherBySn(sn);

        if (t != null) {
            t.setTeacherPwd("e10adc3949ba59abbe56e057f20f883e");
            TeacherDao.updateTeacherById(t);
        } else {
            Student s = StudentDao.getStudentBySn(sn);
            s.setStudentPwd("e10adc3949ba59abbe56e057f20f883e");
            StudentDao.updateStudent(s);
        }

        return "0";
    }

    @RequestMapping("dean/teacher")
    public @ResponseBody List<ManageResult> All(HttpServletRequest request, HttpServletResponse response) {
        List list = TeacherDao.getAllTeacher();
        List<ManageResult> l = new LinkedList();
        String pw = request.getParameter("a");
        System.out.println(pw);
        for (Object ob : list) {
            ManageResult mr = new ManageResult();
            mr.copy(ob);
            mr.setControl("<a herf=\"#\"  onclick=\"manage(" + mr.getSn() + "," + 0 + ")\">???</a>");
            l.add(mr);
        }
        return l;
    }

    public List<String> getCurrentAuthoritiest(String sn) {
        String str[] = { "ROLE_ACDEMIC", "ROLE_COUNSELLOR", "ROLE_DEAN", "ROLE_STUDENT", "ROLE_TEACHER",
                "ROLE_TUTOR", "ROLE_ADMIN" };
        List list = new LinkedList();
        try {
            Teacher tea = TeacherDao.getTeacherBySn(sn);
            char[] ch = Integer.toBinaryString(Integer.valueOf(tea.getTeacherRoleValue())).toCharArray();
            int j = -1;
            for (int i = ch.length - 1; i >= 0; i--) {
                j++;
                if (String.valueOf(ch[i]).equals("1")) {
                    list.add(str[j]);
                }
            }
        } catch (Exception e) {
        }
        try {
            Student std = StudentDao.getStudentBySn(sn);
            System.out.println("" + std.getStudentName());
            list.add("ROLE_STUDENT");
        } catch (Exception e) {
        }
        return list;
    }

    //??Role

    @RequestMapping("/dean/rolecheck")
    public @ResponseBody String[] rolecheck(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        request.setCharacterEncoding("UTF-8");
        String p = request.getParameter("p");
        String[] a = new String[1];

        String sn = request.getParameter("sn");

        StringBuffer sb = new StringBuffer();
        sb.append("<form role=\"form\">sn" + sn + "<br><div class=\"checkbox\">");
        List<String> list = getCurrentAuthoritiest(sn);
        String str[] = { "ROLE_ACDEMIC", "ROLE_COUNSELLOR", "ROLE_DEAN", "ROLE_STUDENT", "ROLE_TEACHER",
                "ROLE_TUTOR" };
        String str2[] = { "", "", "", "", "", "" };
        String str3[] = { "1", "2", "4", "8", "16", "32" };
        // System.out.println(list);
        for (int i = 0; i < str.length; i++) {

            if (list.contains(str[i])) {
                sb.append("<label><input name=\"rolevelue\" value=\"" + str3[i]
                        + "\" type=\"checkbox\" checked = checked>" + str2[i] + "</label><br>");
            } else {
                sb.append("<label><input name=\"rolevelue\" value=\"" + str3[i] + "\"  type=\"checkbox\">" + str2[i]
                        + "</label><br>");
            }

        }

        sb.append("</div></form>");

        a[0] = sb.toString();

        return a;
    }

    //??Role

    @RequestMapping("/dean/roleset")
    public @ResponseBody String roleset(HttpServletRequest request, HttpServletResponse response) throws Exception {
        //System.out.println("logincheck");
        request.setCharacterEncoding("UTF-8");
        String sn = request.getParameter("sn");
        String rolesum = request.getParameter("rolesum");

        Teacher teacher = TeacherDao.getTeacherBySn(sn);
        List<String> list = getCurrentAuthoritiest(sn);
        if (list.contains("ROLE_ADMIN")) { //?????
            teacher.setTeacherRoleValue(Integer.valueOf(rolesum) + 64);
        } else {
            teacher.setTeacherRoleValue(Integer.valueOf(rolesum));
        }
        TeacherDao.updateTeacherById(teacher);
        return "ok";
    }

}