基于javaweb+mysql的jsp+servletcrm客户关系管理系统(java+layui+echarts+jsp+mysql)

基于javaweb+mysql的jsp+servletcrm客户关系管理系统(java+layui+echarts+jsp+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的JSP+Servletcrm客户关系管理系统(java+layui+echarts+jsp+mysql)

功能介绍

该项目未使用spring框架,实现了用户登录,权限控制,数据统计,以及市场活动、线索、客户、联系人、交易管理的CRUD, 使用Proxy实现Service层的动态代理,实现DAO层事务控制,有助于深入理解web项目。管理员还包含系统设置:用户管理、角色管理、 权限管理;其中角色管理可以设置总经理、副总经理、销售经理、综合事务等角色的权限菜单。

环境需要

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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;

技术栈

  1. 后端:Servlet+Mybatis 2. 前端:Layui+jquery+echarts+JSP

使用说明

  1. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包; 2. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置 4. 配置tomcat,然后运行项目,输入localhost:8080/xxx 登录 5. 管理员账户: admin 密码:123456 普通员工账户:zs 密码:123
            if (yoMamaYesThisSaysYoMama.exists()) {
                System.out.println(log4jProp + "初始化日志设置信息");
                PropertyConfigurator.configure(log4jProp);
            } else {
                System.err.println(log4jProp+ " 文件没有找到, 所以使用 BasicConfigurator初始化");
                BasicConfigurator.configure();
            }
        }
        super.init(config);
    }

    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
    }

    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {
    }

}

public class PermissionFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException {
        String contactsId = request.getParameter("contactsId");
        List<Activity> activityList = activityService.getActivityByConid(contactsId);
        JSONUtil.getJSON(response,activityList);
    }

    private void getActivityByName2(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入getActivityByName2...");
        String sname = request.getParameter("sname");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        List<Activity> activityList = activityService.getActivityByName2(sname);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",activityList.size());
        map.put("data",activityList);
        JSONUtil.getJSON(response,map);
    }

    private void getActivityByName(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入getActivityByName...");
        String sname = request.getParameter("sname");
        String clueId = request.getParameter("clueId");
        Map<String,String> param = new HashMap<>();
        param.put("name",sname);
        param.put("clueId",clueId);
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        List<Activity> activityList = activityService.getActivityByName(param);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",activityList.size());
        map.put("data",activityList);
        JSONUtil.getJSON(response,map);
    }

    private void getActivityByCid(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入getActivityByCid...");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String clueId = request.getParameter("clueId");
        List<Activity> activityList = activityService.getActivityByCid(clueId);
//        Map<String,Object> map = new HashMap<>();
//        map.put("code",0);
//        map.put("message","请求成功");
//        map.put("count",activityList.size());
//        map.put("data",activityList);
        JSONUtil.getJSON(response,activityList);
    }

    private void deleteActivities(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入deleteActivities");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());

public class UserController extends HttpServlet {
	private UserService userService = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
	   	if("/controller/login".equals(path)){
		    login(request,response);
        }else if("/controller/getUsers".equals(path)){
	   	    getUsers(request,response);
        }else if("/controller/updateUser".equals(path)){
            updateUser(request,response);
        }else if("/controller/changePwd".equals(path)){
            changePwd(request,response);
        }else if("/controller/addUser".equals(path)){
            addUser(request,response);
        }else if("/controller/getUserList".equals(path)){
            getUserList(request,response);
        }else if("/controller/deleteUsers".equals(path)){
            deleteUsers(request,response);
        }else if("/controller/getUserById".equals(path)){
            getUserById(request,response);
        }else if("/controller/updateUser2".equals(path)){
            updateUser2(request,response);
        }else if("/controller/resetPwd".equals(path)){
            resetPwd(request,response);
        }else if("/controller/welcome".equals(path)){
            getDatas(request,response);
        }
	}

    private void getDatas(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        System.out.println("进入首页获取数据getDatas...");
        userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
        Map<String,Object> map = userService.getDatas();
        request.setAttribute("activities",map.get("activities"));
        request.setAttribute("clues",map.get("clues"));
        request.setAttribute("trans",map.get("trans"));
        request.setAttribute("owners",map.get("owners"));
        request.setAttribute("volumes",map.get("volumes"));
        request.getRequestDispatcher("/pages/welcome.jsp").forward(request,response);

public class RoleController extends HttpServlet {
	private RoleService roleService = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
	   	if("/controller/getRoleList".equals(path)){
            getRoleList(request,response);
        }else if("/controller/addRole".equals(path)){
            addRole(request,response);
        }else if("/controller/deleteRoles".equals(path)){
            deleteRoles(request,response);
        }else if("/controller/getPermissionIds".equals(path)){
            getPermissionIds(request,response);
        }else if("/controller/updateRole".equals(path)){
            updateRole(request,response);
        }
	}

    private void updateRole(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入修改角色信息updateRole...");
        String id = request.getParameter("id");
        String name = request.getParameter("name");
        String orderNo = request.getParameter("orderNo");
        String[] permissionIds = request.getParameterValues("permissionIds");
        Role role = new Role();
        role.setId(id);
        role.setName(name);
        role.setOrderNo(orderNo);
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        Map<String,Object> map = roleService.updateRole(role,permissionIds);
        JSONUtil.getJSON(response,map);
    }
		
	}

	@Override
	public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
			throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
		HttpServletResponse response = (HttpServletResponse) resp;
		Object user = request.getSession().getAttribute("user");
		String path = request.getServletPath();
		
		if(user!=null||"/pages/login.jsp".equals(path)||"/controller/login".equals(path)) {
			chain.doFilter(request, response);
		}else {
			response.sendRedirect(request.getContextPath()+"/pages/login.jsp");
		}
	}

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

}

