Bootstrap

基于javaweb+mysql的ssm+maven学生考勤请假管理系统(java+ssm+jsp+layui+mysql)

基于javaweb+mysql的ssm+maven学生考勤请假管理系统(java+ssm+jsp+layui+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

管理员:

教师:

学生:

辅导员:

基于javaweb+mysql的SSM+Maven学生考勤请假管理系统(java+ssm+jsp+layui+mysql)

项目介绍

本项目包含辅导员、管理员、教师、学生四种角色;

辅导员包含以下功能: 辅导员角色登录,学生管理,密码修改,请假审批,签到列表等功能。

管理员角色包含以下功能: 管理员登录,班级管理,辅导员管理,教师管理等功能。

教师角色包含以下功能: 教师登录,签到管理,请假列表,密码修改等功能。

学生角色包含以下功能: 学生角色登录,查看我的签到,修改密码,请假管理,开始签到等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:是;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+layui

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
        	params.put("code", fdy.getCode());
		}
        if(!isEmpty(fdy.getSex())){
        	params.put("sex", fdy.getSex());
		}
        if(!isEmpty(fdy.getBjId())){
        	params.put("bjId", fdy.getBjId());
		}
		//分页查询
		Pager<Fdy> pagers = fdyService.findByMap(params);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", fdy);
		return "fdy/fdy";
	}
	
	/**********************************【增删改】******************************************************/
	
	/**
	 * 跳至添加页面
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add(Model model) {
		// 查询班级列表
		Bj b = new Bj();
		b.setIsDelete(0);
		List<Bj> listAllByEntity = bjService.listAllByEntity(b);
		model.addAttribute("bjs", listAllByEntity);
		return "fdy/add";
	}

	/**
	 * 跳至详情页面
	 * @return
	 */
	@RequestMapping(value = "/view")
	public String view(Integer id,Model model) {
		Fdy obj = fdyService.load(id);
		model.addAttribute("obj",obj);
		return "fdy/view";
	}
	
	@RequestMapping(value = "/pass")
	public String pass(Integer id,HttpServletRequest request,Model model) {
       Object attribute = request.getSession().getAttribute("userId");
		
		if (attribute == null){
	 */
	@RequestMapping("/mtuichu")
	public String mtuichu(HttpServletRequest request){
		//request.getSession().invalidate();
		return "login/mLogin";
	}
	
	/**
	 * 欢迎页
	 * @return
	 */
	@RequestMapping("/welcome")
	private String welcome(){
		return "login/welcome";
	}
	
	/**
	 * 管理员登陆
	 * @param manage
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/toMlogin")
	public String toLogin(Manage manage, HttpServletRequest request, HttpServletResponse response){
		Manage byEntity = manageService.getByEntity(manage);
		if(byEntity == null){
			return "redirect:/login/mtuichu";
		}else{
			request.getSession().setAttribute("role", 1);
			request.getSession().setAttribute("username", byEntity.getUsername());
			request.getSession().setAttribute("userId", byEntity.getId());
		}
		return "login/index";
	}
	
	
	/**
	 * 除了管理员意外的登陆
	 * @param code
	 * @param password
	 * @param role
	 * @param request
	 * @param response
	 * @return
	 * @return
	 */
	@RequestMapping(value = "/exAdd")
	public String exAdd(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		manageService.insert(manage);
		return "redirect:/manage/findBySql.action";
	}
	
	
	/**
	 * 跳至修改页面
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		Manage obj = manageService.load(id);
		model.addAttribute("obj",obj);
		return "manage/update";
	}
	
	/**
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1.通过实体类修改,可以多传修改条件
		manageService.updateById(manage);
		//2.通过主键id修改
		//manageService.updateById(manage);
		return "redirect:/manage/findBySql.action";
	}
	
	/**
	 * 删除通过主键
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		///1.通过主键删除
		manageService.deleteById(id);
		/*以下是多种删除方式*/
//		//2.通过实体条件删除
//		manageService.deleteByEntity(manage);
//		//3.通过参数删除
//     //通过map查询
//		Map<String,Object> params = new HashMap<String,Object>();
//		
//        if(!isEmpty(manage.getUsername())){
			for (TeacherBj b2 : select){
				ids.add(b2.getBjId());
			}
		}
		
		if (!CollectionUtils.isEmpty(listAllByEntity)){
			
			for (Bj bj : listAllByEntity){
				
				if (!CollectionUtils.isEmpty(ids) && ids.contains(bj.getId())){
					bj.setIsCheck(1);
				}else{
					bj.setIsCheck(0);
				}
			}
		}
		
		
		model.addAttribute("bjs", listAllByEntity);
		model.addAttribute("obj",obj);
		return "teacher/update";
	}
	
	/**
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Teacher teacher,@RequestParam(value = "ids") Integer[] ids, Model model, HttpServletRequest request, HttpServletResponse response) {
		teacherService.updateById(teacher);
		if (ids != null && ids.length > 0){
			teacher.setIsDelete(0);
			//删除
			TeacherBj t = new TeacherBj();
			t.setTeacherId(teacher.getId());
			teacherBjService.deleteByEntity(t);
			for (Integer bId : ids){
				TeacherBj tb = new TeacherBj();
				tb.setBjId(bId);
				tb.setTeacherId(teacher.getId());
				teacherBjService.insert(tb);
			}
		}
		return "redirect:/teacher/findBySql.action";
	}
	
	/**
	 * 删除通过主键
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		Teacher load = teacherService.load(id);
		TeacherBj t = new TeacherBj();
	/**********************************【增删改】******************************************************/
	
	/**
	 * 跳至添加页面
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add() {
		return "record/add";
	}

	/**
	 * 跳至详情页面
	 * @return
	 */
	@RequestMapping(value = "/view")
	public String view(Integer id,Model model) {
		Record obj = recordService.load(id);
		model.addAttribute("obj",obj);
		return "record/view";
	}
	
	/**
	 * 添加执行
	 * @return
	 */
	@RequestMapping(value = "/exAdd")
	@ResponseBody
	public String exAdd(Record record, Model model, HttpServletRequest request, HttpServletResponse response) {
		String ipAdrress = getIp(request);
		Record obj = recordService.load(record.getId());
		
	      JSONObject j = new  JSONObject();
		//查看是否有ip冲突  0 未签到 1 已签到 2 请假
		Record r = new Record();
		r.setSignId(obj.getSignId());
		r.setIp(ipAdrress);
		
		Integer status = obj.getSign().getStatus();
		if (status == 1){
			j.put("res",3);
	   		return j.toString();
		}
		
	}
	
	/**********************************【增删改】******************************************************/
	
	/**
	 * 跳至添加页面
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add(Model model) {
		// 查询班级列表
		Bj b = new Bj();
		b.setIsDelete(0);
		List<Bj> listAllByEntity = bjService.listAllByEntity(b);
		model.addAttribute("bjs", listAllByEntity);
		return "fdy/add";
	}

	/**
	 * 跳至详情页面
	 * @return
	 */
	@RequestMapping(value = "/view")
	public String view(Integer id,Model model) {
		Fdy obj = fdyService.load(id);
		model.addAttribute("obj",obj);
		return "fdy/view";
	}
	
	@RequestMapping(value = "/pass")
	public String pass(Integer id,HttpServletRequest request,Model model) {
       Object attribute = request.getSession().getAttribute("userId");
		
		if (attribute == null){
			return "redirect:/login/uLogin";	
		}
		Integer userId = Integer.valueOf(attribute.toString());
		Fdy obj = fdyService.load(userId);
		model.addAttribute("obj",obj);
		return "fdy/pass";
	}
	
	
	@RequestMapping("/upass")
	@ResponseBody
	public String upass(HttpServletRequest request,String password){
      Object attribute = request.getSession().getAttribute("userId");
      JSONObject j = new  JSONObject();
	   	if (attribute == null){
	   		j.put("res", 0);
	   		return j.toString();
		}
			Integer userId = Integer.valueOf(attribute.toString());
			Fdy byId = fdyService.getById(userId);

/**
 * @ClassName:  
 * @Description: 
 */

@Controller
@RequestMapping("/teacher")
public class TeacherController extends BaseController {
	
	
	/**
	 * 依赖注入 start dao/service/===
	 */
	@Autowired
	private TeacherService teacherService;
	
	@Autowired
	private BjService bjService;
	
	@Autowired
	private TeacherBjService teacherBjService;
	
	
				  file.createNewFile();
			 }
			  files[i].transferTo(file);
		     } catch (Exception e) {
				e.printStackTrace();
				System.out.println("上传出错");
			 }
		  }
		}
	  return "";
	}
 // --------------------------------------- 华丽分割线 ------------------------------
	
	
}

