欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

java+SpringBoot设计实现评教系统

程序员文章站 2022-03-02 16:11:49
目录主要功能运行环境效果图展示主要代码教师管理控制层登录控制层管理员控制层主要功能共有三个角色:管理员、教师、学生。管理员功能有:学生管理、教师管理、评教管理、指标管理、课程管理等。教师功能有:学生管...

主要功能

共有三个角色:管理员、教师、学生。

管理员功能有:学生管理、教师管理、评教管理、指标管理、课程管理等。

教师功能有:学生管理、指标管理、课程管理。

学生功能有:评教管理。

运行环境

jdk1.8、mysql5.x、maven3.5\3.6、idea

效果图展示

java+SpringBoot设计实现评教系统

java+SpringBoot设计实现评教系统

java+SpringBoot设计实现评教系统

java+SpringBoot设计实现评教系统

java+SpringBoot设计实现评教系统

java+SpringBoot设计实现评教系统

主要代码

教师管理控制层

@authority(roles = {role.teacher})
@controller
@requestmapping("/teacher")
public class teachercontroller {
 
    @autowired
    teacherservice teacherservice;
 
    @autowired
    subjectservice subjectservice;
 
    @requestmapping(value = {"", "/loginpage"})
    public string loginpage() {
        return "teacher/login";
    }
 
    @getmapping("/index")
    public string homepage() {
        return "teacher/public-teacher-index";
    }
 
    @getmapping("/updatepwd")
    public string updatepwd() {
        return "teacher/teacherinfo/updatepwd";
    }
 
    @getmapping("/teacherinfo")
    public string teacherinfo() {
        return "teacher/teacherinfo/teacherinfo";
    }
 
    @getmapping("/modifyinfo")
    public string modifyinfo() {
        return "teacher/teacherinfo/updateinfo";
    }
 
    @getmapping("/workapprovalinfo")
    public string workinfo() {
        return "teacher/workapproval/winfo";
    }
 
    @getmapping("/workapprovaldata")
    public string workdata() {
        return "teacher/workapproval/wdata";
    }
 
    @getmapping("/seeworkdata")
    public string seeworkdata() {
        return "teacher/workapproval/seewdata";
    }
 
    //填写表格页面
    @getmapping("/term_debriefing")
    public string termdebriefing() {
        return "teacher/fillouttable/termdebriefing";
    }
 
    @getmapping("/year_debriefing")
    public string yeardebriefing() {
        return "teacher/fillouttable/yeardebriefing";
    }
 
    @getmapping("/annual_assessment")
    public string annualassessment() {
        return "teacher/fillouttable/annualassessment";
    }
 
    @getmapping("/work_load")
    public string workload() {
        return "teacher/fillouttable/workload";
    }
 
    @getmapping("/technical_personnel")
    public string technicalpersonnel() {
        return "teacher/fillouttable/technicalpersonnel";
    }
 
    @getmapping("/term_business")
    public string termbusiness() {
        return "teacher/fillouttable/termbusiness";
    }
 
    //查看表格页面
    @getmapping("/show_year_debriefing")
    public string showyeardebriefing() {
        return "teacher/showtable/yeardebriefing";
    }
 
    @getmapping("/show_term_debriefing")
    public string showtermdebriefing() {
        return "teacher/showtable/termdebriefing";
    }
 
    @getmapping("/show_annual_assessment")
    public string showannualassessment() {
        return "teacher/showtable/annualassessment";
    }
 
    @getmapping("/show_technical_personnel")
    public string showtechnicalpersonnel() {
        return "teacher/showtable/technicalpersonnel";
    }
 
    @getmapping("/show_workload")
    public string showworkload() {
        return "teacher/showtable/workload";
    }
 
    @getmapping("/exit")
    public string exit(httpservletresponse response) {
        //将cookie 中的token 置空
        cookie cookie = new cookie("token", null);
        cookie.setpath("/");
        response.addcookie(cookie);
        return "redirect:/";
    }
 
    //打印页面
    @getmapping("/print_term_debriefing")
    public string printyeardebriefing(long year, string term, model model) {
        model.addattribute("year", year);
        model.addattribute("term", term);
        return "teacher/showtable/print/termdebriefing";
    }
 
    @getmapping("/print_year_debriefing")
    public string printtermdebriefing(long year, model model) {
        model.addattribute("year", year);
        return "teacher/showtable/print/yeardebriefing";
    }
 
 
    @getmapping("/login")
    @responsebody
    public msg login(string name, string pwd, httpsession httpsession, httpservletresponse response) throws parseexception {
        name = name.trim();
        int flag = teacherservice.teacherdl(name, pwd);
        if (flag == 200) {
            user user = new user();
            //-1表示为超管
            user.setid(0l);
            user.setrole("teacher");
            user.setusername(name);
            //生成token 存到 cookie
            cookie cookie = new cookie("token", tokenutil.createtoken(
                    user
            ));
            //该cookie无法被js读取
            cookie.sethttponly(true);
            cookie.setpath("/");
            response.addcookie(cookie);
 
 
            teacher teacher = teacherservice.selectteacher(name);
 
            httpsession.setattribute("teacherinfo", teacher);
            httpsession.setmaxinactiveinterval(3600);
        }
        return msg.success().add("info", flag);
    }
 
    //教师信息修改
    //修改教师密码
    @postmapping("/teacherupdetpwd")
    @responsebody
    public msg fun6(string oldpwd, string newpwd, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        int flag = teacherservice.teacherupdetpwd(teacher.getusername(), oldpwd, newpwd);
        return msg.success().add("flag", flag);
    }
 