public class JSONUtil {
    public static void getJSON(HttpServletResponse response, Object target) throws IOException {
        JSONObject jsonObject = new JSONObject(target);
        String json = jsonObject.toString();
        response.getWriter().print(json);
    }
    public static void getJSON(HttpServletResponse response, Map target) throws IOException {
        JSONObject jsonObject = new JSONObject(target);
        String json = jsonObject.toString();
        response.getWriter().print(json);
    }
    public static void getJSON(HttpServletResponse response, List target) throws IOException {
        JSONArray jsonArray = new JSONArray(target);
        String json = jsonArray.toString();
        response.getWriter().print(json);
    }
}

        clue.setJob(job);
        clue.setEmail(email);
        clue.setTel(tel);
        clue.setWebsite(website);
        clue.setPhone(phone);
        clue.setState(state);
        clue.setSource(source);
        clue.setCreateBy(createBy);
        clue.setCreateTime(createTime);
        clue.setDescription(description);
        clue.setContactSummary(contactSummary);
        clue.setNextContactDate(nextContactDate);
        clue.setAddress(address);
        boolean flag = clueService.addClue(clue);
        response.getWriter().print(flag);
    }

    private void getClue(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入getClue...");
        String owner = request.getParameter("owner");
        String fullname = request.getParameter("fullname");
        String company = request.getParameter("company");
        int page = Integer.parseInt(request.getParameter("page"));
        int limit = Integer.parseInt(request.getParameter("limit"));
        int pageNumber = (page-1)*limit;
        int pageSize = limit;
        clueService = (ClueService)ServiceFactory.getService(new ClueServiceImpl());
        Map<String,Object> param = new HashMap<>();
        param.put("owner",owner);
        param.put("fullname",fullname);
        param.put("company",company);
        param.put("pageNumber",pageNumber);
        param.put("pageSize",pageSize);
        PageVO<Clue> vo = clueService.getClue(param);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",vo.getTotal());
        map.put("data",vo.getDatas());
        JSONUtil.getJSON(response,map);
    }

}

        tran.setCreateBy(createBy);
        tran.setCreateTime(createTime);
        tran.setDescription(description);
        tran.setContactSummary(contactSummary);
        tranService = (TranService) ServiceFactory.getService(new TranServiceImpl());
        boolean flag = tranService.addTran(tran,customer);
        response.getWriter().print(flag);
    }

    private void getTran(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入获取交易列表getTran...");
        String owner = request.getParameter("owner");
        String name = request.getParameter("name");
        String expectedDate = request.getParameter("expectedDate");
        int page = Integer.parseInt(request.getParameter("page"));
        int limit = Integer.parseInt(request.getParameter("limit"));
        int pageNumber = (page-1)*limit;
        int pageSize = limit;
        Map<String,Object> param = new HashMap<>();
        param.put("owner",owner);
        param.put("name",name);
        param.put("expectedDate",expectedDate);
        param.put("pageNumber",pageNumber);
        param.put("pageSize",pageSize);
        tranService = (TranService) ServiceFactory.getService(new TranServiceImpl());
        PageVO<Tran> vo = tranService.getTran(param);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",vo.getTotal());
        map.put("data",vo.getDatas());

        JSONUtil.getJSON(response,map);
    }
}


    private void getActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入getActivity");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String owner = request.getParameter("owner");
        String name = request.getParameter("name");
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");
        int page = Integer.parseInt(request.getParameter("page"));
        int limit = Integer.parseInt(request.getParameter("limit"));
        int pageNumber = (page-1)*limit;
        int pageSize = limit;
        Map<String,Object> data = new HashMap<>();
        data.put("owner",owner);
        data.put("name",name);
        data.put("startDate",startDate);
        data.put("endDate",endDate);
        data.put("pageNumber",pageNumber);
        data.put("pageSize",pageSize);
        PageVO<Activity> vo = activityService.getActivity(data);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",vo.getTotal());
        map.put("data",vo.getDatas());

        JSONUtil.getJSON(response,map);
    }

}