/**
 * @ClassName:  
 * @Description: 
 */
	
	/**
	 * 依赖注入 start dao/service/===
	 */
	@Autowired
	private ManageService manageService;
	
	// --------------------------------------- 华丽分割线 ------------------------------
	
	/*********************************查询列表【不分页】***********************************************/
	
	/**
	 * 【不分页 => 查询列表 => 无条件】
	* @Title: listAll 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listAll")
	public String listAll(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response){
		List<Manage> listAll = manageService.listAll();
		model.addAttribute("list", listAll);
		return "manage/manage";
	}
	
	/**
	 *  【不分页=》查询列表=>有条件】
	* @Title: listByEntity 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listByEntity")
	public String listByEntity(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response){
		List<Manage> listAll = manageService.listAllByEntity(manage);
		model.addAttribute("list", listAll);
		return "manage/manage";
	}
	
		if (attribute == null){
			return "redirect:/login/uLogin";	
		}
		Integer userId = Integer.valueOf(attribute.toString());
		qj.setStatus(0);
		
		Student byId = studentService.getById(userId);
		Integer bjId = byId.getBjId();
		Fdy f = new Fdy();
		f.setBjId(bjId);
		List<Fdy> listAllByEntity = fdyService.listAllByEntity(f);
		
		qj.setBjId(bjId);
		qj.setFdyId(listAllByEntity.get(0).getId());
		qj.setStudentId(userId);
		
		qjService.insert(qj);
		return "redirect:/qj/myqj.action";
	}
	
	
	/**
	 * 跳至修改页面
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		Qj obj = qjService.load(id);
		model.addAttribute("obj",obj);
		return "qj/update";
	}
	
	/**
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Qj qj, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1.通过实体类修改,可以多传修改条件
		qjService.updateById(qj);
		//2.通过主键id修改
		//qjService.updateById(qj);
		return "redirect:/qj/myqj.action";
	}
	
	private String head(){
		return "inc/head";
	}
	
	@RequestMapping("/left")
	private String left(){
		return "inc/left";
	}
	
}

/**
 * @ClassName:  
 * @Description: 
 */

