Java项目:基于遗传算法学校排课系统(java+Springboot+Maven+mybatis+Vue+Mysql)

源码获取:博客首页 "资源" 里下载!

一、项目简述

本系统功能包括:
排课管理,课程管理,讲师管理,班级管理,学生管理,教学资料,学习文档,在线测试,教材列表,教学设计,帮助中心等等功能。

二、项目运行

环境配置:

Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等。


 

 

 

 

 

管理员控制器:

/**
 * 管理员控制器
 */
@RestController
public class AdminController {

    @Resource(name = "adminService")
    private IAdminService adminService;

    /**
     * 管理员 查询管理员列表
     */
    @RequestMapping(value = "/admin/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Admin> qryPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        if (request.containsKey("login_name")) {
            param.put("login_name", request.getString("login_name"));
        }
        if (request.containsKey("name")) {
            param.put("name", request.getString("name"));
        }
        return adminService.qryPage(param, pageNo, pageSize);
    }

    /**
     * 管理员 添加管理员
     */
    @RequestMapping(value = "/admin/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Admin> insert(HttpRequest request) {
        Admin admin = new Admin();
        admin.setLoginName(request.getString("login_name"));
        admin.setName(request.getString("admin_name"));
        admin.setPwd(request.getString("login_name"));
        admin.setSex(request.getInteger("sex"));
        admin.setUpdateTime(new Date());
        return adminService.insert(admin, ImageUtil.stringToBytes(request.getString("admin_image")));
    }

    /**
     * 管理员 更新管理员
     */
    @RequestMapping(value = "/admin/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Admin> update(HttpRequest request) {
        Admin admin = new Admin();
        admin.setLoginName(request.getString("login_name"));
        admin.setName(request.getString("admin_name"));
        admin.setPwd(request.getString("login_name"));
        admin.setSex(request.getInteger("sex"));
        admin.setUpdateTime(new Date());
        return adminService.update(admin, ImageUtil.stringToBytes(request.getString("admin_image")));
    }

    /**
     * 管理员 删除管理员
     */
    @RequestMapping(value = "/admin/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Admin> del(HttpRequest request) {
        List<String> adminIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("admin_id_list");
        for (int i = 0; i < array.size(); i++) {
            adminIdList.add(array.getString(i));
        }
        return adminService.del(adminIdList);
    }
}

学生控制器:

/**
 * 学生控制器
 */
@RestController
public class StudentController {

    @Resource(name = "studentService")
    private IStudentService studentService;

    /**
     * 管理员 查询学生列表
     */
    @RequestMapping(value = "/student/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Student> qryPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        if (request.containsKey("student_id")) {
            param.put("student_id", request.getString("student_id"));
        }
        if (request.containsKey("name")) {
            param.put("name", request.getString("name"));
        }
        return studentService.qryPage(param, pageNo, pageSize);
    }

    @RequestMapping(value = "/student/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Student> insert(HttpRequest request) {
        Student student = new Student();
        student.setStudentId(request.getString("student_id"));
        student.setName(request.getString("student_name"));
        student.setPwd(request.getString("student_id"));
        student.setSex(request.getInteger("sex"));
        student.setClassId(request.getString("class_id"));
        student.setUpdateTime(new Date());
        return studentService.insert(student, ImageUtil.stringToBytes(request.getString("student_image")));
    }

    @RequestMapping(value = "/student/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Student> update(HttpRequest request) {
        Student student = new Student();
        student.setStudentId(request.getString("student_id"));
        student.setName(request.getString("student_name"));
        student.setPwd(request.getString("student_id"));
        student.setSex(request.getInteger("sex"));
        student.setClassId(request.getString("class_id"));
        student.setUpdateTime(new Date());
        return studentService.update(student, ImageUtil.stringToBytes(request.getString("student_image")));
    }

    @RequestMapping(value = "/student/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Student> del(HttpRequest request) {
        List<String> studentIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("student_id_list");
        for (int i = 0; i < array.size(); i++) {
            studentIdList.add(array.getString(i));
        }
        return studentService.del(studentIdList);
    }


}

教师控制器:

/**
 * 教师控制器
 */
@RestController
public class TeacherController {

    @Resource(name = "teacherService")
    private ITeacherService teacherService;