    //修改教师信息
    @postmapping("/teacherupdeteinfo")
    @responsebody
    public msg updateinfo(string name, string gender, httpsession httpsession) {
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
        teacher.setname(name);
        teacher.setgender(gender);
        teacherservice.teacherupdateinfo(teacher);
        return msg.success();
    }
 
 
    //教师出差模块
    //查询所有教师出差申请信息
    @getmapping("/select_work_all")
    @responsebody
    public msg fun1(httpsession httpsession) {
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
        list<workapprovalwithblobs> list = teacherservice.selectteacherworkall(teacher.getid());
        return msg.success().add("workinfo", list);
    }
 
    //查询申请成功教师出差申请
    @getmapping("/select_work_success")
    @responsebody
    public msg fun2(httpsession httpsession) {
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
        list<workapprovalwithblobs> list = teacherservice.selectworksuccess(teacher.getid());
        return msg.success().add("workinfo", list);
    }
 
    //查询申请失败教师出差申请
    @getmapping("/select_work_failed")
    @responsebody
    public msg fun3(httpsession httpsession) {
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
        list<workapprovalwithblobs> list = teacherservice.selectworkfailed(teacher.getid());
        return msg.success().add("workinfo", list);
    }
 
    //查询已提交教师出差申请
    @getmapping("/select_work_submitted")
    @responsebody
    public msg fun4(httpsession httpsession) {
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
        list<workapprovalwithblobs> list = teacherservice.selectworksubmitted(teacher.getid());
        return msg.success().add("workinfo", list);
    }
 
    //删除申请失败的教师出差
    @postmapping("/delete_work")
    @responsebody
    public msg deletework(long id) {
        teacherservice.deleteworkbyid(id);
        return msg.success();
    }
 
    //加载报告填写页面
    @getmapping("/fillworkapproval")
    public string fun5(long id, model model) throws parseexception {
        workapprovalwithblobs workapproval = teacherservice.selectworkbyid(id);
        simpledateformat sdf = new simpledateformat("yyyy/mm/dd");
        string start = sdf.format(workapproval.getbegindate());
        string end = sdf.format(workapproval.getenddate());
        string time = start + " - " + end;
        model.addattribute("workapproval", workapproval);
        model.addattribute("time", time);
        return "teacher/workapproval/fillwdata";
    }
 
 
    //上传出差报告
    @postmapping("/fill_in_w")
    @responsebody
    public msg fun7(@requestparam("id_work") long idwork, @requestparam("news") string news, @requestparam("flag") integer flag,
                    @requestparam("file") multipartfile file) throws ioexception {
        //判断file的值是否为空
        if (file.isempty()) {
            return msg.error();
        }
 
        string filename = file.getoriginalfilename();// 获取上传文件的原名
        int size = (int) file.getsize();
        system.out.println(filename + "-->" + size);
 
        file path = new file(resourceutils.geturl("target").getpath());
        string savepath = path.getabsolutepath() + "\\classes\\static\\model";
        string savefilename = savepath + "\\" + filename;
 
//        string path = "d:/test";//文件保存路径
        file targetfile = new file(savepath);
        if (!targetfile.getparentfile().exists()) { //判断文件父目录是否存在
            targetfile.getparentfile().mkdir();
        }
        file.transferto(new file(targetfile, filename)); // 开始接受文件
 
        workapprovaldata workapprovaldata = new workapprovaldata();
        workapprovaldata.setidworkapproval(idwork);
        workapprovaldata.setnews(news);
        workapprovaldata.setdatarar(savefilename);
        //flag == 0 公有  flag == 1私有
        workapprovaldata.setflag(flag);
 
        teacherservice.insertworddata(workapprovaldata);
 
        return msg.success();
    }
 
    //查看出差报告
    @getmapping("/select_work_data")
    @responsebody
    public msg fun8(integer pn, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        pagehelper.startpage(pn, 9);
        list<workapprovaldata> list = teacherservice.selectworkdata(teacher.getidsection());
        pageinfo page = new pageinfo(list, 5);
        return msg.success().add("datainfo", page);
    }
 
    //出差附件下载
    @requestmapping(value = "/file_download")
    public responseentity<byte[]> downloadfile(string dataid, httpservletrequest req, httpservletresponse response) throws ioexception {
 
        workapprovaldata workapprovaldata = null;
 
        if (dataid != null) {
            long id = long.valueof(dataid);
            workapprovaldata = teacherservice.selectworkdatabyid(id);
        }
 
        if (workapprovaldata != null) {
            string filepath = workapprovaldata.getdatarar();
            //设置文件路径
            file file = new file(filepath);
            if (!file.exists()) {
                file.mkdirs();
            }
 
            string filename = file.getname();
            httpheaders headers = new httpheaders();
 
            headers.setcontenttype(mediatype.multipart_form_data);
 
            string encodefilename = urlencoder.encode(filename, standardcharsets.utf_8.tostring());
            headers.setcontentdispositionformdata("attachment", encodefilename);
 
            return new responseentity<byte[]>(fileutils.readfiletobytearray(file),
                    headers, httpstatus.created);
        }
        return null;
    }
 