@Controller
@RequestMapping("/bj")
public class BjController extends BaseController {
	
		if (type == 1){
			model.addAttribute("mess", "该辅导员并没有负责的班级。");
		}
		return "login/message";
	}
	
	
	/**
	 * 管理员退出
	 * @param request
	 * @return
	 */
	@RequestMapping("/mtuichu")
	public String mtuichu(HttpServletRequest request){
		//request.getSession().invalidate();
		return "login/mLogin";
	}
	
	/**
	 * 欢迎页
	 * @return
	 */
	@RequestMapping("/welcome")
	private String welcome(){
		return "login/welcome";
	}
	
	/**
	 * 管理员登陆
	 * @param manage
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/toMlogin")
	public String toLogin(Manage manage, HttpServletRequest request, HttpServletResponse response){
		Manage byEntity = manageService.getByEntity(manage);
		if(byEntity == null){
			return "redirect:/login/mtuichu";
		}else{
			request.getSession().setAttribute("role", 1);
			request.getSession().setAttribute("username", byEntity.getUsername());
			request.getSession().setAttribute("userId", byEntity.getId());
		}
		return "login/index";
	}
	
	
	/**
	 * 除了管理员意外的登陆
	 * @param code
	 * @param password
	 * @param role
	 * @param request
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(TeacherBj teacherBj, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1.通过实体类修改,可以多传修改条件
		teacherBjService.updateById(teacherBj);
		//2.通过主键id修改
		//teacherBjService.updateById(teacherBj);
		return "redirect:/teacherBj/findBySql.action";
	}
	
	/**
	 * 删除通过主键
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		///1.通过主键删除
		teacherBjService.deleteById(id);
		/*以下是多种删除方式*/
//		//2.通过实体条件删除
//		teacherBjService.deleteByEntity(teacherBj);
//		//3.通过参数删除
//     //通过map查询
//		Map<String,Object> params = new HashMap<String,Object>();
//		
//        if(!isEmpty(teacherBj.getTeacherId())){
//        	params.put("teacherId", teacherBj.getTeacherId());
//		}
//       
//        if(!isEmpty(teacherBj.getBjId())){
//        	params.put("bjId", teacherBj.getBjId());
//		}
//       
//		teacherBjService.deleteByMap(params);
//		//4.状态删除
//		TeacherBj load = teacherBjService.getById(teacherBj.getId())
//		load.setIsDelete(1);
//		teacherBjService.update(load);
		//5.状态删除
		//TeacherBj load = teacherBjService.load(id);
		//load.setIsDelete(1);
		//teacherBjService.updateById(load);
		return "redirect:/teacherBj/findBySql.action";
	}
	
	// --------------------------------------- 华丽分割线 ------------------------------
	// --------------------------------------- 【下面是ajax操作的方法。】 ------------------------------
				e.printStackTrace();
				System.out.println("上传出错");
			 }
		  }
		}
	  return "";
	}
 // --------------------------------------- 华丽分割线 ------------------------------
	
	
}