    /**
     * 管理员 查询教师列表
     */
    @RequestMapping(value = "/teacher/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Teacher> qryPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        if (request.containsKey("teacher_id")) {
            param.put("teacher_id", request.getString("teacher_id"));
        }
        if (request.containsKey("name")) {
            param.put("name", request.getString("name"));
        }
        return teacherService.qryPage(param, pageNo, pageSize);
    }

    /**
     * 管理员 添加教师
     */
    @RequestMapping(value = "/teacher/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Teacher> insert(HttpRequest request) {
        Teacher teacher = new Teacher();
        teacher.setTeacherId(request.getString("teacher_id"));
        teacher.setName(request.getString("teacher_name"));
        teacher.setPwd(request.getString("teacher_id"));
        teacher.setSex(request.getInteger("sex"));
        teacher.setUpdateTime(new Date());
        return teacherService.insert(teacher, ImageUtil.stringToBytes(request.getString("teacher_image")));
    }

    /**
     * 管理员 更新教师属性
     */
    @RequestMapping(value = "/teacher/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Teacher> update(HttpRequest request) {
        Teacher teacher = new Teacher();
        teacher.setTeacherId(request.getString("teacher_id"));
        teacher.setName(request.getString("teacher_name"));
        teacher.setPwd(request.getString("teacher_id"));
        teacher.setSex(request.getInteger("sex"));
        teacher.setUpdateTime(new Date());
        return teacherService.update(teacher, ImageUtil.stringToBytes(request.getString("teacher_image")));
    }

    /**
     * 管理员 删除教师
     */
    @RequestMapping(value = "/teacher/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Teacher> del(HttpRequest request) {
        List<String> teacherIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("teacher_id_list");
        for (int i = 0; i < array.size(); i++) {
            teacherIdList.add(array.getString(i));
        }
        return teacherService.del(teacherIdList);
    }

    /**
     * 管理员 查询所有任教老师
     */
    @RequestMapping(value = "/teacher/qryAllList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Teacher> qryAllList() {
        return teacherService.qryAllList();
    }
}

登录信息角色判断业务: 

@Controller
public class LoginController {

    @Autowired
    private UserService userService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private StudentService studentService;

    //跳转登录页面
    @GetMapping("/login")
    public String login() {
        return "login";
    }

    //登录操作
    @PostMapping("/login")
    @ResponseBody
    public Map<String, Object> login(String userName, String password, String captcha, String type, HttpSession session) {
        //判断用户名、密码、用户类型、验证码是否为空
        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(captcha) || StringUtils.isEmpty(type)) {
            return MapControl.getInstance().error("用户名或密码不能为空").getMap();
        }
        //获取系统生成的验证码
        String _captcha = (String) session.getAttribute("captcha");
        //先判断验证码是否正确
        if (!(captcha.toLowerCase()).equals(_captcha.toLowerCase())) {
            //验证码错误
            return MapControl.getInstance().error("验证码错误").getMap();
        }

        //判断用户类型
        if ("1".equals(type)) { //管理员验证登录
            User user = userService.login(userName, MD5Utils.getMD5(password)); //对密码进行加密处理,因为数据库中存储的是加密后的密码
            if (user != null) {
                session.setAttribute("user", user);
                session.setAttribute("type", 1);
                return MapControl.getInstance().success().add("data", user).getMap();
            } else {
                return MapControl.getInstance().error("用户名或密码错误").getMap();
            }
        }
        if ("2".equals(type)) { //老师验证登录
            Teacher teacher = teacherService.login(userName, MD5Utils.getMD5(password));
            if (teacher != null) {
                session.setAttribute("user", teacher);
                session.setAttribute("type", "2");
                return MapControl.getInstance().success().add("data", teacher).getMap();
            } else {
                return MapControl.getInstance().error("用户名或密码错误").getMap();
            }
        }
        if ("3".equals(type)) { //学生验证登录
            Student student = studentService.login(userName, MD5Utils.getMD5(password));
            if (student != null) {
                session.setAttribute("user", student);
                session.setAttribute("type", "3");
                return MapControl.getInstance().success().add("data", student).getMap();
            } else {
                return MapControl.getInstance().error("用户名或密码错误").getMap();
            }
        }
        return MapControl.getInstance().getMap();
    }

}

源码获取:博客首页 "资源" 里下载!

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 18
    评论
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq1334611189

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值