    //学期述职
    @postmapping("/upload_term_debriefing")
    @responsebody
    public msg fun9(string year, string term, string teachingtask, string scientificresearch,
                    string otherwork, string winaward, string summary, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        debriefingwithblobs debriefingwithblobs = new debriefingwithblobs();
        debriefingwithblobs.setidteacher(teacher.getid());
        debriefingwithblobs.setyear(long.parselong(year));
        debriefingwithblobs.setterm(term);
        debriefingwithblobs.setteachingtask(teachingtask);
        debriefingwithblobs.setachievementsinscientificresearch(scientificresearch);
        debriefingwithblobs.setotherwork(otherwork);
        debriefingwithblobs.setwinaward(winaward);
        debriefingwithblobs.setsummary(summary);
        int flag = teacherservice.selecttermdebriefingflag(teacher.getid(), long.parselong(year), term);
        if (flag == 1) {
            teacherservice.updatetermdebriefing(debriefingwithblobs);
        } else {
            int i = teacherservice.inserttermdebriefing(debriefingwithblobs);
        }
        return msg.success();
    }
 
    // 工作量表相关
 
    @getmapping("/wordload")
    public string wordloadpage() {
        return "teacher/table/workload";
    }
 
 
    @getmapping("/wordloaddata")
    @responsebody
    public msg wordloaddata(
            @requestparam("year") string year,
            @requestparam("trem") string trem
    ) {
        teacher teacher = (teacher) request.getsession().getattribute("teacherinfo");
 
        return msg.success()
                .add("teacher", teacher)
                .add("workloaddto", teacherservice.getworkload(teacher.getid(), year, trem));
    }
 
    private static final logger logger = loggerfactory.getlogger(teachercontroller.class);
 
    @autowired
    httpservletrequest request;
 
    @postmapping("/wordload")
    @responsebody
    public msg wordloadsave(
            @requestbody workloaddto workloaddto
    ) {
        teacher teacher = (teacher) request.getsession().getattribute("teacherinfo");
//        logger.info("{}",workloaddto);
        teacherservice.saveworkload(workloaddto, teacher);
        return msg.success();
    }
 
    // 教师业务表
    @getmapping("/business")
    public string businesspage() {
        return "teacher/table/business";
    }
 
    @getmapping("/businessdata")
    @responsebody
    public msg businessdata(
            @requestparam("year") string year,
            @requestparam("trem") string trem
    ) {
        teacher teacher = (teacher) request.getsession().getattribute("teacherinfo");
        return teacherservice.getbusiness(teacher.getid(), year, trem)
                .add("teacher", teacher);
    }
 
    @postmapping("/business")
    @responsebody
    public msg savebusiness(
            @requestbody businessdto businessdto
    ) {
        teacher teacher = (teacher) request.getsession().getattribute("teacherinfo");
        return msg.sqlchange((int) teacherservice.savebusiness(businessdto, teacher));
    }
 
    //年度述职
    @postmapping("/upload_year_debriefing")
    @responsebody
    public msg fun10(string year, string teachingtask, string scientificresearch,
                     string otherwork, string winaward, string summary, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        debriefingyearwithblobs debriefingyear = new debriefingyearwithblobs();
        debriefingyear.setidteacher(teacher.getid());
        debriefingyear.setyear(long.parselong(year));
        debriefingyear.setteachingtask(teachingtask);
        debriefingyear.setachievementsinscientificresearch(scientificresearch);
        debriefingyear.setotherwork(otherwork);
        debriefingyear.setwinaward(winaward);
        debriefingyear.setsummary(summary);
        long flag = teacherservice.selectyeardebriefingflag(teacher.getid(), long.parselong(year));
        if (flag == 1) {
            teacherservice.updateyeardebriefing(debriefingyear);
        } else {
            int i = teacherservice.insertyeardebriefing(debriefingyear);
        }
 
        return msg.success();
    }
 
    //查询年度述职中年份
    @getmapping("/select_debriefing_year")
    @responsebody
    public msg fun11() {
        list<debriefingyear> list = teacherservice.selectdebriefingbyyear();
 
//         把年份排序
        collections.sort(list, new comparator<debriefingyear>() {
            @override
            public int compare(debriefingyear o1, debriefingyear o2) {
                return (int) (o2.getyear() - o1.getyear());
            }
        });
        return msg.success().add("year", list);
    }
 
 
    //查询指定年份的年度述职信息
    @getmapping("/select_debriefing_year_info")
    @responsebody
    public msg fun12(long year, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        debriefingyearwithblobs debriefingyear = teacherservice.selectyeardebriefinginfo(teacher.getid(), year);
        return msg.success().add("debriefinginfo", debriefingyear);
    }
 
    //查询学期述职中年份
    @getmapping("select_debriefing_term")
    @responsebody
    public msg fun13() {
        list<debriefing> list = teacherservice.selectdebriefingtermbyyear();
        list<long> temp = new arraylist<>();
        //去除重复的年份
        for (debriefing s : list) {
            if (!temp.contains(s.getyear())) {
                temp.add(s.getyear());
            }
        }
        return msg.success().add("year", temp);
    }
 
    //查询指定年份的学期述职信息
    @getmapping("/select_debriefing_term_info")
    @responsebody
    public msg fun14(long year, string term, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        debriefingwithblobs debriefing = teacherservice.selecttermdebriefinginfo(teacher.getid(), year, term);
        return msg.success().add("debriefinginfo", debriefing);
    }
 
    //年度考核
    @postmapping("/upload_annual_assessment")
    @responsebody
    public msg fun15(string personalsummary, string year, string remark, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        annualassessmentwithblobs assessment = new annualassessmentwithblobs();
        assessment.setidteacher(teacher.getid());
        assessment.setpersonalsummary(personalsummary);
        assessment.setyear(year);
        assessment.setremark(remark);
        long flag = teacherservice.selectannualassessmentflag(teacher.getid(), year);
        if (flag == 1) {
            int i = teacherservice.updateannualassessment(assessment);
        } else {
            int i = teacherservice.insertannualassessment(assessment);
        }
        return msg.success();
    }
 
