ssm学生请假系统java学生请假系统源码

 
开发工具:idea (eclipse) 环境:jdk1.8  mysql5.7
数据库库连接工具 navcat

 框架:
项目整体采用spring+springMVC+mybatis框架
前端 jsp bootstrap jquery
数据库:
使用mysql数据库,数据库版本 5.5 5.6 5.7 

package controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import service.LeaveService;
import entity.Leave;
import entity.User;

@Controller
public class LeaveController {
	@Autowired
	private LeaveService leaveService;
	
	/**
	 * 跳转到学生请假页面
	 * @return
	 */
	@RequestMapping("toStuLeave")
	public String toStuLeave(){
		
		return "stu_leave";
		
	}
	/**
	 * 学生提交请假申请
	 * @param leave
	 * @param request
	 * @return
	 */
	@RequestMapping("sublitLeave")
	public String sublitLeave(Leave leave,HttpServletRequest request){
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		//我要获取当前的日期
        Date date = new Date();
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取String类型的时间
        String createdate = sdf.format(date);
        
        //保存请假
        leave.setId(UUID.randomUUID().toString());
        leave.setIsagree("未审批");
        leave.setCreatetime(createdate);
        leave.setUserid(user.getId());
		leaveService.insert(leave);
		
		return "redirect:/getStuLeaveRecord.action";
	}
	
	/**
	 * 学生个人请假记录
	 * @return
	 */
	@RequestMapping("getStuLeaveRecord")
	public String getStuLeaveRecord(HttpServletRequest request,Model model){
		//从session中获取用户信息
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		 //查询当前登录用户的请假集合
		 List<Leave> list = leaveService.selectStuList(user.getId());
		 //保存到model里面,页面取数
		 model.addAttribute("list", list);
		return "stu_record";
		
	}
	/**
	 * 查询需要审批的学生
	 * @return
	 */
	@RequestMapping("getneedLeave")
	public String needLeave(Model model){
		List<Leave> list = leaveService.selectNeedList();
		 model.addAttribute("list", list);
		return "tea_needleave";
	}
	
	/**
	 * 查询所有学生请假记录
	 * @return
	 */
	@RequestMapping("selectAllList")
	public String selectAllList(Model model){
		List<Leave> list = leaveService.selectAllList();
		 model.addAttribute("list", list);
		return "tea_allleave";
	}
	
	/**
	 * 教师审批
	 * @return
	 */
	@RequestMapping("shenpi")
	@ResponseBody
	public String shenpi(HttpServletRequest request,String leaveid,Integer type,String content2){
		//我要获取当前的日期
        Date date = new Date();
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取String类型的时间
        String createdate = sdf.format(date);
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		Leave record = leaveService.selectByPrimaryKey(leaveid);
		record.setContent2(content2);
		record.setEdittime(createdate);
		record.setEditpeople(user.getName());
		if(type==1){
			record.setIsagree("已拒绝");
		}else{
			record.setIsagree("已同意");
		}
		leaveService.updateByPrimaryKey(record);
		 
		return "success";
	}

}

 

 

 

package controller;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import entity.User;
import service.UserService;

@Controller
public class UserController {
	@Autowired
	private UserService userService;
	
    /**
     * 用户登录
     * @return
     */
	@RequestMapping("/checklogin")
	public String checkedLogin(String username,String password,Integer usertpye,Model model,HttpServletRequest request){
		//验证用户和密码是否为空
		if(StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){
			model.addAttribute("error", "用户名或密码不能为空");
			return "login";
		}
		//验证是否选了登录类型
		if(usertpye==null){
			model.addAttribute("error", "请选择用户类型");
			return "login";
		}
		//验证用户密码是否正确
		User user = userService.checkLogin(username, password, usertpye);
		if(user==null){
			model.addAttribute("error", "用户或密码错误");
			return "login";
		}
		//验证成功后,将登录信息放入session
		HttpSession session = request.getSession();
		session.setAttribute("user", user);
		
		//如果用户类型 1学生,2教师,跳转不同的页面
	     if(usertpye==1){
	    	 return "redirect:/toStuLeave.action";
	     }else if(usertpye==2){
	    	 return "redirect:/getneedLeave.action";
	     }
	     
		return "login";
	}
	
	/**
	 * 跳转到学生注册页面
	 * @return
	 */
	@RequestMapping("registerpage")
	public String registerpage(){
		
		return "register";
		
	}
	
	
	/**
	 * 学生注册
	 * @return
	 */
	@RequestMapping("register")
	public String register(User user,Model model){
		//保存注册信息
		user.setId(UUID.randomUUID().toString());
		user.setUsertype(1);
		user.setRemark("学生");
		userService.insert(user);
		model.addAttribute("error", "注册成功");
		return "register";
		
	}
	
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值