public class PermissionController extends HttpServlet {
	private PermissionService permissionService = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
	   	if("/controller/getPermissionList".equals(path)){
            getPermissionList(request,response);
        }else if("/controller/addPermission".equals(path)){
            addPermission(request,response);
        }else if("/controller/updatePermission".equals(path)){
            updatePermission(request,response);
        }else if("/controller/deletePermissions".equals(path)){
            deletePermissions(request,response);
        }
	}

    private void deletePermissions(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入批量删除权限deletePermissions...");
        String[] ids = request.getParameterValues("id");
        permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
        boolean flag = permissionService.deletePermissions(ids);
        response.getWriter().print(flag);
    }

    private void updatePermission(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入修改权限updatePermission...");
        String id = request.getParameter("id");
        String title = request.getParameter("title");
        String url = request.getParameter("url");
    }

    private void resetPwd(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入重置密码resetPwd...");
        String id = request.getParameter("id");
        userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
        boolean flag = userService.resetPwd(id);
        response.getWriter().print(flag);
    }

    private void updateUser2(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入修改用户详情updateUser2...");
        String id = request.getParameter("id");
        String name = request.getParameter("name");
        String username = request.getParameter("username");
        String isEnable =request.getParameter("isEnable");
        String isAdmin =request.getParameter("isAdmin");
        String[] roleIds = request.getParameterValues("roleIds");
        String email =request.getParameter("email");
        String remark =request.getParameter("remark");
        User user = new User();
        user.setId(id);
        user.setName(name);
        user.setUsername(username);
        user.setIsEnable(isEnable);
        user.setIsAdmin(isAdmin);
        user.setEmail(email);
        user.setRemark(remark);
        userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
        Map<String,Object> map = userService.updateUser2(user,roleIds);
        JSONUtil.getJSON(response,map);
    }

    private void getUserById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入查询用户详情getUserById...");
        String id = request.getParameter("id");
        userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
        User user = userService.getUserById(id);
        JSONUtil.getJSON(response,user);
    }
        System.out.println("进入线索修改updateClue...");
        clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
        String id = request.getParameter("id");
        String fullname = request.getParameter("fullname");
        String appellation = request.getParameter("appellation");
        String owner = request.getParameter("owner");
        String company = request.getParameter("company");
        String job = request.getParameter("job");
        String email = request.getParameter("email");
        String tel = request.getParameter("tel");
        String website = request.getParameter("website");
        String phone = request.getParameter("phone");
        String state = request.getParameter("state");
        String source = request.getParameter("source");
        String editBy = ((User)request.getSession().getAttribute("user")).getName();
        String editTime = DateUtil.now();
        String description = request.getParameter("description");
        String contactSummary = request.getParameter("contactSummary");
        String nextContactDate = request.getParameter("nextContactDate");
        String address = request.getParameter("address");
        Clue clue = new Clue();
        clue.setId(id);
        clue.setFullname(fullname);
        clue.setAppellation(appellation);
        clue.setOwner(owner);
        clue.setCompany(company);
        clue.setJob(job);
        clue.setEmail(email);
        clue.setTel(tel);
        clue.setWebsite(website);
        clue.setPhone(phone);
        clue.setState(state);
        clue.setSource(source);
        clue.setEditBy(editBy);
        clue.setEditTime(editTime);
        clue.setDescription(description);
        clue.setContactSummary(contactSummary);
        clue.setNextContactDate(nextContactDate);
        clue.setAddress(address);
        boolean flag = clueService.updateClue(clue);
        response.getWriter().print(flag);
    }

    private void getClueByIdAndUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入查询线索和用户getClueByIdAndUser...");
        String id = request.getParameter("id");
        clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
        Map map = clueService.getClueByIdAndUser(id);
        JSONUtil.getJSON(response, map);
        customer.setOwner(owner);
        customer.setName(name);
        customer.setWebsite(website);
        customer.setTel(tel);
        customer.setNextContactDate(nextContactDate);
        customer.setAddress(address);
        customer.setDescription(description);
        customer.setContactSummary(contactSummary);
        customer.setCreateBy(createBy);
        customer.setCreateTime(createTime);
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        boolean flag = customerService.addCustomer(customer);
        response.getWriter().print(flag);
    }

    private void getCustomer(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入查询客户getCustomer...");
        String name = request.getParameter("name");
        String owner = request.getParameter("owner");
        int page = Integer.parseInt(request.getParameter("page"));
        int limit = Integer.parseInt(request.getParameter("limit"));
        int pageNumber = (page-1)*limit;
        int pageSize = limit;
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        Map<String,Object> param = new HashMap<>();
        param.put("name",name);
        param.put("owner",owner);
        param.put("pageNumber",pageNumber);
        param.put("pageSize",pageSize);
        PageVO<Customer> vo = customerService.getCustomer(param);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",vo.getTotal());
        map.put("data",vo.getDatas());
        JSONUtil.getJSON(response,map);
    }
}

        System.out.println("进入获取客户名称getCustomerName");
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        List<Customer> customerList = customerService.getCustomerName();
        JSONUtil.getJSON(response,customerList);
    }

    private void deleteCustomers(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入批量删除客户deleteCustomers...");
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        String[] ids = request.getParameterValues("id");
        Map<String,Object> map = customerService.deleteCustomers(ids);
        JSONUtil.getJSON(response,map);
    }

    private void deleteCustomer(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入删除客户deleteCustomer...");
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        String id = request.getParameter("id");
        Map<String,Object> map = customerService.deleteCustomer(id);
        JSONUtil.getJSON(response,map);
    }

    private void updateCustomer(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入修改客户updateCustomer...");
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        String id = request.getParameter("id");
        String owner = request.getParameter("owner");
        String name = request.getParameter("name");
        String website = request.getParameter("website");
        String tel = request.getParameter("tel");
        String contactSummary = request.getParameter("contactSummary");
        String nextContactDate =  request.getParameter("nextContactDate");
        String description = request.getParameter("description");
        String address = request.getParameter("address");
        String editBy = ((User)request.getSession().getAttribute("user")).getName();
        String editTime = DateUtil.now();
        Customer customer = new Customer();
        customer.setId(id);
        customer.setOwner(owner);
        customer.setName(name);
        customer.setWebsite(website);
        customer.setTel(tel);
        JSONUtil.getJSON(response,map);
    }

}