    //年度专业技术人员考核表
    @postmapping("/upload_technical_personnel")
    @responsebody
    public msg fun16(string year, string mainachievements, string attendance, string rewardsandpunishments, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        technicalpersonnelwithblobs technicalpersonnelwithblobs = new technicalpersonnelwithblobs();
        technicalpersonnelwithblobs.setidteacher(teacher.getid());
        technicalpersonnelwithblobs.setyear(year);
        technicalpersonnelwithblobs.setmainachievements(mainachievements);
        technicalpersonnelwithblobs.setattendance(attendance);
        technicalpersonnelwithblobs.setrewardsandpunishments(rewardsandpunishments);
        long flag = teacherservice.selecttechnicalpersonnelflag(teacher.getid(), long.parselong(year));
        if (flag == 1) {
            int i = teacherservice.updatetechnicalpersonnel(technicalpersonnelwithblobs);
        } else {
            int i = teacherservice.inserttechnicalpersonnel(technicalpersonnelwithblobs);
        }
        return msg.success();
    }
 
    //查询年度考核年份
    @getmapping("/select_annual_assessment")
    @responsebody
    public msg fun17(httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        list<annualassessment> list = teacherservice.selectannualassessmentbyyear(teacher.getid());
        if (list.isempty()) {
            return msg.fail();
        } else {
            return msg.success().add("year", list);
        }
    }
 
    //查询指定年度考核信息
    @getmapping("/select_annualassessment_year_info")
    @responsebody
    public msg fun18(long year, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        annualassessmentwithblobs assessment = teacherservice.selectannualassessmentinfo(teacher.getid(), year);
        return msg.success().add("assessmentinfo", assessment);
    }
 
    //查询度专业技术人员考核表年份
    @getmapping("/select_technical_personnel_year")
    @responsebody
    public msg fun18(httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        list<technicalpersonnel> list = teacherservice.selecttechnicalpersonnelbyyear(teacher.getid());
        if (list.isempty()) {
            return msg.fail();
        } else {
            return msg.success().add("year", list);
        }
    }
 
    //查询度专业技术人员考核表信息
    @getmapping("/select_technicalpersonnel_year_info")
    @responsebody
    public msg fun19(long year, httpsession httpsession) {
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        technicalpersonnelwithblobs technicalpersonnelwithblobs = teacherservice.selecttechnicalpersonnelinfo(teacher.getid(), year);
        return msg.success().add("technicalpersonnel", technicalpersonnelwithblobs);
    }
 
    // 毕业设计内容
 
    // 加载上传课题页面
    @getmapping("/upload_topic_page")
    public string uploadtopic(modelmap modelmap, httpsession httpsession) {
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
 
        list<projecttype> projecttypes = teacherservice.select_allprojecttype();
        list<projectsource> projectsources = teacherservice.select_allprojectsource();
        list<specialty> specialties = teacherservice.select_allspecialty(teacher.getidsection());
 
        modelmap.addattribute("projecttypes", projecttypes);
        modelmap.addattribute("projectsources", projectsources);
        modelmap.addattribute("specialties", specialties);
        return "teacher/graduation/upload";
    }
 
 
 
    // 上传课题
    @postmapping("/up_project")
    @responsebody
    public msg fun20(string projectname, long idprojecttype, long idprojectsource, string marchspecialty, string teachernames, @requestparam("file") multipartfile file, httpservletrequest request, httpsession httpsession) throws ioexception {
        if (file == null) {
            return msg.fail().add("msg","文件上传失败");
        }
        if(teacherservice.selectprojectbyname(projectname).size()>0){
            system.out.println("上传失败");
            return msg.fail().add("msg","课题名已存在");
        }
 
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
 
        servletcontext servletcontext = request.getsession().getservletcontext();
 
        string uploadfilename = file.getoriginalfilename(); // 获取上传文件的原名
        system.out.println(uploadfilename);
 
        uploadfilename = uploadfilename.substring(uploadfilename.lastindexof(file.separator) + 1);
        system.out.println(uploadfilename);
 
        file path = new file(resourceutils.geturl("target").getpath());
        string savepath =
                path.getabsolutepath() + file.separator+"classes+"+file.separator+"static"
                                    +file.separator+"model"+file.separator + teacher.getid();
        string savefilename = savepath +file.separator + uploadfilename;
 
 
        file dirs = new file(savepath);
        //判断路径是否存在,如果不存在就创建一个
        if (!dirs.exists()) {
            dirs.mkdirs();
        }
        file.transferto(new file(dirs, uploadfilename)); // 开始接受文件
        system.out.println(teachernames);
        projectwithblobs project = new projectwithblobs();
        project.setprojectname(projectname);
        project.setidprojecttype(idprojecttype);
        project.setidprojectsource(idprojectsource);
        project.setidteacher(teacher.getid());
        project.setfilepath(savefilename);
        project.setmarchspecialty(marchspecialty.trim());
        project.setteachernames(teachernames);
        project.setselectcount(0);
        project.setselectflag(0);
        project.setverifyprojectflag(0);
        project.setreleaseflag(0);
 
        int i = teacherservice.insert_project(project);
        return msg.success();
    }
 
