基于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的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
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)){
                response.sendRedirect(request.getContextPath()+"/pages/error.jsp");
                return;
            }
        }
        filterChain.doFilter(request,response);
    }

    @Override
    public void destroy() {

    }
}

        role.setName(name);
        role.setOrderNo(orderNo);
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        Map<String,Object> map = roleService.updateRole(role,permissionIds);
        JSONUtil.getJSON(response,map);
    }

    private void getPermissionIds(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入查询当前角色权限getPermissionIds...");
        String roleId = request.getParameter("roleId");
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        List<String> permissionIds = roleService.getPermissionIds(roleId);
        Map<String,List<String>> map = new HashMap<>();
        map.put("pids",permissionIds);
        JSONUtil.getJSON(response,map);
    }

    private void deleteRoles(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入批量删除角色deleteRoles...");
        String[] ids = request.getParameterValues("id");
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        boolean flag = roleService.deleteRoles(ids);
        response.getWriter().print(flag);
    }

    private void addRole(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入添加角色addRole...");
        String name = request.getParameter("name");
        String orderNo = request.getParameter("orderNo");
        String[] permissionIds = request.getParameterValues("permissionIds");
        Role role = new Role();
        role.setId(IdUtil.simpleUUID());
        role.setName(name);
        role.setOrderNo(orderNo);
        role.setCreateTime(DateUtil.now());
        roleService = (RoleService) ServiceFactory.getService(new RoleServiceImpl());
        Map<String,Object> map = roleService.addRole(role,permissionIds);
        if((boolean)map.get("success")){
            updateApplication(request,response);
        }
        JSONUtil.getJSON(response,map);
    }

    private void getRoleList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入获取角色列表getPermissionList...");
        String name = request.getParameter("name");
        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);
    }

}

        user.setRegistTime(DateUtil.now());
        userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
        Map<String,Object> map = userService.addUser(user,roleIds);
        JSONUtil.getJSON(response,map);
    }

    private void changePwd(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入重置密码changePwd...");
       // String oldPwd = SecureUtil.md5(request.getParameter("oldPwd"));
      //  String password = SecureUtil.md5(request.getParameter("password"));

        String oldPwd = (request.getParameter("oldPwd"));
        String password = (request.getParameter("password"));

        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        Map<String,Object> map = new HashMap<>();
        if(!user.getPassword().equals(oldPwd)){
            map.put("success",false);
            map.put("msg","修改失败,旧密码错误");
            JSONUtil.getJSON(response,map);
            //response.getWriter().print("{\"success\":false,\"msg\":\"重置失败,旧密码错误\"}");
        }else{
            user.setPassword(password);
            userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
            boolean flag = userService.changePwd(user);
            if(flag){
                session.setAttribute("user",user);
                map.put("success",true);
                map.put("msg","修改成功");
                JSONUtil.getJSON(response,map);
                //response.getWriter().print("{\"success\":true,\"msg\":\"重置成功\"}");
            }else{
                map.put("success",false);
                map.put("msg","修改失败");
                JSONUtil.getJSON(response,map);
                //response.getWriter().print("{\"success\":false,\"msg\":\"重置失败\"}");
            }
        }
    }

    private void updateUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入修改个人信息adminInfo...");
        String name = request.getParameter("name");
        String email = request.getParameter("email");
        String remark = request.getParameter("remark");
        User user = (User) request.getSession().getAttribute("user");
        user.setName(name);
        user.setEmail(email);
        user.setRemark(remark);
        userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
        boolean flag = userService.updateUser(user);
        if(flag){
public class CustomerController extends HttpServlet {
    private CustomerService customerService = null;
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
        if("/controller/getCustomer".equals(path)){
            getCustomer(request,response);
        }else if("/controller/addCustomer".equals(path)){
            addCustomer(request,response);
        }else if("/controller/detailCustomer".equals(path)){
            detailCustomer(request,response);
        }else if("/controller/updateCustomer".equals(path)){
            updateCustomer(request,response);
        }else if("/controller/deleteCustomer".equals(path)){
            deleteCustomer(request,response);
        }else if("/controller/deleteCustomers".equals(path)){
            deleteCustomers(request,response);
        }else if("/controller/getCustomerName".equals(path)){
            getCustomerName(request,response);
        }else if("/controller/getCustomerByName".equals(path)){
            getCustomerByName(request,response);
        }
    }

    private void getCustomerByName(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入获取客户名称getCustomerByName");
        String name = request.getParameter("keywords");
        List<Customer> customerList = null;
        if(name!=null&&!"".equals(name)){
            customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
            customerList = customerService.getCustomerByName(name);
        }
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("content",customerList);
        map.put("type","success");
        JSONUtil.getJSON(response,map);
    }

    private void getCustomerName(HttpServletRequest request, HttpServletResponse response) throws IOException {
	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");
        String orderNo = request.getParameter("orderNo");
        Permission permission = new Permission();
        permission.setId(id);
        permission.setTitle(title);
        permission.setUrl(url);
        permission.setOrderNo(orderNo);
        permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
        boolean flag = permissionService.updatePermission(permission);
        response.getWriter().print(flag);
    }

    private void addPermission(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入添加权限addPermission...");
        String title = request.getParameter("title");
        String url = request.getParameter("url");
        Customer customer = new Customer();
        customer.setId(id);
        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);
    }
}
    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);
        customer.setNextContactDate(nextContactDate);
        customer.setAddress(address);
        customer.setDescription(description);
        customer.setContactSummary(contactSummary);
        customer.setEditBy(editBy);
        customer.setEditTime(editTime);
        boolean flag = customerService.updateCustomer(customer);
        Map<String,Object> map = new HashMap<>();
        map.put("success",flag);
        map.put("editBy",editBy);
        map.put("editTime",editTime);
        JSONUtil.getJSON(response,map);
    }

    private void detailCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("进入客户详情detailCustomer...");
        String id = request.getParameter("id");
        customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
        Customer customer = customerService.getCustomerById(id);
        request.setAttribute("customer",customer);
        request.getRequestDispatcher("/pages/customer-detail.jsp").forward(request,response);
    }

    private void addCustomer(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入添加客户addCustomer...");
        String id = IdUtil.simpleUUID();
        String owner = request.getParameter("owner");
        String name = request.getParameter("name");

public class ClueController extends HttpServlet {
	private ClueService clueService = null;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
	   	if("/controller/getClue".equals(path)){
		    getClue(request,response);
        } else if("/controller/addClue".equals(path)){
            addClue(request,response);
        } else if("/controller/detailClue".equals(path)){
            clueDetail(request,response);
        } else if("/controller/removeClueActivity".equals(path)){
            removeClueActivity(request,response);
        } else if("/controller/addClueActivity".equals(path)){
            addClueActivity(request,response);
        } else if("/controller/getClueByIdAndUser".equals(path)){
            getClueByIdAndUser(request,response);
        } else if("/controller/updateClue".equals(path)){
            updateClue(request,response);
        } else if("/controller/deleteClue".equals(path)){
            deleteClue(request,response);
        } else if("/controller/deleteClues".equals(path)){
            deleteClues(request,response);
        } else if("/controller/convert".equals(path)){
            convert(request,response);
        }
	}

    private void convert(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("进入线索转换convert...");
        clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
    private void updateContacts(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入修改联系人updateContacts...");
        String id = request.getParameter("id");
        String fullname = request.getParameter("fullname");
        String appellation = request.getParameter("appellation");
        String customerId = request.getParameter("customerId");
        String job = request.getParameter("job");
        String phone = request.getParameter("phone");
        String email = request.getParameter("email");
        String birth = request.getParameter("birth");
        String source = request.getParameter("source");
        String description = request.getParameter("description");
        String contactSummary = request.getParameter("contactSummary");
        String nextContactDate = request.getParameter("nextContactDate");
        String address = request.getParameter("address");
        Contacts contacts = new Contacts();
        contacts.setId(id);
        contacts.setFullname(fullname);
        contacts.setAppellation(appellation);
        contacts.setCustomerId(customerId);
        contacts.setJob(job);
        contacts.setPhone(phone);
        contacts.setEmail(email);
        contacts.setBirth(birth);
        contacts.setSource(source);
        contacts.setDescription(description);
        contacts.setContactSummary(contactSummary);
        contacts.setNextContactDate(nextContactDate);
        contacts.setAddress(address);
        contactsService = (ContactsService)ServiceFactory.getService(new ContactsServiceImpl());
        boolean flag = contactsService.updateContacts(contacts);
        response.getWriter().print(flag);
    }

    private void detailContacts(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("进入联系人详情detailContacts...");
        String id = request.getParameter("id");
        contactsService = (ContactsService) ServiceFactory.getService(new ContactsServiceImpl());
        Contacts contacts = contactsService.getContactsById(id);
        request.setAttribute("contacts",contacts);
        request.getRequestDispatcher("/pages/contacts-detail.jsp").forward(request,response);
    }

        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);
        Map<String,Object> param = new HashMap<>();
        param.put("fullname",fullname);
        param.put("company",company);
        param.put("pageNumber",pageNumber);
        param.put("pageSize",pageSize);
        contactsService = (ContactsService)ServiceFactory.getService(new ContactsServiceImpl());
        PageVO<Contacts> vo = contactsService.getContacts(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);
    }

}