public class TranController extends HttpServlet {
    private TranService tranService = null;
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
        if("/controller/getTran".equals(path)){
            getTran(request,response);
        }else if("/controller/addTran".equals(path)){
            addTran(request,response);
        }else if("/controller/updateTran".equals(path)){
        	updateTran(request,response);
        }else if("/controller/deleteTran".equals(path)){
            deleteTran(request,response);
        }else if("/controller/deleteTrans".equals(path)){

public class UserController extends HttpServlet {
	private UserService userService = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
	   	if("/controller/login".equals(path)){
		    login(request,response);
        }else if("/controller/getUsers".equals(path)){
	   	    getUsers(request,response);
        }else if("/controller/updateUser".equals(path)){
            updateUser(request,response);
        }else if("/controller/changePwd".equals(path)){
            changePwd(request,response);
        }else if("/controller/addUser".equals(path)){
            addUser(request,response);
        }else if("/controller/getUserList".equals(path)){
            getUserList(request,response);
        }else if("/controller/deleteUsers".equals(path)){
            deleteUsers(request,response);
        }else if("/controller/getUserById".equals(path)){
            getUserById(request,response);
        }else if("/controller/updateUser2".equals(path)){
            updateUser2(request,response);
        }else if("/controller/resetPwd".equals(path)){
            resetPwd(request,response);
        }else if("/controller/welcome".equals(path)){
            getDatas(request,response);
        param.put("pageSize",pageSize);
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        PageVO<Role> vo = roleService.getRoleList(param);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",vo.getTotal());
        map.put("data",vo.getDatas());
        JSONUtil.getJSON(response,map);
    }

    //更新application中的缓存
    private void updateApplication(HttpServletRequest request, HttpServletResponse response){
        ServletContext application = request.getServletContext();
        RoleService roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        List<Role> roleList = roleService.getRole();
        application.setAttribute("roles",roleList);
    }

}

        super.init(config);
    }

    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
    }

    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {
    }

}

