├── .idea ├── artifacts │ ├── customer_maven_war.xml │ └── customer_maven_war_exploded.xml ├── compiler.xml ├── dataSources.local.xml ├── dataSources.xml ├── dataSources │ └── e93f6f4c-a1b1-4d2f-882a-479ce8afac46.xml ├── encodings.xml ├── inspectionProfiles │ └── Project_Default.xml ├── libraries │ ├── Maven__com_mchange_c3p0_0_9_5_2.xml │ ├── Maven__com_mchange_mchange_commons_java_0_2_11.xml │ ├── Maven__commons_logging_commons_logging_1_2.xml │ ├── Maven__javax_servlet_javax_servlet_api_3_1_0.xml │ ├── Maven__jstl_jstl_1_2.xml │ ├── Maven__junit_junit_4_12.xml │ ├── Maven__mysql_mysql_connector_java_5_1_46.xml │ ├── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── Maven__org_mybatis_mybatis_3_4_6.xml │ ├── Maven__org_mybatis_mybatis_spring_1_3_2.xml │ ├── Maven__org_springframework_spring_aop_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_beans_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_context_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_core_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_expression_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_jdbc_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_test_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_tx_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_web_4_3_8_RELEASE.xml │ ├── Maven__org_springframework_spring_webmvc_4_3_8_RELEASE.xml │ └── Maven__taglibs_standard_1_1_2.xml ├── misc.xml ├── modules.xml └── workspace.xml ├── README.md ├── customer-maven.iml ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── silver │ │ ├── controller │ │ ├── CustomerController.java │ │ └── converter │ │ │ └── TrimStringConverter.java │ │ ├── dao │ │ └── CustomerDao.java │ │ ├── entity │ │ ├── Customer.java │ │ └── PageBean.java │ │ └── service │ │ ├── CustomerService.java │ │ └── impl │ │ └── CustomerServiceImpl.java ├── resources │ ├── jdbc.properties │ ├── mapper │ │ └── CustomerDao.xml │ ├── mybatis-config.xml │ └── spring │ │ ├── spring-dao.xml │ │ ├── spring-service.xml │ │ └── spring-web.xml ├── sql │ └── customer.sql └── webapp │ ├── WEB-INF │ ├── jsp │ │ ├── DevelopDoc.jsp │ │ ├── add.jsp │ │ ├── edit.jsp │ │ ├── frame.jsp │ │ ├── list.jsp │ │ └── query.jsp │ └── web.xml │ ├── index.jsp │ └── resources │ └── layui │ ├── css │ ├── layui.css │ ├── layui.mobile.css │ └── modules │ │ ├── code.css │ │ ├── laydate │ │ └── default │ │ │ └── laydate.css │ │ └── layer │ │ └── default │ │ ├── icon-ext.png │ │ ├── icon.png │ │ ├── layer.css │ │ ├── loading-0.gif │ │ ├── loading-1.gif │ │ └── loading-2.gif │ ├── font │ ├── iconfont.eot │ ├── iconfont.svg │ ├── iconfont.ttf │ └── iconfont.woff │ ├── images │ └── face │ │ ├── 0.gif │ │ ├── 1.gif │ │ ├── 10.gif │ │ ├── 11.gif │ │ ├── 12.gif │ │ ├── 13.gif │ │ ├── 14.gif │ │ ├── 15.gif │ │ ├── 16.gif │ │ ├── 17.gif │ │ ├── 18.gif │ │ ├── 19.gif │ │ ├── 2.gif │ │ ├── 20.gif │ │ ├── 21.gif │ │ ├── 22.gif │ │ ├── 23.gif │ │ ├── 24.gif │ │ ├── 25.gif │ │ ├── 26.gif │ │ ├── 27.gif │ │ ├── 28.gif │ │ ├── 29.gif │ │ ├── 3.gif │ │ ├── 30.gif │ │ ├── 31.gif │ │ ├── 32.gif │ │ ├── 33.gif │ │ ├── 34.gif │ │ ├── 35.gif │ │ ├── 36.gif │ │ ├── 37.gif │ │ ├── 38.gif │ │ ├── 39.gif │ │ ├── 4.gif │ │ ├── 40.gif │ │ ├── 41.gif │ │ ├── 42.gif │ │ ├── 43.gif │ │ ├── 44.gif │ │ ├── 45.gif │ │ ├── 46.gif │ │ ├── 47.gif │ │ ├── 48.gif │ │ ├── 49.gif │ │ ├── 5.gif │ │ ├── 50.gif │ │ ├── 51.gif │ │ ├── 52.gif │ │ ├── 53.gif │ │ ├── 54.gif │ │ ├── 55.gif │ │ ├── 56.gif │ │ ├── 57.gif │ │ ├── 58.gif │ │ ├── 59.gif │ │ ├── 6.gif │ │ ├── 60.gif │ │ ├── 61.gif │ │ ├── 62.gif │ │ ├── 63.gif │ │ ├── 64.gif │ │ ├── 65.gif │ │ ├── 66.gif │ │ ├── 67.gif │ │ ├── 68.gif │ │ ├── 69.gif │ │ ├── 7.gif │ │ ├── 70.gif │ │ ├── 71.gif │ │ ├── 8.gif │ │ └── 9.gif │ ├── lay │ └── modules │ │ ├── carousel.js │ │ ├── code.js │ │ ├── element.js │ │ ├── flow.js │ │ ├── form.js │ │ ├── jquery.js │ │ ├── laydate.js │ │ ├── layedit.js │ │ ├── layer.js │ │ ├── laypage.js │ │ ├── laytpl.js │ │ ├── mobile.js │ │ ├── table.js │ │ ├── tree.js │ │ ├── upload.js │ │ └── util.js │ ├── layui.all.js │ └── layui.js └── test └── com └── silver ├── dao └── CustomerDaoTest.java └── service └── CustomerServiceTest.java /.idea/artifacts/customer_maven_war.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/artifacts/customer_maven_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target/customer 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/dataSources.local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #@ 7 | ` 8 | 9 | 10 | master_key 11 | mysql 12 | *:customer 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql 6 | true 7 | com.mysql.jdbc.Driver 8 | jdbc:mysql://localhost:3306/customer 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_mchange_c3p0_0_9_5_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_mchange_mchange_commons_java_0_2_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_javax_servlet_api_3_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__jstl_jstl_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__mysql_mysql_connector_java_5_1_46.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_3_4_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_spring_1_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_aop_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_beans_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_core_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_expression_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_jdbc_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_test_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_tx_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_web_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__taglibs_standard_1_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # customer-maven 2 | 3 | ## 项目介绍 4 | 使用ssm+maven编写的客户信息管理系统 5 | - 使用框架:spring4+mybatis+springMVC 6 | - 数据库:mysql5.7 7 | - 项目管理工具:maven 8 | - 编译器:intellij idea 9 | 10 | 注:此项目是基于之前的[Servlet+JSP+SQL Server+Layui+intellij idea编写的客户信息管理系统](https://github.com/2427595858/Customer-Information-Management)项目进行改造。 11 | 12 | ## 实现功能 13 | - 客户信息的增删查改,以及模糊查询功能 14 | - 分页显示客户信息 15 | 16 | ## 效果预览 17 | 18 | 1. 客户列表页 19 | 20 |  21 | 22 | 2. 添加客户 23 | 24 |  25 | 26 | 3. 高级搜索 27 | 28 |  29 | 30 | 4. 开发日志 31 | 32 |  33 | 34 | 相关教程请到[我的博客](https://blog.csdn.net/silversoldier/article/details/80387067#t17)查看。 35 | 36 | 如果觉得不错的话,请给个star吧。 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /customer-maven.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | com.silver 8 | customer 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | customer Maven Webapp 13 | 14 | http://www.example.com 15 | 16 | 17 | UTF-8 18 | 1.7 19 | 1.7 20 | 21 | 22 | 23 | 24 | 25 | junit 26 | junit 27 | 4.12 28 | test 29 | 30 | 31 | 32 | 33 | taglibs 34 | standard 35 | 1.1.2 36 | 37 | 38 | jstl 39 | jstl 40 | 1.2 41 | 42 | 43 | javax.servlet 44 | javax.servlet-api 45 | 3.1.0 46 | 47 | 48 | 49 | 50 | mysql 51 | mysql-connector-java 52 | 5.1.46 53 | 54 | 55 | com.mchange 56 | c3p0 57 | 0.9.5.2 58 | 59 | 60 | 61 | 62 | org.mybatis 63 | mybatis 64 | 3.4.6 65 | 66 | 67 | org.mybatis 68 | mybatis-spring 69 | 1.3.2 70 | 71 | 72 | 73 | 74 | org.springframework 75 | spring-core 76 | 4.3.8.RELEASE 77 | 78 | 79 | org.springframework 80 | spring-beans 81 | 4.3.8.RELEASE 82 | 83 | 84 | org.springframework 85 | spring-context 86 | 4.3.8.RELEASE 87 | 88 | 89 | 90 | org.springframework 91 | spring-tx 92 | 4.3.8.RELEASE 93 | 94 | 95 | org.springframework 96 | spring-jdbc 97 | 4.3.8.RELEASE 98 | 99 | 100 | 101 | org.springframework 102 | spring-web 103 | 4.3.8.RELEASE 104 | 105 | 106 | org.springframework 107 | spring-webmvc 108 | 4.3.8.RELEASE 109 | 110 | 111 | 112 | org.springframework 113 | spring-test 114 | 4.3.8.RELEASE 115 | 116 | 117 | 118 | 119 | customer 120 | 121 | 122 | 123 | maven-clean-plugin 124 | 3.0.0 125 | 126 | 127 | 128 | maven-resources-plugin 129 | 3.0.2 130 | 131 | 132 | maven-compiler-plugin 133 | 3.7.0 134 | 135 | 136 | maven-surefire-plugin 137 | 2.20.1 138 | 139 | 140 | maven-war-plugin 141 | 3.2.0 142 | 143 | 144 | maven-install-plugin 145 | 2.5.2 146 | 147 | 148 | maven-deploy-plugin 149 | 2.8.2 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /src/main/java/com/silver/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package com.silver.controller; 2 | 3 | import com.silver.entity.Customer; 4 | import com.silver.entity.PageBean; 5 | import com.silver.service.CustomerService; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | /** 18 | * 编写控制器,用来和前端页面进行交互 19 | * @author 光玉 20 | * @create 2018-05-18 15:40 21 | **/ 22 | @Controller 23 | @RequestMapping("/customer") // 相当于模块化,这个模块下的请求格式为“/customer/**” 24 | public class CustomerController { 25 | @Autowired 26 | private CustomerService customerService; 27 | 28 | private Customer myCustomer; // 用来保存模糊查询的客户信息 29 | 30 | // 这里设置了只能使用get方法传递url 31 | @RequestMapping(value = "/frame", method = RequestMethod.GET) 32 | public String mainFrame(){ 33 | // 显示主界面 34 | return "frame"; 35 | } 36 | 37 | @RequestMapping(value = "/allCustomerList/{pageNum}", method = RequestMethod.GET) 38 | public String allCustomerList(@PathVariable("pageNum") Integer pageNum,Model model) throws Exception{ 39 | // 显示所有客户列表 40 | // 获取从前端传过来的当前页数,并进行分页操作,显示列表 41 | if(pageNum == null){ 42 | pageNum = 1; // 空则当前页面设置为1 43 | } 44 | int pageRecord = 8; // 设置每页8条记录 45 | PageBean pb = customerService.allList((pageNum-1)*pageRecord, pageRecord); 46 | myCustomer = new Customer(); // 实例化myCustomer对象(如果之前有进行模糊查询操作,则相当于清除保存在myCustomer对象中的信息) 47 | model.addAttribute("pb",pb); // 将pb对象传到前端页面中 48 | return "list"; 49 | } 50 | 51 | @RequestMapping(value = "/add",method = RequestMethod.GET) // 设置传递的url以及设置访问方式 52 | public String addCustomer() throws Exception{ 53 | return "add"; // 返回添加客户的jsp页面 54 | } 55 | 56 | @RequestMapping(value = "/addCustomerSubmit",method = RequestMethod.POST) 57 | public String addCustomerSuccess(Customer customer) throws Exception{ 58 | // 进行添加客户操作 59 | customerService.insert(customer); 60 | return "redirect:allCustomerList/1"; // 重定向到列表页面,显示第一页 61 | } 62 | 63 | @RequestMapping(value = "/edit/{id}",method = RequestMethod.GET) 64 | public String editCustomer(@PathVariable("id") Long id, Model model)throws Exception{ 65 | // 到要修改客户的信息页 66 | Customer customer = customerService.getById(id); 67 | model.addAttribute("customer",customer); 68 | return "edit"; 69 | } 70 | 71 | @RequestMapping(value = "/editCustomerSubmit",method = RequestMethod.POST) 72 | public String editCustomerSubmit(@Param("id") Long id,@Param("customer") Customer customer) throws Exception{ 73 | // 传入id和要修改的相关客户信息,执行更新操作 74 | customerService.update(id,customer); 75 | return "redirect:allCustomerList/1"; 76 | } 77 | 78 | @RequestMapping(value = "/delete/{id}",method = RequestMethod.GET) 79 | public void deleteCustomer(@PathVariable("id") Long id, HttpServletRequest request, HttpServletResponse response)throws Exception{ 80 | // 删除客户信息 81 | customerService.delete(id); 82 | String url = request.getRequestURL().toString(); // 获取当前请求的url 83 | String newUrl = url.substring(0,url.lastIndexOf("delete")) 84 | + "allCustomerList/1"; // 重新拼接url 85 | 86 | response.sendRedirect(newUrl); // 重定向回客户列表的第一页 87 | } 88 | 89 | @RequestMapping(value = "/query",method = RequestMethod.GET) 90 | public String queryList(){ 91 | // 进入模糊查询页面 92 | return "query"; 93 | } 94 | 95 | // 由于模糊查询需要使用post提交表单,这里设置了可以使用get和post方法传递url 96 | @RequestMapping(value = "/list/{pageNum}", method = {RequestMethod.GET, RequestMethod.POST}) 97 | public String queryCustomerList(@PathVariable("pageNum") Integer pageNum,Customer customer, Model model) throws Exception{ 98 | // 获取从前端传过来的当前页数,并进行分页操作,显示列表,具有模糊查询的功能 99 | if(pageNum == null){ 100 | pageNum = 1; // 空则当前页面设置为1 101 | } 102 | int pageRecord = 8; // 设置每页记录数为8 103 | if(!customer.isNull()){ // 如果模糊查询中有设置查询信息,则将信息保存到myCustomer对象中 104 | myCustomer = customer; 105 | } 106 | PageBean pb = customerService.queryList((pageNum-1)*pageRecord, pageRecord,myCustomer); 107 | model.addAttribute("pb",pb); 108 | 109 | return "list"; 110 | } 111 | 112 | @RequestMapping(value = "/DevelopDoc",method = RequestMethod.GET) 113 | public String developDoc(){ 114 | // 显示开发日志页面 115 | return "DevelopDoc"; 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/silver/controller/converter/TrimStringConverter.java: -------------------------------------------------------------------------------- 1 | package com.silver.controller.converter; 2 | 3 | import org.springframework.core.convert.converter.Converter; 4 | 5 | /** 6 | * 去除前后空格的转换器 7 | * @author 光玉 8 | * @create 2018-05-20 16:45 9 | **/ 10 | public class TrimStringConverter implements Converter { 11 | // 编写去除前后空格的转换器 12 | // 若去除空格后字符串为空,则返回null,否则返回去空格后的字符串 13 | @Override 14 | public String convert(String source){ 15 | try{ 16 | if(source != null){ 17 | source=source.trim(); 18 | if(source.equals("")){ 19 | return null; 20 | } 21 | } 22 | }catch(Exception e){ 23 | e.printStackTrace(); 24 | } 25 | return source; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/silver/dao/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.silver.dao; 2 | 3 | import com.silver.entity.Customer; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 客户信息dao层编写(增,删,查,改操作) 10 | * @author 光玉 11 | * @create 2018-05-16 22:49 12 | **/ 13 | public interface CustomerDao { 14 | /** 15 | * 由于有多个形参,在spring中形参是以arg0,arg1...的形式传递的,需要使用@Param设置对应的名字 16 | * 分页查询客户 17 | * @param offset 偏移量 18 | * @param pageRecord 每页记录数 19 | * @return 20 | */ 21 | public List findAll(@Param("offset") int offset,@Param("pageRecord") int pageRecord); 22 | 23 | /** 24 | * 通过id查找应客户信息 25 | * @param id 26 | * @return 27 | */ 28 | public Customer findById(long id) throws Exception; 29 | 30 | /** 31 | * 通过传入的customer对象获取对应客户信息,并将其插入数据库 32 | * @param customer 33 | */ 34 | public void addCustomer(Customer customer) throws Exception; 35 | 36 | /** 37 | * 通过id来删除对应的客户 38 | * @param id 39 | */ 40 | public void deleteCustomer(long id) throws Exception; 41 | 42 | /** 43 | * 根据id修改信息,传入要修改的信息 44 | * @param id 45 | * @param customer 46 | * @throws Exception 47 | */ 48 | public void editCustomer(@Param("id") long id,@Param("customer") Customer customer)throws Exception; 49 | 50 | /** 51 | * 返回客户列表的总记录数(模糊查询时,返回模糊查询总记录数) 52 | * @param customer 53 | * @return 54 | * @throws Exception 55 | */ 56 | public int countCustomers(@Param("customer") Customer customer)throws Exception; 57 | 58 | /** 59 | * 分页查询客户,并且有模糊查询功能 60 | * @param offset 61 | * @param pageRecord 62 | * @param customer 63 | * @return 64 | * @throws Exception 65 | */ 66 | public List queryAll(@Param("offset") int offset,@Param("pageRecord") int pageRecord,@Param("customer") Customer customer) throws Exception; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/silver/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.silver.entity; 2 | 3 | /** 4 | * 封装客户信息(id,姓名,性别,电话,邮箱,个人描述)的pojo类 5 | * @author 光玉 6 | * @create 2018-05-16 22:36 7 | **/ 8 | public class Customer { 9 | private long id; 10 | private String name; 11 | private String gender; 12 | private String phone; 13 | private String email; // 不是必填项 14 | private String description; // 不是必填项 15 | 16 | public long getId() { 17 | return id; 18 | } 19 | 20 | public void setId(long id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getGender() { 33 | return gender; 34 | } 35 | 36 | public void setGender(String gender) { 37 | this.gender = gender; 38 | } 39 | 40 | public String getPhone() { 41 | return phone; 42 | } 43 | 44 | public void setPhone(String phone) { 45 | this.phone = phone; 46 | } 47 | 48 | public String getEmail() { 49 | return email; 50 | } 51 | 52 | public void setEmail(String email) { 53 | this.email = email; 54 | } 55 | 56 | public String getDescription() { 57 | return description; 58 | } 59 | 60 | public void setDescription(String description) { 61 | this.description = description; 62 | } 63 | 64 | public Boolean isNull(){ // 判断除id外的属性是否为空,用于后面编写controller模糊查询时的判断 65 | if(this.name == null && this.gender == null && this.phone == null 66 | && this.email == null && this.description == null){ 67 | return true; 68 | } 69 | return false; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return "Customer{" + 75 | "id='" + id + '\'' + 76 | ", name='" + name + '\'' + 77 | ", gender='" + gender + '\'' + 78 | ", phone='" + phone + '\'' + 79 | ", email='" + email + '\'' + 80 | ", description='" + description + '\'' + 81 | '}'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/silver/entity/PageBean.java: -------------------------------------------------------------------------------- 1 | package com.silver.entity; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 进行分页操作的Java Bean封装 7 | * @author 光玉 8 | * @create 2018-05-17 14:09 9 | **/ 10 | public class PageBean { 11 | private int pageNum; // 当前页码 12 | private int pageRecord; // 每页记录数 13 | private int totalRecord; // 总记录数 14 | private int totalPage; // 总页数 15 | private List beanList; // 当前页的记录 16 | 17 | public int getPageNum() { 18 | return pageNum; 19 | } 20 | 21 | public void setPageNum(int pageNum) { 22 | this.pageNum = pageNum; 23 | } 24 | 25 | public int getPageRecord() { 26 | return pageRecord; 27 | } 28 | 29 | public void setPageRecord(int pageRecord) { 30 | this.pageRecord = pageRecord; 31 | } 32 | 33 | public int getTotalRecord() { 34 | return totalRecord; 35 | } 36 | 37 | public void setTotalRecord(int totalRecord) { 38 | this.totalRecord = totalRecord; 39 | } 40 | 41 | public int getTotalPage() { 42 | return totalPage; 43 | } 44 | 45 | public void setTotalPage(int totalPage) { 46 | this.totalPage = totalPage; 47 | } 48 | 49 | public List getBeanList() { 50 | return beanList; 51 | } 52 | 53 | public void setBeanList(List beanList) { 54 | this.beanList = beanList; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "PageBean{" + 60 | "pageNum=" + pageNum + 61 | ", pageRecord=" + pageRecord + 62 | ", totalRecord=" + totalRecord + 63 | ", totalPage=" + totalPage + 64 | ", beanList=" + beanList + 65 | '}'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/silver/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package com.silver.service; 2 | 3 | import com.silver.entity.Customer; 4 | import com.silver.entity.PageBean; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 业务层,编写业务逻辑,调用Dao层 10 | * @author 光玉 11 | * @create 2018-05-17 16:07 12 | **/ 13 | public interface CustomerService { 14 | /** 15 | * 分页查询 16 | * @param offset 17 | * @param pageRecord 18 | * @return 19 | */ 20 | public PageBean allList(int offset, int pageRecord) throws Exception; 21 | 22 | /** 23 | * 通过id查找客户 24 | * @param id 25 | * @return 26 | * @throws Exception 27 | */ 28 | public Customer getById(long id)throws Exception; 29 | 30 | /** 31 | * 添加客户 32 | * @param customer 33 | * @throws Exception 34 | */ 35 | public void insert(Customer customer)throws Exception; 36 | 37 | /** 38 | * 通过id删除客户 39 | * @param id 40 | * @throws Exception 41 | */ 42 | public void delete(long id)throws Exception; 43 | 44 | /** 45 | * 修改客户信息 46 | * @param id 47 | * @param customer 48 | * @throws Exception 49 | */ 50 | public void update(long id,Customer customer)throws Exception; 51 | 52 | /** 53 | * 分页查询,模糊查询,还需要在Service实现类中编写一些业务逻辑 54 | * @param offset 55 | * @param pageRecord 56 | * @param customer 57 | * @return 58 | * @throws Exception 59 | */ 60 | public PageBean queryList(int offset, int pageRecord, Customer customer)throws Exception; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/silver/service/impl/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.silver.service.impl; 2 | 3 | import com.silver.dao.CustomerDao; 4 | import com.silver.entity.Customer; 5 | import com.silver.entity.PageBean; 6 | import com.silver.service.CustomerService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Service接口的实现类 14 | * @author 光玉 15 | * @create 2018-05-17 16:54 16 | **/ 17 | @Service 18 | public class CustomerServiceImpl implements CustomerService{ 19 | // 注入依赖 20 | @Autowired 21 | private CustomerDao customerDao; 22 | 23 | @Override 24 | public PageBean allList(int offset, int pageRecord) throws Exception{ 25 | List customers = customerDao.findAll(offset,pageRecord); 26 | Customer customer = new Customer(); 27 | int totalRecord = customerDao.countCustomers(customer); // 获取总记录数 28 | int pageNum = offset/pageRecord + 1; // 当前页数 29 | // 计算总页数 30 | int totalPage; 31 | if (totalRecord % pageRecord == 0){ 32 | totalPage = totalRecord/pageRecord; 33 | } else { 34 | totalPage = totalRecord/pageRecord + 1; 35 | } 36 | PageBean pageBean = new PageBean<>(); // 将分页数据封装到PageBean中 37 | pageBean.setBeanList(customers); 38 | pageBean.setPageNum(pageNum); 39 | pageBean.setPageRecord(pageRecord); 40 | pageBean.setTotalRecord(totalRecord); 41 | pageBean.setTotalPage(totalPage); 42 | 43 | return pageBean; // 返回封装后的数据 44 | } 45 | 46 | @Override 47 | public Customer getById(long id) throws Exception { 48 | Customer customer = customerDao.findById(id); 49 | return customer; 50 | } 51 | 52 | @Override 53 | public void insert(Customer customer) throws Exception { 54 | customerDao.addCustomer(customer); 55 | } 56 | 57 | @Override 58 | public void delete(long id) throws Exception { 59 | customerDao.deleteCustomer(id); 60 | } 61 | 62 | @Override 63 | public void update(long id,Customer customer) throws Exception { 64 | customerDao.editCustomer(id,customer); 65 | } 66 | 67 | @Override 68 | public PageBean queryList(int offset, int pageRecord, Customer customer) throws Exception { 69 | List customers = customerDao.queryAll(offset,pageRecord,customer); // 获取每页的所有记录 70 | int totalRecord = customerDao.countCustomers(customer); // 获取模糊查询总记录数 71 | int pageNum = offset/pageRecord + 1; // 当前页数 72 | // 计算总页数 73 | int totalPage; 74 | if (totalRecord % pageRecord == 0){ 75 | totalPage = totalRecord/pageRecord; 76 | } else { 77 | totalPage = totalRecord/pageRecord + 1; 78 | } 79 | PageBean pageBean = new PageBean<>(); // 将分页数据封装到PageBean中 80 | pageBean.setBeanList(customers); 81 | pageBean.setPageNum(pageNum); 82 | pageBean.setPageRecord(pageRecord); 83 | pageBean.setTotalRecord(totalRecord); 84 | pageBean.setTotalPage(totalPage); 85 | 86 | return pageBean; // 返回封装后的数据 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | # url\u4E2D\u201CuseSSL=false\u201D\u8868\u793A\u4E0D\u4F7F\u7528SSL\u8FDE\u63A5\uFF08\u4E5F\u53EF\u4EE5\u8BBE\u7F6E\u4E3Atrue\uFF09\uFF0C\u5982\u679C\u4F7F\u7528\u9AD8\u7248\u672C\u7684mysql\uFF0C\u4E0D\u5199\u4E0A\u7684\u8BDD\u4F1A\u5728\u63A7\u5236\u53F0\u8F93\u51FA\u8B66\u544A 2 | jdbc.driver=com.mysql.jdbc.Driver 3 | jdbc.url=jdbc:mysql://localhost:3306/customer?useUnicode=true&characterEncoding=utf-8&useSSL=false 4 | jdbc.username=mysql 5 | jdbc.password=123456 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/mapper/CustomerDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | SELECT * FROM customer 9 | limit #{offset}, #{pageRecord} 10 | 11 | 12 | 13 | SELECT * FROM customer 14 | WHERE id = #{id} 15 | 16 | 17 | 18 | INSERT INTO customer(id,name,gender,phone,email,description) 19 | VALUES (null,#{name},#{gender},#{phone},#{email},#{description}) 20 | 21 | 22 | 23 | DELETE FROM customer 24 | WHERE id = #{id} 25 | 26 | 27 | 28 | UPDATE customer 29 | SET name = #{customer.name}, 30 | phone = #{customer.phone}, 31 | gender = #{customer.gender}, 32 | email = #{customer.email}, 33 | description = #{customer.description} 34 | WHERE id = #{id} 35 | 36 | 37 | 38 | SELECT COUNT(*) FROM customer 39 | 40 | 41 | 42 | 43 | 44 | SELECT * FROM customer 45 | 46 | 47 | limit #{offset}, #{pageRecord} 48 | 49 | 50 | 51 | 52 | WHERE 1 = 1 53 | 54 | 55 | 56 | and name like "%${customer.name}%" 57 | 58 | 59 | and gender like "%${customer.gender}%" 60 | 61 | 62 | and phone like "%${customer.phone}%" 63 | 64 | 65 | and email like "%${customer.email}%" 66 | 67 | 68 | and description like "%${customer.description}%" 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-dao.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-service.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/sql/customer.sql: -------------------------------------------------------------------------------- 1 | -- 数据库初始化脚本 2 | 3 | -- 创建数据库 4 | CREATE DATABASE customer; 5 | 6 | -- 切换到customer数据库 7 | use customer; 8 | 9 | -- 建表 10 | CREATE TABLE `customer` ( 11 | `id` bigint NOT NULL AUTO_INCREMENT, 12 | `name` varchar(50) NOT NULL, 13 | `gender` varchar(50) NOT NULL, 14 | `phone` varchar(50) NOT NULL, 15 | `email` varchar(50) DEFAULT NULL, 16 | `description` varchar(200) DEFAULT NULL, 17 | PRIMARY KEY (`id`) 18 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 19 | 20 | -- 插入数据 21 | INSERT INTO customer(name,gender,phone,email,description) 22 | VALUES ('小明','男','13723232333','小明@126.com','我是小明'), 23 | ('小红','女','15689897568','小红@126.com','我是小红'), 24 | ('张飞','男','15826547965','张飞@126.com','我是张飞'), 25 | ('关羽','男','13621214896','关羽@126.com','我是关羽'), 26 | ('刘备','男','12345678910','刘备@126.com','我是刘备'); 27 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/DevelopDoc.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 光玉 4 | Date: 2018/3/30 5 | Time: 12:39 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | DevelopDoc 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 客户关系管理系统2.0版本 23 | 24 | 前端框架:Layui 25 | 后台技术:ssm+maven+mysql 26 | 27 | 28 | 客户关系管理系统1.0版本 29 | 30 | 前端框架:Layui 31 | 后台技术:JSP+Servlet+SQL Server 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/add.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 光玉 4 | Date: 2018/3/25 5 | Time: 23:15 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 添加客户信息 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 姓名 27 | 28 | 30 | 31 | 32 | 33 | 34 | 性别 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 手机 43 | 44 | 46 | 47 | 48 | 49 | 50 | 邮箱 51 | 52 | 53 | 54 | 55 | 56 | 57 | 个人描述 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 添加客户 66 | 重置 67 | 68 | 69 | 70 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/edit.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 光玉 4 | Date: 2018/3/26 5 | Time: 12:40 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 编辑客户信息 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 姓名 24 | 25 | 26 | 27 | 28 | 29 | 30 | 性别 31 | 32 | checked/> 33 | checked /> 34 | 35 | 36 | 37 | 38 | 手机 39 | 40 | 41 | 42 | 43 | 44 | 45 | 邮箱 46 | 47 | 48 | 49 | 50 | 51 | 52 | 个人描述 53 | 54 | ${customer.description} 55 | 56 | 57 | 58 | 59 | 60 | 编辑客户 61 | 重置 62 | 63 | 64 | 65 | 66 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/frame.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 光玉 4 | Date: 2018/3/25 5 | Time: 11:22 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%-- 每个jsp文件中都加入下面两句 --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> 10 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%--注意:需要放一个jstl.jar包到Tomcat的WEB-INF/lib下--%> 11 | 12 | 13 | 14 | 客户管理系统主界面 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Admin 28 | <%-- 头部区域(可配合layui已有的水平导航) --%> 29 | 30 | 控制台 31 | 32 | 邮件管理 33 | 消息管理 34 | 授权管理 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 管理员 43 | 44 | 45 | 基本资料 46 | 安全设置 47 | 48 | 49 | 注销 50 | 51 | 52 | 53 | 54 | 55 | <%-- 左侧导航区域(可配合layui已有的垂直导航) --%> 56 | 57 | 58 | 基本操作 59 | 60 | 客户信息 61 | 添加客户 62 | 高级搜索 63 | 64 | 65 | 开发日志 66 | 67 | 68 | 69 | 70 | 71 | <%-- 内容主体区域 --%> 72 | 73 | 74 | 78 | 79 | 80 |
22 | 客户关系管理系统2.0版本 23 | 24 | 前端框架:Layui 25 | 后台技术:ssm+maven+mysql 26 | 27 | 28 | 客户关系管理系统1.0版本 29 | 30 | 前端框架:Layui 31 | 后台技术:JSP+Servlet+SQL Server 32 | 33 |