    //查看自己的课题发布记录
    @getmapping("/cxmyproject")
    public string fun21(modelmap modelmap, httpsession httpsession)  {
 
        teacherwithblobs teacher = (teacherwithblobs) httpsession.getattribute("teacherinfo");
 
        list<projecttype> projecttypes = teacherservice.select_allprojecttype();
        list<projectsource> projectsources = teacherservice.select_allprojectsource();
        list<specialty> specialties = teacherservice.select_allspecialty(teacher.getidsection());
 
        modelmap.addattribute("projecttypes", projecttypes);
        modelmap.addattribute("projectsources", projectsources);
        modelmap.addattribute("specialties", specialties);
 
        list<project> projects = teacherservice.selectteacherproject(teacher.getname());
 
        for (int i = 0; i < projects.size(); i++) {
            if (projects.get(i).getverifyprojectflag() == 0) projects.get(i).setprojectzt("未审核");
            else if (projects.get(i).getverifyprojectflag() == 1) projects.get(i).setprojectzt("审核未通过");
            else projects.get(i).setprojectzt("审核通过");
        }
        modelmap.addattribute("myproject", projects);
        return "teacher/graduation/section_xq/index";
    }
 
    // 发布或取消发布已审核通过的课题
    @postmapping("/fb_project")
    @responsebody
    public string fun8(long project_id, string pd,httpsession httpsession) {
 
        int s = integer.parseint(pd);
        teacherservice.updateprojectfb(project_id, s);
        if (s == 0) {
            teacherservice.deleteselectedall(project_id);
            teacherservice.updateprojectcount(project_id);
        }
        map<string, string> map = new hashmap<string, string>();
        map.put("pd", "" + 1);
        return jsonobject.tojsonstring(map);
    }
 
 
    @postmapping("del_project")
    @responsebody
    public msg deleteproject(long id) {
        teacherservice.deleteproject(id);
        return msg.success();
    }
 
    @postmapping("/updatesubject")
    @responsebody
    public msg updateproject(long id, string projectname, long idprojecttype, long idprojectsource, string marchspecialty, string teachernames, @requestparam(value = "file", required = false) multipartfile file, httpservletrequest request, httpsession httpsession) throws ioexception {
 
        //拼接 teachernames 字段
        teacherwithblobs teacher = (teacherwithblobs) request.getsession().getattribute("teacherinfo");
        string teachername = teacher.getname();
        if (teachernames == null || teachernames.trim().length() == 0) {
            teachernames = teachername;
        } else {
            teachernames = teachername + "&" + teachernames;
        }
 
        subjectwithblobs subject = null;
 
        //文件大小 为 0 则表示 文件没上传
        long size = file.getsize();
        //不更新课题文件情况
        if (file == null || size == 0) {
            subject = new subjectwithblobs();
 
            subject.setid(id);
            subject.setprojectname(projectname);
            subject.setidprojecttype(idprojecttype);
            subject.setidprojectsource(idprojectsource);
            subject.setmarchspecialty(marchspecialty);
            subject.setteachernames(teachernames);
 
            //修改后状态置 0
            subject.setselectflag(0);
            subject.setverifyprojectflag(0);
            subject.setreleaseflag(0);
 
            subjectservice.updatesubjectbyid(subject);
 
            return msg.success();
 
        } else {
 
            //获取课题
            subjectwithblobs subject1 = subjectservice.getsubjectbyid(id);
            //获取课题路径
            string oldpath = subject1.getfilepath();
            file oldfile = new file(oldpath);
 
            //如果文件存在则删除
            if (oldfile.exists()) {
                //删除成功
                if (oldfile.delete()) {
 
                } else {
                    return msg.fail();
                }
            }
 
            servletcontext servletcontext = request.getsession().getservletcontext();
 
            string uploadfilename = file.getoriginalfilename(); // 获取上传文件的原名
 
            uploadfilename = uploadfilename.substring(uploadfilename.lastindexof(file.separator) + 1);
 
            file path = new file(resourceutils.geturl("target").getpath());
//            string savepath = path.getabsolutepath() + "\\classes\\static\\model\\" + teacher.getid();
//            string savefilename = savepath + "\\" + uploadfilename;
            string savepath =
                    path.getabsolutepath() + file.separator+"classes+"+file.separator+"static"
                            +file.separator+"model"+file.separator + teacher.getid();
            string savefilename = savepath +file.separator + uploadfilename;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
            file dirs = new file(savepath);
            //判断路径是否存在,如果不存在就创建一个
            if (!dirs.exists()) {
                dirs.mkdirs();
            }
            file.transferto(new file(dirs, uploadfilename)); // 开始接受文件
 
            subjectwithblobs project = subject1;
            project.setprojectname(projectname);
            project.setidprojecttype(idprojecttype);
            project.setidprojectsource(idprojectsource);
            project.setfilepath(savefilename);
            project.setmarchspecialty(marchspecialty.trim());
            project.setteachernames(teachernames);
            //修改后状态置 0
            project.setselectflag(0);
            project.setverifyprojectflag(0);
            project.setreleaseflag(0);
 
            int i = subjectservice.updatesubjectbyid(project);
            return msg.success();
 
        }
    }
 
    @getmapping("/getsubjectbyid")
    @responsebody
    public msg getss(long id) {
        subjectwithblobs subject = subjectservice.getsubjectbyid(id);
        system.out.println(subject);
        subject.setfilepath(subject.getfilepath().substring(subject.getfilepath().lastindexof("\\") + 1));
 
        string[] teachers = subject.getteachernames().split("&");
        string teacher2 = "";
        if (teachers.length >= 2) {
            teacher2 = teachers[teachers.length - 1];
        }
 
        subject.setteachernames(teacher2);
 
        return msg.success()
                .add("subject", subject)
                ;
    }
 