public class PermissionFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;
        User user = (User) request.getSession().getAttribute("user");
        String path = request.getServletPath();
        List<String> permissionList = new ArrayList<>();
        permissionList.add("/pages/activity.jsp");
        permissionList.add("/pages/clue.jsp");
        permissionList.add("/pages/customer.jsp");
        permissionList.add("/pages/contacts.jsp");
        permissionList.add("/pages/tran.jsp");
        permissionList.add("/pages/user.jsp");
        permissionList.add("/pages/role.jsp");
        permissionList.add("/pages/permission.jsp");
        if(user!=null&&permissionList.contains(path)){
            Set<String> permissions = user.getPermissions();
            if(!"1".equals(user.getIsAdmin())&&!permissions.contains(path)){
        param.put("pageSize",pageSize);
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        PageVO<Role> vo = roleService.getRoleList(param);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("message","请求成功");
        map.put("count",vo.getTotal());
        map.put("data",vo.getDatas());
        JSONUtil.getJSON(response,map);
    }

    //更新application中的缓存
    private void updateApplication(HttpServletRequest request, HttpServletResponse response){
        ServletContext application = request.getServletContext();
        RoleService roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        List<Role> roleList = roleService.getRole();
        application.setAttribute("roles",roleList);
    }

}

public class PermissionController extends HttpServlet {
	private PermissionService permissionService = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值