基于javaweb和mysql的springboot+mybatis企业行政信息管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap)

私信源码获取及调试交流

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

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

技术框架

JavaBean MVC JSP SpringBoot MyBatis MySQL CSS JavaScript Bootstrap

适用

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

功能说明

登录、注册、退出、用户模块、公告模块、会议模块、培训模块、节假模块的增删改查管理

eclipse/MyEclipse运行:

idea运行:

@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 增加用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userAdd")
    public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        userService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    }

     */
    @RequestMapping("huiList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        Map<String, Object> map = huiService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) huiService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("huiList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("hui_list.jsp");
    }
}


    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        if (!"管理员".equals(loginUser.getUserType())) {
            params.put("id", loginUser.getId());
        }
        Map<String, Object> map = userService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) userService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("userList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("user_list.jsp");
    }
}

     * @throws IOException
     */
    @RequestMapping({"huiGet", "huiEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Hui vo = huiService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("hui_" + to + ".jsp");
    }

    /**
     * 根据条件查询会议的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("huiList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        Map<String, Object> map = huiService.list(params);
        response.sendRedirect("jia_list.jsp");
    }
}

@Controller
@RequestMapping
public class PeiController {

    @Autowired
    private PeiService peiService;

    /**
     * 增加培训
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("peiAdd")
    public void add(Pei vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        peiService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除培训
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("peiDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");

@Controller
@RequestMapping
public class JiaController {

    @Autowired
    private JiaService jiaService;

    /**
     * 增加节假
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("jiaAdd")
    public void add(Jia vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        jiaService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除节假
     *
     * @param response
     * @param request
     * @throws IOException
     */
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        Map<String, Object> map = peiService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) peiService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("peiList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("pei_list.jsp");
    }
}

    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        Map<String, Object> map = peiService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) peiService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("peiList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("pei_list.jsp");
    }
}

    }

    @RequestMapping("authResetPassword")
    public void resetPassword(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String msg;
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        String oldPassword = request.getParameter("oldPassword");
        if (!loginUser.getPassword().equals(oldPassword)) {
            msg = "原密码错误!";
        } else {
            String newPassword = request.getParameter("newPassword");
            loginUser.setPassword(newPassword);
            this.userService.update(loginUser);
            msg = "修改成功!";
        }
        request.getSession().setAttribute("alert_msg", msg);
        request.getRequestDispatcher("reset_password.jsp").forward(request, response);
    }

    // 返回一个随机颜色(Color对象)
    private Color getRandomColor(int minColor, int maxColor) {
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
        int red = minColor + random.nextInt(maxColor - minColor);
        //  获得绿色的随机颜色值
        int green = minColor + random.nextInt(maxColor - minColor);
        //  获得蓝色的随机颜色值
        int blue = minColor + random.nextInt(maxColor - minColor);
        return new Color(red, green, blue);
    }
}


@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 增加用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userAdd")
    public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("jiaAdd")
    public void add(Jia vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        jiaService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除节假
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("jiaDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        jiaService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑节假
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("jiaEdit")
    public void edit(Jia vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        jiaService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取节假的详细信息(详情页面与编辑页面要显示该节假的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"jiaGet", "jiaEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Jia vo = jiaService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("jia_" + to + ".jsp");

@Controller
@RequestMapping
public class PeiController {

    @Autowired
    private PeiService peiService;

    /**
     * 增加培训
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("peiAdd")
    public void add(Pei vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        peiService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除培训
     *
     * @param response
     * @param request

    /**
     * 编辑培训
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("peiEdit")
    public void edit(Pei vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        peiService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取培训的详细信息(详情页面与编辑页面要显示该培训的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"peiGet", "peiEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Pei vo = peiService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("pei_" + to + ".jsp");
    }

    /**
     * 根据条件查询培训的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("peiList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**

    /**
     * 获取培训的详细信息(详情页面与编辑页面要显示该培训的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"peiGet", "peiEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Pei vo = peiService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("pei_" + to + ".jsp");
    }

    /**
     * 根据条件查询培训的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("peiList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        Map<String, Object> map = peiService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
    public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        userService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"userGet", "userEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        User vo = userService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("user_" + to + ".jsp");
    }

    @RequestMapping("jiaDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        jiaService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑节假
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("jiaEdit")
    public void edit(Jia vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        jiaService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取节假的详细信息(详情页面与编辑页面要显示该节假的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"jiaGet", "jiaEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Jia vo = jiaService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("jia_" + to + ".jsp");
    }

    /**
     * 根据条件查询节假的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) userService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("userList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("user_list.jsp");
    }
}

@Controller
@RequestMapping
public class HuiController {

    @Autowired
    private HuiService huiService;

    /**
     * 增加会议
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("huiAdd")
    public void add(Hui vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法

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

更多推荐