    //查看自己所在教研室的课题发布记录
    @getmapping("/cxallproject")
    public string fun7(modelmap modelmap, httpsession httpsession) {
 
        teacher teacher = (teacher) httpsession.getattribute("teacherinfo");
        list<project> projects = teacherservice.selecsectionproject(teacher.getsectionname());
        for (int i = 0; i < projects.size(); i++) {
            if (projects.get(i).getverifyprojectflag() == 0) projects.get(i).setprojectzt("未审核");
            else if (projects.get(i).getverifyprojectflag() == 1) projects.get(i).setprojectzt("审核未通过");
            else projects.get(i).setprojectzt("审核通过");
        }
        modelmap.addattribute("allproject", projects);
        return "teacher/graduation/section_xq/subjectinfoto";
    }
}
 
 
 
 

登录控制层

 
 
@controller
public class logincontroller {
 
    private static final logger logger = loggerfactory.getlogger(logincontroller.class);
 
 
    @autowired
    adminservice adminservice;
 
    @getmapping("/cs")
    public string cs() {
        return "cs";
    }
 
 
    @getmapping("/login")
    public string login() {
        return "login";
    }
 
    @postmapping("/login")
    @responsebody
    public msg login(string name, string pwd, httpsession httpsession) {
        name = name.trim();
//        logger.info("{}--{}",name,pwd);
        return adminservice.login(name, pwd, httpsession);
 
    }
}

管理员控制层

@authority(roles = {role.admin, role.sadmin})
@controller
@requestmapping("/admin")
public class admincontroller {
 
    private static final logger logger = loggerfactory.getlogger(admincontroller.class);
 
    @autowired
    adminservice adminservice;
 
    @autowired
    adminmapper adminmapper;
 
    @autowired
    collegeservice collegeservice;
 
    @autowired
    sectionservice sectionservice;
 
    @autowired
    specialtyservice specialtyservice;
 
    @autowired
    classservice classservice;
 
    @autowired
    teacherservice teacherservice;
 
    @autowired
    studentservice studentservice;
 
    @autowired
    subjectservice subjectservice;
 
    @autowired
    excelservice excelservice;
 
    @autowired
    subjectrelationstudentmapper subjectrelationstudentmapper;
 
    @autowired
    httpservletrequest request;
 
    @autowired
    httpservletresponse response;
 
    @autowired
    httpsession session;
 
    @modelattribute("id_institute")
    public long getroleinfo() {
        user user = (user) request.getattribute("user");
//        logger.info("user:{}",user);
        if (user != null) {
            if (user.getrole().equals("admin")) {
                institute institute = collegeservice.selectcollege(adminmapper.selectbyprimarykey(user.getid()).getidinstitute());
                return institute.getid();
            }
            if (user.getrole().equals("sadmin")) {
                return -1;
            }
            return 0;
        } else {
            return 0;
        }
    }
 
//   admin index page   子管首页
 
    @getmapping(value = {"", "/index"})
    public string index() {
        user user = (user) request.getattribute("user");
//        logger.info("index user:{}",user);
 
        //这部分还是用了session存储部分信息 后续可能修改
        //根据 user的id 判断 渲染页面
        if (user.getid() == -1) {
            logger.info("超级管理员登录");
            session.setattribute("institutename", "超级管理员");
            session.setattribute("role", "sadmin");
            session.setattribute("username", user.getusername());
            return "admin/public-admin-index";
        }
 
        institute institute = collegeservice.selectcollege(adminmapper.selectbyprimarykey(user.getid()).getidinstitute());
        system.out.println(institute.getinstitutename());
        session.setattribute("institutename", institute.getinstitutename());
        session.setattribute("role", "admin");
        session.setattribute("username", user.getusername());
 
        return "admin/public-admin-index";
    }
 
//    exit      退出登录
 
    @getmapping("/exit")
    public string exit(httpsession httpsession) {
        //将cookie 中的token 置空
        cookie cookie = new cookie("token", null);
        cookie.setpath("/");
        response.addcookie(cookie);
        return "login";
    }
// login 在单独controller
 
//    updatepwd     更新密码
 
    @getmapping("/updatepwd")
    public string updatepwd() {
        return "admin/updatepwd";
    }
 
    @postmapping("/updatepwd")
    @responsebody
    public msg updatepwd(
            @requestbody admin admin,
            httpsession httpsession) {
 
        user user = (user) request.getattribute("user");
        adminservice.updatepwdbyusername(
                user.getusername(),
                admin.getpwd()
        );
 
        return msg.success();
    }
 
 
//    教研室
 
    @getmapping("/sectionmanagement")
    public string section() {
        return "admin/department/sectionmanagement";
    }
 
    @getmapping("/sections")
    @responsebody
    public msg getsections(@modelattribute("id_institute") long id_institute) {
        return msg.success().add("sections", sectionservice.getsections(id_institute));
    }
 
    @deletemapping("/section")
    @responsebody
    public msg delsection(@requestbody section section) {
        return msg.sqlchange((int) sectionservice.delsection(section));
    }
 
    @putmapping("/section")
    @responsebody
    public msg updatesection(@requestbody @validated section section, @modelattribute("id_institute") long id_institute) throws myexception {
        return msg.sqlchange((int) sectionservice.updatesection(section, section.getsectionname(), id_institute));
    }
 
