基于javaweb+mysql的springboot课程信息管理系统(java+springboot+freemarker+maven+mysql)

基于javaweb+mysql的springboot课程信息管理系统(java+springboot+freemarker+maven+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot课程信息管理系统(java+springboot+freemarker+maven+mysql)

一、项目运行

环境配置:

Jdk1.8 + Tomcat8.0 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

Springboot + SpringMVC + MyBatis + FreeMarker + JavaScript + JQuery + Ajax + maven等等。

            //MultipartFile  fileFile = request.getFile("file"); //这里是页面的name属性
            //转换成输入流
            InputStream is = file.getInputStream();
            //得到excel
            Workbook workbook = Workbook.getWorkbook(is);
            //得到sheet
            Sheet sheet = workbook.getSheet(0);
            //得到列数
            int colsNum = sheet.getColumns();
            //得到行数
            int rowsNum = sheet.getRows();
            //单元格
            Cell cell;
            Cell cell1;

            List<Map> list = new ArrayList<>();
            Map<Integer, String> map = new HashMap<Integer, String>();
            for (int i = 1; i < rowsNum; i++) {//我的excel第一行是标题,所以 i从1开始
                cell  = sheet.getCell(0,i);
                cell1 = sheet.getCell(5,i);
                Curelation curelation = new Curelation();

                curelation.setId(cell.getContents());
                curelation.setScore(cell1.getContents());
                curelationService.updateByPrimaryKey(curelation);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (BiffException e) {
            e.printStackTrace();
        }
        return "redirect:/Course/queryCourse";
    }

    @RequestMapping("/queryCourse")
    public String queryScore(HttpServletRequest request,Curelation curelation){

        curelation.setType("1");
        List<Curelation> list = curelationService.queryAll(curelation);
        request.setAttribute("list",list );
        return "ScoreList";
    }

    @RequestMapping("/teacher")
    public String teacher(HttpServletRequest request){
        User user = (User) request.getSession().getAttribute("user");
        Course course = new Course();
        course.setCourseteacher(user.getName());
        List<Course> courseList = courseService.queryAll(course);
        request.setAttribute("list",courseList);
        return "teacherDeal";

    @RequestMapping("suggeetion")
    public String suggeetion(HttpServletRequest request, Coursecomment coursecomment){

        List<Coursecomment> coursecomments = coursecommentService.queryAll(coursecomment);

        request.setAttribute("list",coursecomments);
        return "suggeetion";
    }

    @RequestMapping("view")
    public String view(HttpServletRequest request){
        User user = (User) request.getSession().getAttribute("user");

        String type = "1";

        if ("1".equals(user.getType())){
            type="2";
        }

        List<Map<String,String>> list=curelationService.courseview(type,user.getId());
        request.setAttribute("list",list);
        return "courseview";
    }

    @RequestMapping("deletecomment")
    public String deletecomment(String ID){
        coursecommentService.deleteByPrimaryKey(ID);
        return "redirect:/Course/suggeetion";
    }

    @RequestMapping("queryAll")
    public String queryAll(HttpServletRequest request, Course course){
        List<Course> list = courseService.queryAll(course);
        request.setAttribute("list",list);

        return "course";
    }

    @RequestMapping("/receive")
    public String receive(HttpServletRequest request, HttpServletResponse response, MultipartFile file){

		return data;
	}

	@RequestMapping("/quit")
	public ModelAndView quit(HttpServletRequest request) throws Exception{
		ModelAndView mav = new ModelAndView();
		HttpSession session1 = request.getSession();
		session1.invalidate();
		request.getSession().setAttribute("info", "quit");
		mav.setViewName("index");

		return mav;
	}

}

@Controller
@RequestMapping("/Role")
public class RoleController {

	@Autowired
	private RoleService depotService;

	@Autowired
	private PowerService powerService;
		return "redirect:/Role/queryAll";
	}

	@RequestMapping("/delete")
	public String delete(String ID){
		depotService.deleteByPrimaryKey(ID);
		return "redirect:/Role/queryAll";
	}

	@RequestMapping("/queryAll")
	public String queryAll(HttpServletRequest request,Role role){

		List<Role> list = depotService.QueryAll(role);
		request.setAttribute("list", list);

	   if(null != role.getRolename()){
			request.setAttribute("rolename", role.getRolename());
		}
		return "Role";
	}

	@RequestMapping("/add")
	public String  add(String roleid,String rolename,String powerContent){
		Power power1 = new Power();
		Role role = new Role();
		String powerid = String.valueOf(Math.random()).substring(2, 8);
		role.setRoleid(String.valueOf(Math.random()).substring(2, 6));
		role.setPowerid(powerid);
		role.setRolename(rolename);

		power1.setPower(powerContent);
		power1.setRoleid(powerid);
		power1.setId(String.valueOf(Math.random()).substring(2, 8));

		powerService.insert(power1);
		depotService.insert(role);
		return "redirect:/Role/queryAll";
	}

	@ResponseBody
	@RequestMapping("/queryOne")
	public String queryOne(String ID){
		JSONObject json = new JSONObject();
		Role depot = new Role();
		Power power = new Power();
		power.setId(ID);
		System.out.println(ID);
		depot.setRoleid(ID);

        HttpServletRequest servletRequest = (HttpServletRequest) req;
        HttpServletResponse servletResponse = (HttpServletResponse) res;
        HttpSession session = servletRequest.getSession();

        String path = servletRequest.getRequestURI();

        User user = (User) session.getAttribute("user");

        if(path.indexOf("/index") > -1) {
            fc.doFilter(servletRequest, servletResponse);
            return;
        }

        if(path.indexOf("/Login") > -1) {
            fc.doFilter(servletRequest, servletResponse);
            return;
        }

        if(path.contains(".css") || path.contains(".js")) {
            fc.doFilter(servletRequest, servletResponse);
            return;
        }
        if (user == null ) {
            // 跳转到登陆页?
            servletResponse.sendRedirect("/ChooseCourse/index");
            servletRequest.getSession().setAttribute("info", "请先登陆本系统再进行操作!");
        } else {
            // 已经登陆,继续此次请求
            fc.doFilter(req, res);
        }

    }

    public void init(FilterConfig arg0) throws ServletException {
        // TODO Auto-generated method stub

    }

}

        coursecomment.setUserid(user.getName());
        coursecomment.setId(String.valueOf(Math.random()).substring(2,10));
        coursecommentService.insert(coursecomment);
        return "redirect:/Course/suggeetion";
    }

    @ResponseBody
    @RequestMapping("jsoncourse")
    public String jsoncourse(HttpServletRequest request, Curelation course){
        User user = (User) request.getSession().getAttribute("user");
        /*String type = "1";

        if ("1".equals(user.getType())){
            type="2";
        }
        course.setType(type);
        course.setUserid(user.getId());*/
        List<Curelation> curelationList = curelationService.queryAll(course);
        List<Course> dataList = new ArrayList<>();
        for (int i = 0; i < curelationList.size(); i++) {
            Course curelation = courseService.selectByPrimaryKey(curelationList.get(i).getCourseid());
            dataList.add(curelation);
        }

        JSONObject json = new JSONObject();
        return json.toJSONString(dataList);
    }

    @RequestMapping("suggeetion")
    public String suggeetion(HttpServletRequest request, Coursecomment coursecomment){

        List<Coursecomment> coursecomments = coursecommentService.queryAll(coursecomment);

        request.setAttribute("list",coursecomments);
        return "suggeetion";
    }

    @RequestMapping("view")
    public String view(HttpServletRequest request){
        User user = (User) request.getSession().getAttribute("user");

        String type = "1";

        if ("1".equals(user.getType())){
            type="2";
        }

        List<Map<String,String>> list=curelationService.courseview(type,user.getId());
        request.setAttribute("list",list);
		return "NoticeAdd";
	}

	@RequestMapping("/modify")
	public String modify(HttpServletRequest request,Notice notice){
		List<Notice> noticeList = noticeService.queryAll(notice);
		request.setAttribute("list",noticeList);
		return "noticeModfiy";
	}

	@RequestMapping("/update")
	public String update(HttpServletRequest request,Notice notice){
		User user = (User) request.getSession().getAttribute("user");
		notice.setUserid(user.getId());
		notice.setCreatdate(DateUtil.getStringToday());
		noticeService.update(notice);
		return "redirect:/Notice/modify";
	}

	@RequestMapping("/delete")
	public String delete(HttpServletRequest request,Notice notice){
		List<Notice> noticeList = noticeService.queryAll(notice);
		request.setAttribute("list",noticeList);
		return "noticeDelete";
	}

	@RequestMapping("/delete1")
	public String delete1(String ID){
		noticeService.delete(ID);
		return "redirect:/Notice/delete";
	}

	@ResponseBody
	@RequestMapping("/queryOne")
	public String queryOne(String id){
		System.out.println("=================="+id);

		Notice notice = new Notice();
		notice.setId(id);
		List<Notice> noticeList = noticeService.queryAll(notice);
		JSONObject json = new JSONObject();
		return json.toJSONString(noticeList.get(0));
	}

	@RequestMapping("/add1")
	public String  add(HttpServletRequest request,String Content,String biaoti) throws Exception{

@Controller
@RequestMapping("/Notice")
public class NoticeController {

	@Autowired
	private NoticeService noticeService;

	@RequestMapping("/add")
	public String toAdd(){
		return "NoticeAdd";
	}

	@RequestMapping("/modify")
	public String modify(HttpServletRequest request,Notice notice){
		List<Notice> noticeList = noticeService.queryAll(notice);
		request.setAttribute("list",noticeList);
		return "noticeModfiy";
	}

	@RequestMapping("/update")
	public String update(HttpServletRequest request,Notice notice){
		User user = (User) request.getSession().getAttribute("user");
		notice.setUserid(user.getId());
		notice.setCreatdate(DateUtil.getStringToday());
		noticeService.update(notice);
		return "redirect:/Notice/modify";
	}

	@RequestMapping("/delete")
	public String delete(HttpServletRequest request,Notice notice){
		List<Notice> noticeList = noticeService.queryAll(notice);

@Controller
@RequestMapping("/Course")
public class CourseController {

    @Autowired
    private CourseService courseService;
    @Autowired
    private CurelationService curelationService;

    @Autowired
    private CoursecommentService coursecommentService;

    @ResponseBody
    @RequestMapping("/queryOneCom")
    public String queryOneCom(String ID){
        Coursecomment course = new Coursecomment();
        course.setId(ID);
        System.out.println("===================================="+ID);
        List<Coursecomment> list = coursecommentService.queryAll(course);
        course = list.get(0);
        JSONObject json = new JSONObject();
        return json.toJSONString(course);
    }

    @RequestMapping("addComment")
    public String addComment(HttpServletRequest request, Coursecomment coursecomment){
        User user = (User) request.getSession().getAttribute("user");
        coursecomment.setCreatetime(DateUtil.getStringToday());
        coursecomment.setUserid(user.getName());
        coursecomment.setId(String.valueOf(Math.random()).substring(2,10));
        coursecommentService.insert(coursecomment);
        return "redirect:/Course/suggeetion";
    }

    @ResponseBody
    @RequestMapping("jsoncourse")
    public String jsoncourse(HttpServletRequest request, Curelation course){
        User user = (User) request.getSession().getAttribute("user");
        /*String type = "1";

        if ("1".equals(user.getType())){
            type="2";
        }
        course.setType(type);
    private CoursecommentService coursecommentService;

    @ResponseBody
    @RequestMapping("/queryOneCom")
    public String queryOneCom(String ID){
        Coursecomment course = new Coursecomment();
        course.setId(ID);
        System.out.println("===================================="+ID);
        List<Coursecomment> list = coursecommentService.queryAll(course);
        course = list.get(0);
        JSONObject json = new JSONObject();
        return json.toJSONString(course);
    }

    @RequestMapping("addComment")
    public String addComment(HttpServletRequest request, Coursecomment coursecomment){
        User user = (User) request.getSession().getAttribute("user");
        coursecomment.setCreatetime(DateUtil.getStringToday());
        coursecomment.setUserid(user.getName());
        coursecomment.setId(String.valueOf(Math.random()).substring(2,10));
        coursecommentService.insert(coursecomment);
        return "redirect:/Course/suggeetion";
    }

    @ResponseBody
    @RequestMapping("jsoncourse")
    public String jsoncourse(HttpServletRequest request, Curelation course){
        User user = (User) request.getSession().getAttribute("user");
        /*String type = "1";

        if ("1".equals(user.getType())){
            type="2";
        }
        course.setType(type);
        course.setUserid(user.getId());*/
        List<Curelation> curelationList = curelationService.queryAll(course);
        List<Course> dataList = new ArrayList<>();
        for (int i = 0; i < curelationList.size(); i++) {
            Course curelation = courseService.selectByPrimaryKey(curelationList.get(i).getCourseid());
            dataList.add(curelation);
        }

        JSONObject json = new JSONObject();
        return json.toJSONString(dataList);
    }

    @RequestMapping("suggeetion")
    public String suggeetion(HttpServletRequest request, Coursecomment coursecomment){

        List<Coursecomment> coursecomments = coursecommentService.queryAll(coursecomment);

		}
		return "student";
	}

	@RequestMapping("/addteacher")
	public String  addUser(User user){

	    String passWord = "123456";
		user.setPassword(passWord);
		user.setType(Constans.TEACHER);
		userService.insert(user);
		return "redirect:/User/teacher";
	}

	@RequestMapping("/addstudent")
	public String  addStudent(User user){

		String passWord = "123456";
		user.setPassword(passWord);
		user.setType(Constans.STUDENT);
		userService.insert(user);
		return "redirect:/User/student";
	}

	@ResponseBody
	@RequestMapping("/queryOne")
	public String queryOne(String ID){
		User user = new User();
		user.setId(ID);
		List<User> list = userService.QueryAll(user);
		user = list.get(0);
		JSONObject json = new JSONObject();
		String data = json.toJSONString(user);

		return data;
	}

	@RequestMapping("/quit")
	public ModelAndView quit(HttpServletRequest request) throws Exception{
		ModelAndView mav = new ModelAndView();
		HttpSession session1 = request.getSession();
		session1.invalidate();
		request.getSession().setAttribute("info", "quit");
		mav.setViewName("index");

		return mav;
	}

}
		depotService.update(role);
		List<Role> list = depotService.QueryAll(role);
		Role role1 = list.get(0);
		Power power = new Power();
		if(powerContent.indexOf("110") != -1){
			powerContent = powerContent + ",1100";
		}
		if(powerContent.indexOf("120") != -1){
			powerContent = powerContent + ",1200";
		}
		if(powerContent.indexOf("130") != -1){
			powerContent = powerContent + ",1300";
		}
		if(powerContent.indexOf("140") != -1){
			powerContent = powerContent + ",1400";
		}
		if(powerContent.indexOf("150") != -1){
			powerContent = powerContent + ",1500";
		}
		power.setPower(powerContent);
		power.setRoleid(role1.getPowerid());
		powerService.update(power);
		return "redirect:/Role/queryAll";
	}

	@RequestMapping("/delete")
	public String delete(String ID){
		depotService.deleteByPrimaryKey(ID);
		return "redirect:/Role/queryAll";
	}

	@RequestMapping("/queryAll")
	public String queryAll(HttpServletRequest request,Role role){

		List<Role> list = depotService.QueryAll(role);
		request.setAttribute("list", list);

	   if(null != role.getRolename()){
			request.setAttribute("rolename", role.getRolename());
		}
		return "Role";
	}

	@RequestMapping("/add")
	public String  add(String roleid,String rolename,String powerContent){
		Power power1 = new Power();
		Role role = new Role();
		String powerid = String.valueOf(Math.random()).substring(2, 8);
		role.setRoleid(String.valueOf(Math.random()).substring(2, 6));
		role.setPowerid(powerid);
		role.setRolename(rolename);

		power1.setPower(powerContent);

@Controller
@RequestMapping("/Role")
public class RoleController {

	@Autowired
	private RoleService depotService;

	@Autowired
	private PowerService powerService;

	@RequestMapping("/update")
	public String update(String id,String rolename,String powerContent){
		Role role = new Role();
		role.setRoleid(id);
		role.setRolename(rolename);
		depotService.update(role);
		List<Role> list = depotService.QueryAll(role);
		Role role1 = list.get(0);
		Power power = new Power();
		if(powerContent.indexOf("110") != -1){
			powerContent = powerContent + ",1100";
		}
		if(powerContent.indexOf("120") != -1){
			powerContent = powerContent + ",1200";
		}
		if(powerContent.indexOf("130") != -1){
			powerContent = powerContent + ",1300";
		}
		if(powerContent.indexOf("140") != -1){
			powerContent = powerContent + ",1400";
		}
		if(powerContent.indexOf("150") != -1){
			powerContent = powerContent + ",1500";
		}
		power.setPower(powerContent);
		power.setRoleid(role1.getPowerid());
		powerService.update(power);
		return "redirect:/Role/queryAll";
	}

	@RequestMapping("/delete")
	public String delete(String ID){
		depotService.deleteByPrimaryKey(ID);
	@RequestMapping("/addteacher")
	public String  addUser(User user){

	    String passWord = "123456";
		user.setPassword(passWord);
		user.setType(Constans.TEACHER);
		userService.insert(user);
		return "redirect:/User/teacher";
	}

	@RequestMapping("/addstudent")
	public String  addStudent(User user){

		String passWord = "123456";
		user.setPassword(passWord);
		user.setType(Constans.STUDENT);
		userService.insert(user);
		return "redirect:/User/student";
	}

	@ResponseBody
	@RequestMapping("/queryOne")
	public String queryOne(String ID){
		User user = new User();
		user.setId(ID);
		List<User> list = userService.QueryAll(user);
		user = list.get(0);
		JSONObject json = new JSONObject();
		String data = json.toJSONString(user);

		return data;
	}

	@RequestMapping("/quit")
	public ModelAndView quit(HttpServletRequest request) throws Exception{
		ModelAndView mav = new ModelAndView();
		HttpSession session1 = request.getSession();
		session1.invalidate();
		request.getSession().setAttribute("info", "quit");
		mav.setViewName("index");

		return mav;
	}

}

		List<Notice> list = noticeService.queryAll(notice);

		notice = list.get(0);

		User user = userService.selectByPrimaryKey(notice.getUserid());

		notice.setUserid(user.getName());
		request.getSession().setAttribute("notice", notice);

		return "Main";
	}

	@RequestMapping("/changePa")
	public String res1(){
		return "changePass";
	}

	@RequestMapping("/Login")
	public ModelAndView login(HttpServletRequest request,String id,String password) throws Exception{

		ModelAndView mav = new ModelAndView();

		User user1 = userService.selectByPrimaryKey(id);

		if(user1 == null || !password.equals(user1.getPassword())){
			mav.setViewName("index");
		    request.getSession().setAttribute("info", "error");
			return mav;
		}else{
			Role role = new Role();
			role.setRoleid(user1.getRoleid());
			List<Role> list =roleService.QueryAll(role);
			role =list.get(0);
			request.getSession().setAttribute("roleName", role.getRolename());
			Power power = powerService.selectByPrimaryKey(role.getPowerid());

			if(!StringUtil.isNullOrEmpty(power.getPower())){
				request.getSession().setAttribute("power", power.getPower());
			}
    public String queryOneCom(String ID){
        Coursecomment course = new Coursecomment();
        course.setId(ID);
        System.out.println("===================================="+ID);
        List<Coursecomment> list = coursecommentService.queryAll(course);
        course = list.get(0);
        JSONObject json = new JSONObject();
        return json.toJSONString(course);
    }

    @RequestMapping("addComment")
    public String addComment(HttpServletRequest request, Coursecomment coursecomment){
        User user = (User) request.getSession().getAttribute("user");
        coursecomment.setCreatetime(DateUtil.getStringToday());
        coursecomment.setUserid(user.getName());
        coursecomment.setId(String.valueOf(Math.random()).substring(2,10));
        coursecommentService.insert(coursecomment);
        return "redirect:/Course/suggeetion";
    }

    @ResponseBody
    @RequestMapping("jsoncourse")
    public String jsoncourse(HttpServletRequest request, Curelation course){
        User user = (User) request.getSession().getAttribute("user");
        /*String type = "1";

        if ("1".equals(user.getType())){
            type="2";
        }
        course.setType(type);
        course.setUserid(user.getId());*/
        List<Curelation> curelationList = curelationService.queryAll(course);
        List<Course> dataList = new ArrayList<>();
        for (int i = 0; i < curelationList.size(); i++) {
            Course curelation = courseService.selectByPrimaryKey(curelationList.get(i).getCourseid());
            dataList.add(curelation);
        }

        JSONObject json = new JSONObject();
        return json.toJSONString(dataList);
    }

    @RequestMapping("suggeetion")
    public String suggeetion(HttpServletRequest request, Coursecomment coursecomment){

        List<Coursecomment> coursecomments = coursecommentService.queryAll(coursecomment);

        request.setAttribute("list",coursecomments);
        return "suggeetion";
    }
		request.setAttribute("list",noticeList);
		return "noticeDelete";
	}

	@RequestMapping("/delete1")
	public String delete1(String ID){
		noticeService.delete(ID);
		return "redirect:/Notice/delete";
	}

	@ResponseBody
	@RequestMapping("/queryOne")
	public String queryOne(String id){
		System.out.println("=================="+id);

		Notice notice = new Notice();
		notice.setId(id);
		List<Notice> noticeList = noticeService.queryAll(notice);
		JSONObject json = new JSONObject();
		return json.toJSONString(noticeList.get(0));
	}

	@RequestMapping("/add1")
	public String  add(HttpServletRequest request,String Content,String biaoti) throws Exception{
		User user = (User) request.getSession().getAttribute("user");
		Notice notice = new Notice();
		notice.setContent(Content);
		notice.setTitle(biaoti);
		notice.setCreatdate(DateUtil.Date2String(new Date()));
		notice.setId(String.valueOf(Math.random()).substring(2, 8));
		notice.setUserid(user.getId());
		noticeService.add(notice);

		return "redirect:/User/Main";
	}
}

public class LoginFilter implements Filter {

请添加图片描述

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值