/**
 * @ClassName:  
 * @Description: 
		model.addAttribute("bjs", listAllByEntity);
		model.addAttribute("obj",obj);
		return "teacher/update";
	}
	
	/**
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Teacher teacher,@RequestParam(value = "ids") Integer[] ids, Model model, HttpServletRequest request, HttpServletResponse response) {
		teacherService.updateById(teacher);
		if (ids != null && ids.length > 0){
			teacher.setIsDelete(0);
			//删除
			TeacherBj t = new TeacherBj();
			t.setTeacherId(teacher.getId());
			teacherBjService.deleteByEntity(t);
			for (Integer bId : ids){
				TeacherBj tb = new TeacherBj();
				tb.setBjId(bId);
				tb.setTeacherId(teacher.getId());
				teacherBjService.insert(tb);
			}
		}
		return "redirect:/teacher/findBySql.action";
	}
	
	/**
	 * 删除通过主键
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		Teacher load = teacherService.load(id);
		TeacherBj t = new TeacherBj();
		t.setTeacherId(id);
		teacherBjService.deleteByEntity(t);
		load.setIsDelete(1);
		teacherService.updateById(load);
		return "redirect:/teacher/findBySql.action";
	}
	
	
}
		}
        if(!isEmpty(qj.getFdyId())){
        	sql += " and fdyId like '%"+qj.getFdyId()+"%'";
		}
        if(!isEmpty(qj.getStartTime())){
        	sql += " and startTime like '%"+qj.getStartTime()+"%'";
		}
        if(!isEmpty(qj.getEndTime())){
        	sql += " and endTime like '%"+qj.getEndTime()+"%'";
		}
        if(!isEmpty(qj.getStatus())){
        	sql += " and status like '%"+qj.getStatus()+"%'";
		}
       sql += " ORDER BY ID DESC ";
		Pager<Qj> pagers = qjService.findBySqlRerturnEntity(sql);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", qj);
		return "qj/qj";
	}
	
	//findBySqlSign
	@RequestMapping(value = "/findBySqlSign")
	public String findBySqlSign(Qj qj, Model model, HttpServletRequest request, HttpServletResponse response) {
		
		//分页查询
		String sql = "SELECT * FROM qj WHERE bjId = "+qj.getBjId();
        if(!isEmpty(qj.getBjId())){
        	sql += " and bjId like '%"+qj.getBjId()+"%'";
		}
        if(!isEmpty(qj.getStudentId())){
        	sql += " and studentId like '%"+qj.getStudentId()+"%'";
		}
        if(!isEmpty(qj.getFdyId())){
        	sql += " and fdyId like '%"+qj.getFdyId()+"%'";
		}
        if(!isEmpty(qj.getStartTime())){
        	sql += " and startTime like '%"+qj.getStartTime()+"%'";
		}
        if(!isEmpty(qj.getEndTime())){
        	sql += " and endTime like '%"+qj.getEndTime()+"%'";
		}
        if(!isEmpty(qj.getStatus())){
        	sql += " and status like '%"+qj.getStatus()+"%'";
		}
       sql += " ORDER BY ID DESC ";
		Pager<Qj> pagers = qjService.findBySqlRerturnEntity(sql);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", qj);
		model.addAttribute("bjId", qj.getBjId());
		return "qj/qjSign";
	}
	
        	params.put("status", sign.getStatus());
		}
        if(!isEmpty(sign.getFdyId())){
        	params.put("fdyId", sign.getFdyId());
		}
		//分页查询
		Pager<Sign> pagers = signService.findByMap(params);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", sign);
		return "sign/sign";
	}
	
	/**********************************【增删改】******************************************************/
	
	/**
	 * 跳至添加页面
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add(Integer bjId,Model model) {
		model.addAttribute("bjId", bjId);
		return "sign/add";
	}

	/**
	 * 跳至详情页面
	 * @return
	 */
	@RequestMapping(value = "/view")
	public String view(Integer id,Model model) {
		Sign obj = signService.load(id);
		model.addAttribute("obj",obj);
		return "sign/view";
	}
	
	/**
	 * 添加执行
	 * @return
	 */
	@RequestMapping(value = "/exAdd")
	public String exAdd(Sign sign, Model model, HttpServletRequest request, HttpServletResponse response) {
	Object attribute = request.getSession().getAttribute("userId");
		
		if (attribute == null){
			return "redirect:/login/uLogin";	
		}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

;