    @postmapping("/section")
    @responsebody
    public msg addsection(@requestbody @validated section section, @modelattribute("id_institute") long id_institute) {
        return msg.sqlchange((int) sectionservice.addsection(section, id_institute));
    }
 
 
//    专业方向
 
 
    @getmapping("/specialtymanagement")
    public string specialty() {
        return "admin/department/specialtymanagement";
    }
 
    @getmapping("/specialtys")
    @responsebody
    public msg getspecialtys(
            @requestparam integer offset,
            @requestparam(required = false) long sectionid,
            @requestparam(required = false) string keyword,
            @modelattribute("id_institute") long id_institute) {
        long total = specialtyservice.getspecialtycount(offset, keyword, sectionid, id_institute);
        return msg.success()
                .add("specialtys", specialtyservice.getspecialtys(offset, keyword, sectionid, id_institute))
                .add("total", total);
    }
 
    @responsebody
    @deletemapping("/specialty")
    public msg delspecialty(
            @requestbody specialty specialty,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) specialtyservice.delspecialty(specialty, id_institute));
    }
 
    @responsebody
    @putmapping("/specialty")
    public msg putspecialty(
            @requestbody @validated({update.class}) specialty specialty,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) specialtyservice.putspecialty(specialty, id_institute));
    }
 
    @responsebody
    @postmapping("/specialty")
    public msg postspecialty(
            @requestbody @validated({add.class}) specialty specialty,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) specialtyservice.postspecialty(specialty, id_institute));
    }
 
 
//    班级
 
 
    @getmapping("/classmanagement")
    public string class() {
        return "admin/department/classmanagement";
//    //获取管理员的 学院id
//    public static long getidinstitute(modelmap modelmap) {
//        subadmin subadmin = (subadmin) modelmap.get("admin");
//        return subadmin.getidinstitute();
//    }
 
    }
 
    @responsebody
    @getmapping("/classes")
    public msg getclasses(
            @requestparam("offset") integer offset,
            @requestparam(required = false) long specialtyid,
            @requestparam(required = false) string keyword,
            @modelattribute("id_institute") long id_institute) {
        long total = classservice.getclassescount(offset, keyword, specialtyid, id_institute);
        return msg.success()
                .add("classes", classservice.getclasses(offset, keyword, specialtyid, id_institute))
                .add("total", total);
    }
 
    @responsebody
    @deletemapping("/class")
    public msg delclass(
            @requestbody myclass myclass,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) classservice.delclass(myclass, id_institute));
    }
 
    @responsebody
    @putmapping("/class")
    public msg putclass(
            @requestbody @validated({one.class}) myclass myclass,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) classservice.putclass(myclass, id_institute));
    }
 
    @responsebody
    @postmapping("/class")
    public msg postclass(
            @requestbody @validated({one.class}) myclass myclass,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) classservice.postclass(myclass, id_institute));
    }
 
 
//    课题综合管理
 
 
    @getmapping("/sourcemanagement")
    public string source() {
        return "admin/subject/sourcemanagement";
    }
 
    @responsebody
    @getmapping("/sources")
    public msg getsources() {
        return msg.success().add("sources", subjectservice.selectsubjectsources());
    }
 
    @responsebody
    @postmapping("/source")
    public msg addsource(@requestbody @validated subjectsource source) throws myexception {
        return msg.sqlchange((int) subjectservice.insertsubjectsource(source.getsourcename()));
    }
 
    @responsebody
    @deletemapping("/source")
    public msg delsource(@requestbody subjectsource source) throws myexception {
        return msg.sqlchange(subjectservice.delsubjectsource(source.getid()));
    }
 
    @responsebody
    @putmapping("/source")
    public msg updatesource(@requestbody @validated subjectsource source) {
        return msg.sqlchange(subjectservice.updatesubjectsource(source));
    }
 
    //课题类型
 
    @getmapping("/typemanagement")
    public string subjecttype() {
        return "admin/subject/typemanagement";
    }
 
    @responsebody
    @getmapping("/sujecttypes")
    public msg gettype() {
        return msg.success().add("sujecttypes", subjectservice.selectsubjecttypes());
    }
 
    @responsebody
    @postmapping("/sujecttype")
    public msg addtype(@requestbody @validated subjecttype type) throws myexception {
        return msg.sqlchange((int) subjectservice.insertsubjecttype(type.gettypename()));
    }
 
    @responsebody
    @deletemapping("/sujecttype")
    public msg deltype(@requestbody subjecttype type) throws myexception {
        return msg.sqlchange(subjectservice.delsubjecttype(type.getid()));
    }
 
    @responsebody
    @putmapping("/sujecttype")
    public msg updatetype(@requestbody @validated subjecttype type) {
        return msg.sqlchange(subjectservice.updatesubjecttype(type));
    }
 
    //课题管理
 
    @getmapping("/subjectmanagement")
    public string subject() {
        return "admin/subject/subjectmanagement";
    }
 
    @responsebody
    @getmapping("/subjects")
    public msg getsubjects(
            @requestparam integer offset,
            @requestparam(required = false) long sectionid,
            @requestparam(required = false) string keyword,
            @modelattribute("id_institute") long id_institute) {
 
        long total = subjectservice.selectsubjectscount(offset, keyword, sectionid, id_institute);
        return msg.success()
                .add("subjects", subjectservice.selectsubjects(offset, keyword, sectionid, id_institute))
                .add("total", total);
    }
 
    @responsebody
    @postmapping("/subject")
    public msg addsubject(
            @requestbody @validated(add.class) subjectwithblobs subject,
            @modelattribute("id_institute") long id_institute) throws myexception {
        return msg.sqlchange((int) subjectservice.insertsubject(subject, id_institute));
    }
 
    @responsebody
    @deletemapping("/subject")
    public msg delsubject(
            @requestbody subjectwithblobs subject,
            @modelattribute("id_institute") long id_institute) throws myexception {
        return msg.sqlchange(subjectservice.delsubject(subject, id_institute));
    }
 
    @responsebody
    @putmapping("/subject")
    public msg updatesubject(
            @requestbody @validated(update.class) subjectwithblobs subject,
            @modelattribute("id_institute") long id_institute) throws myexception {
        return msg.sqlchange(subjectservice.updatesuject(subject, id_institute));
    }
 
    //get学生选题的状态
 
    @getmapping("/srs")
    @responsebody
    public msg getselectsubjected(
            @modelattribute("id_institute") long id_institute
    ) {
        system.out.println(subjectservice.getselectsubjected(null, id_institute));
        return msg.success().add("srs", subjectservice.getselectsubjected(null, id_institute));
    }
 
    //get 选某个课题的所有学生
    @getmapping("/studentsbysubject")
    @responsebody
    public msg getstuentbysubject(
            @requestparam("id") long id,
            @modelattribute("id_institute") long id_institute
    ) {
        return subjectservice.getstuentbysubject(id, id_institute);
    }
 