public class CustomerController extends HttpServlet {
    private CustomerService customerService = null;
        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);
    }

    private void removeClueActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入解除线索和市场活动关系removeClueActivity...");
        String id = request.getParameter("id");
        clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());

public class ActivityController extends HttpServlet {
    private ActivityService activityService = null;
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getServletPath();
        if("/controller/getActivity".equals(path)){
           getActivity(request,response);
        }else if("/controller/createActivity".equals(path)){
            createActivity(request,response);
        }else if("/controller/updateActivity".equals(path)){
            updateActivity(request,response);
        }else if("/controller/deleteActivity".equals(path)){
            deleteActivity(request,response);
        }else if("/controller/deleteActivities".equals(path)){
            deleteActivities(request,response);
        }else if("/controller/getActivityByCid".equals(path)){
            getActivityByCid(request,response);
        }else if("/controller/getActivityByName".equals(path)){
            getActivityByName(request,response);
        }else if("/controller/getActivityByName2".equals(path)){
            getActivityByName2(request,response);
        }else if("/controller/getActivityByConid".equals(path)){
            getActivityByConid(request,response);
        }else if("/controller/getActivityByName3".equals(path)){
            getActivityByName3(request,response);
        }
    }

    private void getActivityByName3(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入getActivityByName3...");
        String sname = request.getParameter("sname");

public class LoginFilter implements Filter{

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@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
		
	}

}

        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);
    }

}

    }

    private void deleteActivities(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入deleteActivities");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String[] ids = request.getParameterValues("id");
        boolean flag = activityService.deleteActivities(ids);
        response.getWriter().print(flag);
    }

    private void deleteActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入deleteActivity");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String id = request.getParameter("id");
        int res = activityService.deleteActivity(id);
        boolean flag = (res==1?true:false);
        response.getWriter().print(flag);
    }

    private void updateActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入updateActivity");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String id = request.getParameter("id");
        String owner = request.getParameter("owner");
        String name = request.getParameter("name");
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");
        String cost = request.getParameter("cost");
        String description = request.getParameter("description");
        String editTime = DateUtil.now();
        String editBy = ((User)request.getSession().getAttribute("user")).getName();
        Activity activity = new Activity();
        activity.setId(id);
        activity.setOwner(owner);
        activity.setName(name);
        activity.setStartDate(startDate);
        activity.setEndDate(endDate);
        activity.setCost(cost);
        activity.setDescription(description);
        activity.setEditTime(editTime);
        activity.setEditBy(editBy);
        int res = activityService.updateActivity(activity);
        boolean flag = (res==1?true:false);
        response.getWriter().print(flag);
    }

    private void createActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("进入createActivity");
        activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String id = IdUtil.simpleUUID();
        String owner = request.getParameter("create-owner");
        String name = request.getParameter("create-name");
        String startDate = request.getParameter("create-startDate");

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);
        }
	}

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

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值