作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目分为管理员与员工两种角色;
管理员功能主要包括:
客户相关:客户信息、客户分配、客户关怀、客户类型、客户状态、客户来源、联系记录、联系人;
员工相关:员工信息、房屋信息、房屋类型、部门信息、公告;
邮件相关:写邮件、发件箱、草稿箱;
管理员:添加员工、添加部门、添加角色;
员工功能主要包括:
客户相关:客户信息、客户关怀、客户类型、客户状态、客户来源、联系记录、联系人;
员工相关:员工信息、房屋信息、房屋类型、部门信息、公告;
邮件相关:写邮件、发件箱、草稿箱;
环境需要
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.数据库:MySql 5.7版本;
6.是否Maven项目:否;
技术栈
1. 后端:Servlet
2. 前端:JSP+CSS+JavaScript
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中util/DBCon.java配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/crm 登录
管理员账号/密码: admin/123456
员工账号/密码:123/123
运行截图
相关代码
CustomerAddServlet
package com.sxxy.servlet.customer;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sxxy.po.CustomerConditionInfo;
import com.sxxy.po.CustomerInfo;
import com.sxxy.po.CustomerSourceInfo;
import com.sxxy.po.CustomerTypeInfo;
import com.sxxy.po.UserInfo;
import com.sxxy.service.CustomerConditionService;
import com.sxxy.service.CustomerService;
import com.sxxy.service.CustomerSourceService;
import com.sxxy.service.CustomerTypeService;
import com.sxxy.service.UserService;
import com.sxxy.service.impl.CustomerConditionServiceImpl;
import com.sxxy.service.impl.CustomerServiceImpl;
import com.sxxy.service.impl.CustomerSourceServiceImpl;
import com.sxxy.service.impl.CustomerTypeServiceImpl;
import com.sxxy.service.impl.UserServiceImpl;
public class CustomerAddServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public CustomerAddServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//获取客户状态名
CustomerConditionService conditionService = new CustomerConditionServiceImpl();
List<CustomerConditionInfo> conditionInfo = conditionService.query(null);
request.setAttribute("conditionInfo", conditionInfo);
//获取客户来源名
CustomerSourceService sourceService = new CustomerSourceServiceImpl();
List<CustomerSourceInfo> sourceInfo = sourceService.query(null);
request.setAttribute("sourceInfo", sourceInfo);
//获取客户来源名
CustomerTypeService typeService = new CustomerTypeServiceImpl();
List<CustomerTypeInfo> typeInfo = typeService.query(null);
request.setAttribute("typeInfo", typeInfo);
//获取客户所属员工名
UserService userService = new UserServiceImpl();
List<UserInfo> userInfo = userService.getList(null, null);
request.setAttribute("userInfo", userInfo);
request.getRequestDispatcher("/view/customer/customer_add.jsp").forward(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String customerForUser = request.getParameter("customerForUser");
String customerName = request.getParameter("customerName");
String customerSex = request.getParameter("customerSex");
String customerSource = request.getParameter("customerSource");
String customerCondition = request.getParameter("customerCondition");
System.out.println(customerCondition);
String customerType = request.getParameter("customerType");
String customerBirthday = request.getParameter("customerBirthday");
String customerMobile = request.getParameter("customerMobile");
String customerQq = request.getParameter("customerQq");
String customerAddress = request.getParameter("customerAddress");
String customerEmail = request.getParameter("customerEmail");
String customerJob = request.getParameter("customerJob");
String customerBlog = request.getParameter("customerBlog");
String customerTel = request.getParameter("customerTel");
String customerMsn = request.getParameter("customerMsn");
String customerCompany = request.getParameter("customerCompany");
String customerAddTime = request.getParameter("customerAddTime");
String customerAddMan = request.getParameter("customerAddMan");
String customerChangeTime = request.getParameter("customerChangeTime");
String customerChangeMan = request.getParameter("customerChangeMan");
String customerRemark = request.getParameter("customerRemark");
CustomerInfo customerInfo = new CustomerInfo();
try {
//customerInfo.setUserId(Integer.parseInt(customerForUser));
customerInfo.setSourceId(Integer.parseInt(customerSource));
customerInfo.setConditionId(Integer.parseInt(customerCondition));
customerInfo.setTypeId(Integer.parseInt(customerType));
} catch (Exception e) {
e.printStackTrace();
}
customerInfo.setCustomerName(customerName);
customerInfo.setCustomerSex(customerSex);
customerInfo.setCustomerMobile(customerMobile);
customerInfo.setCustomerQq(customerQq);
customerInfo.setCustomerAddress(customerAddress);
customerInfo.setCustomerEmail(customerEmail);
customerInfo.setCustomerRemark(customerRemark);
customerInfo.setCustomerJob(customerJob);
customerInfo.setCustomerBlog(customerBlog);
customerInfo.setCustomerTel(customerTel);
customerInfo.setCustomerMsn(customerMsn);
customerInfo.setCustomerChangeTime(customerChangeTime);
customerInfo.setCustomerChangeMan(customerChangeMan);
customerInfo.setCustomerAddTime(customerAddTime);
customerInfo.setCustomerAddMan(customerAddMan);
customerInfo.setCustomerCompany(customerCompany);
customerInfo.setCustomerBirthday(customerBirthday);
CustomerService service = new CustomerServiceImpl();
boolean mark = service.add(customerInfo);
if (mark) {
request.setAttribute("info", "客户添加成功");
}else{
request.setAttribute("info", "客户添加失败");
}
request.getRequestDispatcher("/view/customer/customer_save.jsp").forward(
request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
CustomerQueryMoreServlet
package com.sxxy.servlet.customer;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sxxy.po.CustomerInfo;
import com.sxxy.service.CustomerService;
import com.sxxy.service.impl.CustomerServiceImpl;
public class CustomerQueryMoreServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public CustomerQueryMoreServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//获取客户信息
int customerId = Integer.parseInt(request.getParameter("customerId"));
CustomerService service = new CustomerServiceImpl();
CustomerInfo customerInfo = service.getAllList(customerId);
request.setAttribute("customerInfo", customerInfo);
request.getRequestDispatcher("/view/customer/customer_more.jsp").forward(
request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
CustomerQueryServlet
package com.sxxy.servlet.customer;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sxxy.po.CustomerInfo;
import com.sxxy.service.CustomerService;
import com.sxxy.service.impl.CustomerServiceImpl;
public class CustomerQueryServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public CustomerQueryServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
request.setCharacterEncoding("utf-8");
String customerInput = request.getParameter("customerInput");
String queryType = request.getParameter("queryType");
String UserId = request.getParameter("userId");
if (UserId != null) {
int userId = Integer.parseInt(request.getParameter("userId"));
System.out.println(userId);
CustomerService service =new CustomerServiceImpl();
List<CustomerInfo> list= service.query(customerInput,queryType ,userId) ;
request.setAttribute("list", list);
}else {
CustomerService service =new CustomerServiceImpl();
List<CustomerInfo> list= service.query(customerInput,queryType ,0) ;
request.setAttribute("list", list);
}
request.getRequestDispatcher("/view/customer/customer_list.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
如果也想学习本系统,下面领取。关注并回复:124jsp