//    教师管理 增删改查
 
    @getmapping("/teachermanagement")
    public string teacher() {
        return "admin/basicinfo/teachermanagement";
    }
 
    @responsebody
    @getmapping("/teachers")
    public msg getteachers(
            @requestparam integer offset,
            @requestparam(required = false) long sectionid,
            @requestparam(required = false) string keyword,
            @modelattribute("id_institute") long id_institute) {
        long total = teacherservice.selectteacherscount(offset, keyword, sectionid, id_institute);
        return msg.success()
                .add("teachers", teacherservice.selectteachers(offset, keyword, sectionid, id_institute))
                .add("total", total);
    }
 
    @responsebody
    @deletemapping("/teacher")
    public msg delteacher(
            @requestbody teacherwithblobs teacher,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) teacherservice.delteacher(teacher, id_institute));
    }
 
    @responsebody
    @postmapping("/teacher")
    public msg addteacher(
            @requestbody @validated(add.class) teacherwithblobs teacher,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) teacherservice.addteacher(teacher, id_institute));
    }
 
    @responsebody
    @putmapping("/teacher")
    public msg updateteacher(
            @requestbody @validated({update.class}) teacherwithblobs teacher,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) teacherservice.updateteacher(teacher, id_institute));
    }
 
    //教师批量教师导入
    @postmapping("/teacherexcel")
    @responsebody
    public msg addteacherexcel(
            @requestparam("excel") multipartfile excelfile,
            @modelattribute("id_institute") long id_institute
    ) throws myexception, ioexception {
        return excelservice.teacherexcelimport(excelfile, id_institute);
    }
 
    //教师批量导入模板
    @getmapping("/teacherexceldemo")
    public void getteacherexceldemo(httpservletresponse response) throws ioexception {
        excelservice.teacherexceldownload(response);
    }
 
 
//    学生管理
 
 
    @getmapping("/studentmanagement")
    public string student() {
        return "admin/basicinfo/studentmanagement";
    }
 
    @responsebody
    @getmapping("/students")
    public msg getstudents(
            @requestparam integer offset,
            @requestparam(required = false) long classid,
            @requestparam(required = false) long specialtyid,
            @requestparam(required = false) string keyword,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        long total = studentservice.selectstudentscount(offset, keyword, classid, specialtyid, id_institute);
        return msg.success()
                .add("students", studentservice.selectstudents(offset, keyword, classid, specialtyid, id_institute))
                .add("total", total);
    }
 
    @responsebody
    @deletemapping("/student")
    public msg delstudent(
            @requestbody studentwithblobs student,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) studentservice.delstudent(student, id_institute));
    }
 
    @responsebody
    @postmapping("/student")
    public msg addstudent(
            @requestbody @validated(add.class) studentwithblobs student,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) studentservice.addstudent(student, id_institute));
    }
 
    @responsebody
    @putmapping("/student")
    public msg updatestudent(
            @requestbody @validated({update.class}) studentwithblobs student,
            @modelattribute("id_institute") long id_institute
    ) throws myexception {
        return msg.sqlchange((int) studentservice.updatestudent(student, id_institute));
    }
 
    //    批量导入模板
 
    @getmapping("/studentexceldemo")
    public void getstudentexceldemo(httpservletresponse response) throws ioexception {
        excelservice.studentexceldownload(response);
    }
 
    //批量学生导入
 
    @postmapping("/studentexcel")
    @responsebody
    public msg addstudentexcel(
            @requestparam("excel") multipartfile excelfile,
            @modelattribute("id_institute") long id_institute
    ) throws myexception, ioexception {
        return excelservice.studentexcelimport(excelfile, id_institute);
    }
 
 
//    生成一览表
 
    //课题一览表
    @getmapping("/subjectexcel")
    public void getsubjectexcel(
            httpservletresponse response,
            httpservletrequest request,
            @modelattribute("id_institute") long id_institute) throws ioexception {
        excelservice.subjectexceldownload(response, request, id_institute);
    }
 
}

以上就是java+springboot设计实现评教系统的详细内容,更多关于java springboot评教系统的资料请关注其它相关文章!