码迷,mamicode.com
首页 > 其他好文 > 详细

SSM框架整合,以CRM为例子

时间:2017-07-23 18:17:16      阅读:1536      评论:0      收藏:0      [点我收藏+]

标签:www   编辑功能   ntb   icon   path   ast   bind   next   attr   

 

 

 

MybatisSpringMVC练习

 

CRM系统

 

 

 

 

  1. 回顾

Springmvc  高级参数绑定  数组  List

<input type  name=ids />  多个

方法 (Integer[] ids)  QueryVo (里面Integer[] ids)

 

方法(QueryVo 里面List<Items> itemList

<input type  name=itemList[${s.index}].name />

 

 

  1. 2.  REquestMapping 处理器映射器(找此标签  路径 )

Value = {多个路径,}

Value = {/item/sfdsf.action}  类头上

Method=RequestMethod.POST或GET

3、 Controller方法返回值

三个

ModelAndView  建议不使用 不解偶

String   返回视图的路径   (形参 绑定Model )    重定向redirect:另一个方法的映射路径  forward:内部转发

Void    异步请求使用

 

 

  1. 异常处理器

预期、运行时

自定义异常处理类 实现HandlerEexceptionResolver 

由Spring实现化 自定义的处理类

未知异常

 

CustomEexception 继承Eexception 

 

 

4、 上传图片

1)Form  上传图片了  action上传路径

2)input type=file  name=picturePic

3)接收此图片  形参上绑定 MultipartFile picturePic 接口

4)配置此接口的实现类 Springmvc.xml配置CommonsMultipartFileResolver   id=multipartFileResolver

5、JSON数据交互

应用场景:前端是各种  html Freemarker  JSP一个Servlet 是Java代码 jstl C

 

浏览器 Ajax  发送JSON字符串 报文 

 

6、拦截器

 

拦截器 应用 (练习)

 

 

 

 

 

 

 

 

 

 

 

 

1   CRM项目外观

技术分享

 

1.   开发环境

IDE:     Eclipse Mars2

Jdk:       1.7

数据库: MySQL

2.   创建数据库

数据库sql文件如下:

 

/*
Navicat MySQL Data Transfer

Source Server         : localhost_3306
Source Server Version : 50611
Source Host           : localhost:3306
Source Database       : crm

Target Server Type    : MYSQL
Target Server Version : 50611
File Encoding         : 65001

Date: 2016-05-12 00:07:42
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for base_dict
-- ----------------------------
DROP TABLE IF EXISTS `base_dict`;
CREATE TABLE `base_dict` (
  `dict_id` varchar(32) NOT NULL COMMENT ‘数据字典id(主键)‘,
  `dict_type_code` varchar(10) NOT NULL COMMENT ‘数据字典类别代码‘,
  `dict_type_name` varchar(64) NOT NULL COMMENT ‘数据字典类别名称‘,
  `dict_item_name` varchar(64) NOT NULL COMMENT ‘数据字典项目名称‘,
  `dict_item_code` varchar(10) DEFAULT NULL COMMENT ‘数据字典项目代码(可为空)‘,
  `dict_sort` int(10) DEFAULT NULL COMMENT ‘排序字段‘,
  `dict_enable` char(1) NOT NULL COMMENT ‘1:使用 0:停用‘,
  `dict_memo` varchar(64) DEFAULT NULL COMMENT ‘备注‘,
  PRIMARY KEY (`dict_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of base_dict
-- ----------------------------
INSERT INTO `base_dict` VALUES (‘1‘, ‘001‘, ‘客户行业‘, ‘教育培训 ‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘10‘, ‘003‘, ‘公司性质‘, ‘民企‘, null, ‘3‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘12‘, ‘004‘, ‘年营业额‘, ‘1-10万‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘13‘, ‘004‘, ‘年营业额‘, ‘10-20万‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘14‘, ‘004‘, ‘年营业额‘, ‘20-50万‘, null, ‘3‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘15‘, ‘004‘, ‘年营业额‘, ‘50-100万‘, null, ‘4‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘16‘, ‘004‘, ‘年营业额‘, ‘100-500万‘, null, ‘5‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘17‘, ‘004‘, ‘年营业额‘, ‘500-1000万‘, null, ‘6‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘18‘, ‘005‘, ‘客户状态‘, ‘基础客户‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘19‘, ‘005‘, ‘客户状态‘, ‘潜在客户‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘2‘, ‘001‘, ‘客户行业‘, ‘电子商务‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘20‘, ‘005‘, ‘客户状态‘, ‘成功客户‘, null, ‘3‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘21‘, ‘005‘, ‘客户状态‘, ‘无效客户‘, null, ‘4‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘22‘, ‘006‘, ‘客户级别‘, ‘普通客户‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘23‘, ‘006‘, ‘客户级别‘, ‘VIP客户‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘24‘, ‘007‘, ‘商机状态‘, ‘意向客户‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘25‘, ‘007‘, ‘商机状态‘, ‘初步沟通‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘26‘, ‘007‘, ‘商机状态‘, ‘深度沟通‘, null, ‘3‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘27‘, ‘007‘, ‘商机状态‘, ‘签订合同‘, null, ‘4‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘3‘, ‘001‘, ‘客户行业‘, ‘对外贸易‘, null, ‘3‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘30‘, ‘008‘, ‘商机类型‘, ‘新业务‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘31‘, ‘008‘, ‘商机类型‘, ‘现有业务‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘32‘, ‘009‘, ‘商机来源‘, ‘电话营销‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘33‘, ‘009‘, ‘商机来源‘, ‘网络营销‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘34‘, ‘009‘, ‘商机来源‘, ‘推广活动‘, null, ‘3‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘4‘, ‘001‘, ‘客户行业‘, ‘酒店旅游‘, null, ‘4‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘5‘, ‘001‘, ‘客户行业‘, ‘房地产‘, null, ‘5‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘6‘, ‘002‘, ‘客户信息来源‘, ‘电话营销‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘7‘, ‘002‘, ‘客户信息来源‘, ‘网络营销‘, null, ‘2‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘8‘, ‘003‘, ‘公司性质‘, ‘合资‘, null, ‘1‘, ‘1‘, null);
INSERT INTO `base_dict` VALUES (‘9‘, ‘003‘, ‘公司性质‘, ‘国企‘, null, ‘2‘, ‘1‘, null);

-- ----------------------------
-- Table structure for customer
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
  `cust_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT ‘客户编号(主键)‘,
  `cust_name` varchar(32) NOT NULL COMMENT ‘客户名称(公司名称)‘,
  `cust_user_id` bigint(32) DEFAULT NULL COMMENT ‘负责人id‘,
  `cust_create_id` bigint(32) DEFAULT NULL COMMENT ‘创建人id‘,
  `cust_source` varchar(32) DEFAULT NULL COMMENT ‘客户信息来源‘,
  `cust_industry` varchar(32) DEFAULT NULL COMMENT ‘客户所属行业‘,
  `cust_level` varchar(32) DEFAULT NULL COMMENT ‘客户级别‘,
  `cust_linkman` varchar(64) DEFAULT NULL COMMENT ‘联系人‘,
  `cust_phone` varchar(64) DEFAULT NULL COMMENT ‘固定电话‘,
  `cust_mobile` varchar(16) DEFAULT NULL COMMENT ‘移动电话‘,
  `cust_zipcode` varchar(10) DEFAULT NULL,
  `cust_address` varchar(100) DEFAULT NULL,
  `cust_createtime` datetime DEFAULT NULL COMMENT ‘创建时间‘,
  PRIMARY KEY (`cust_id`),
  KEY `FK_cst_customer_source` (`cust_source`),
  KEY `FK_cst_customer_industry` (`cust_industry`),
  KEY `FK_cst_customer_level` (`cust_level`),
  KEY `FK_cst_customer_user_id` (`cust_user_id`),
  KEY `FK_cst_customer_create_id` (`cust_create_id`)
) ENGINE=InnoDB AUTO_INCREMENT=162 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of customer
-- ----------------------------
INSERT INTO `customer` VALUES (‘14‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:01‘);
INSERT INTO `customer` VALUES (‘15‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:01‘);
INSERT INTO `customer` VALUES (‘16‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:01‘);
INSERT INTO `customer` VALUES (‘17‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:02‘);
INSERT INTO `customer` VALUES (‘22‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:03‘);
INSERT INTO `customer` VALUES (‘24‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:03‘);
INSERT INTO `customer` VALUES (‘25‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:03‘);
INSERT INTO `customer` VALUES (‘26‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:03‘);
INSERT INTO `customer` VALUES (‘28‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:04‘);
INSERT INTO `customer` VALUES (‘29‘, ‘令狐冲‘, null, null, ‘7‘, ‘1‘, ‘23‘, ‘任盈盈‘, ‘0108888886‘, ‘13888888886‘, ‘6123456‘, ‘北京三里桥6‘, ‘2016-04-08 16:32:04‘);
INSERT INTO `customer` VALUES (‘30‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:04‘);
INSERT INTO `customer` VALUES (‘31‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:04‘);
INSERT INTO `customer` VALUES (‘33‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:04‘);
INSERT INTO `customer` VALUES (‘34‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:05‘);
INSERT INTO `customer` VALUES (‘35‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:05‘);
INSERT INTO `customer` VALUES (‘36‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:05‘);
INSERT INTO `customer` VALUES (‘37‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:05‘);
INSERT INTO `customer` VALUES (‘38‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:05‘);
INSERT INTO `customer` VALUES (‘39‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:06‘);
INSERT INTO `customer` VALUES (‘40‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:06‘);
INSERT INTO `customer` VALUES (‘41‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:06‘);
INSERT INTO `customer` VALUES (‘42‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:06‘);
INSERT INTO `customer` VALUES (‘43‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:06‘);
INSERT INTO `customer` VALUES (‘44‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:07‘);
INSERT INTO `customer` VALUES (‘45‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:07‘);
INSERT INTO `customer` VALUES (‘46‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:07‘);
INSERT INTO `customer` VALUES (‘47‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:07‘);
INSERT INTO `customer` VALUES (‘48‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:07‘);
INSERT INTO `customer` VALUES (‘49‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:07‘);
INSERT INTO `customer` VALUES (‘50‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:08‘);
INSERT INTO `customer` VALUES (‘51‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:08‘);
INSERT INTO `customer` VALUES (‘52‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:08‘);
INSERT INTO `customer` VALUES (‘53‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:08‘);
INSERT INTO `customer` VALUES (‘54‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:08‘);
INSERT INTO `customer` VALUES (‘55‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:08‘);
INSERT INTO `customer` VALUES (‘56‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:09‘);
INSERT INTO `customer` VALUES (‘57‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:09‘);
INSERT INTO `customer` VALUES (‘58‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:09‘);
INSERT INTO `customer` VALUES (‘59‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:29‘);
INSERT INTO `customer` VALUES (‘60‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:29‘);
INSERT INTO `customer` VALUES (‘61‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:29‘);
INSERT INTO `customer` VALUES (‘62‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:29‘);
INSERT INTO `customer` VALUES (‘63‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:30‘);
INSERT INTO `customer` VALUES (‘64‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:30‘);
INSERT INTO `customer` VALUES (‘65‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:30‘);
INSERT INTO `customer` VALUES (‘66‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:30‘);
INSERT INTO `customer` VALUES (‘67‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:30‘);
INSERT INTO `customer` VALUES (‘68‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:30‘);
INSERT INTO `customer` VALUES (‘69‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:31‘);
INSERT INTO `customer` VALUES (‘70‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:31‘);
INSERT INTO `customer` VALUES (‘71‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:31‘);
INSERT INTO `customer` VALUES (‘72‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:31‘);
INSERT INTO `customer` VALUES (‘73‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:31‘);
INSERT INTO `customer` VALUES (‘74‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:32‘);
INSERT INTO `customer` VALUES (‘75‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:32‘);
INSERT INTO `customer` VALUES (‘76‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:32‘);
INSERT INTO `customer` VALUES (‘77‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:32‘);
INSERT INTO `customer` VALUES (‘78‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:32‘);
INSERT INTO `customer` VALUES (‘79‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:32‘);
INSERT INTO `customer` VALUES (‘80‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:33‘);
INSERT INTO `customer` VALUES (‘81‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:33‘);
INSERT INTO `customer` VALUES (‘82‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:33‘);
INSERT INTO `customer` VALUES (‘83‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:33‘);
INSERT INTO `customer` VALUES (‘84‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:33‘);
INSERT INTO `customer` VALUES (‘85‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:33‘);
INSERT INTO `customer` VALUES (‘86‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:34‘);
INSERT INTO `customer` VALUES (‘87‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:34‘);
INSERT INTO `customer` VALUES (‘88‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:34‘);
INSERT INTO `customer` VALUES (‘89‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:34‘);
INSERT INTO `customer` VALUES (‘90‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:34‘);
INSERT INTO `customer` VALUES (‘91‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:34‘);
INSERT INTO `customer` VALUES (‘92‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:35‘);
INSERT INTO `customer` VALUES (‘93‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:35‘);
INSERT INTO `customer` VALUES (‘94‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:35‘);
INSERT INTO `customer` VALUES (‘95‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:35‘);
INSERT INTO `customer` VALUES (‘96‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:35‘);
INSERT INTO `customer` VALUES (‘97‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:36‘);
INSERT INTO `customer` VALUES (‘98‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:36‘);
INSERT INTO `customer` VALUES (‘99‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:36‘);
INSERT INTO `customer` VALUES (‘100‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:36‘);
INSERT INTO `customer` VALUES (‘101‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:36‘);
INSERT INTO `customer` VALUES (‘102‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:36‘);
INSERT INTO `customer` VALUES (‘103‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:37‘);
INSERT INTO `customer` VALUES (‘104‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:37‘);
INSERT INTO `customer` VALUES (‘105‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:37‘);
INSERT INTO `customer` VALUES (‘106‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:37‘);
INSERT INTO `customer` VALUES (‘107‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:37‘);
INSERT INTO `customer` VALUES (‘108‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:38‘);
INSERT INTO `customer` VALUES (‘109‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:38‘);
INSERT INTO `customer` VALUES (‘110‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:38‘);
INSERT INTO `customer` VALUES (‘111‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:38‘);
INSERT INTO `customer` VALUES (‘112‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:38‘);
INSERT INTO `customer` VALUES (‘113‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:38‘);
INSERT INTO `customer` VALUES (‘114‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:39‘);
INSERT INTO `customer` VALUES (‘115‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:39‘);
INSERT INTO `customer` VALUES (‘116‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:39‘);
INSERT INTO `customer` VALUES (‘117‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:39‘);
INSERT INTO `customer` VALUES (‘118‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:39‘);
INSERT INTO `customer` VALUES (‘119‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:40‘);
INSERT INTO `customer` VALUES (‘120‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:40‘);
INSERT INTO `customer` VALUES (‘121‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:40‘);
INSERT INTO `customer` VALUES (‘122‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:40‘);
INSERT INTO `customer` VALUES (‘123‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:40‘);
INSERT INTO `customer` VALUES (‘124‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:40‘);
INSERT INTO `customer` VALUES (‘125‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:41‘);
INSERT INTO `customer` VALUES (‘126‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:41‘);
INSERT INTO `customer` VALUES (‘127‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:41‘);
INSERT INTO `customer` VALUES (‘128‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:41‘);
INSERT INTO `customer` VALUES (‘129‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:41‘);
INSERT INTO `customer` VALUES (‘130‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:42‘);
INSERT INTO `customer` VALUES (‘131‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:42‘);
INSERT INTO `customer` VALUES (‘132‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:42‘);
INSERT INTO `customer` VALUES (‘133‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:42‘);
INSERT INTO `customer` VALUES (‘134‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:42‘);
INSERT INTO `customer` VALUES (‘135‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:42‘);
INSERT INTO `customer` VALUES (‘136‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:43‘);
INSERT INTO `customer` VALUES (‘137‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:43‘);
INSERT INTO `customer` VALUES (‘138‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:43‘);
INSERT INTO `customer` VALUES (‘139‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:43‘);
INSERT INTO `customer` VALUES (‘140‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:43‘);
INSERT INTO `customer` VALUES (‘141‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:44‘);
INSERT INTO `customer` VALUES (‘142‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:44‘);
INSERT INTO `customer` VALUES (‘143‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:44‘);
INSERT INTO `customer` VALUES (‘144‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:44‘);
INSERT INTO `customer` VALUES (‘145‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:44‘);
INSERT INTO `customer` VALUES (‘146‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:44‘);
INSERT INTO `customer` VALUES (‘147‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:45‘);
INSERT INTO `customer` VALUES (‘148‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:45‘);
INSERT INTO `customer` VALUES (‘149‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:45‘);
INSERT INTO `customer` VALUES (‘150‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:45‘);
INSERT INTO `customer` VALUES (‘151‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:45‘);
INSERT INTO `customer` VALUES (‘152‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:46‘);
INSERT INTO `customer` VALUES (‘153‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:46‘);
INSERT INTO `customer` VALUES (‘154‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:46‘);
INSERT INTO `customer` VALUES (‘155‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:46‘);
INSERT INTO `customer` VALUES (‘156‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:46‘);
INSERT INTO `customer` VALUES (‘157‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:46‘);
INSERT INTO `customer` VALUES (‘158‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:47‘);
INSERT INTO `customer` VALUES (‘159‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:47‘);
INSERT INTO `customer` VALUES (‘160‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:47‘);
INSERT INTO `customer` VALUES (‘161‘, ‘马云‘, null, null, ‘6‘, ‘2‘, ‘22‘, ‘马化腾‘, ‘0108888887‘, ‘13888888888‘, ‘123456‘, ‘北京三里桥‘, ‘2016-04-08 16:32:47‘);

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `user_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT ‘用户id‘,
  `user_code` varchar(32) NOT NULL COMMENT ‘用户账号‘,
  `user_name` varchar(64) NOT NULL COMMENT ‘用户名称‘,
  `user_password` varchar(32) NOT NULL COMMENT ‘用户密码‘,
  `user_state` char(1) NOT NULL COMMENT ‘1:正常,0:暂停‘,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES (‘5‘, ‘m0003‘, ‘小军‘, ‘123‘, ‘1‘);
INSERT INTO `sys_user` VALUES (‘6‘, ‘m0001‘, ‘小红‘, ‘123‘, ‘1‘);
INSERT INTO `sys_user` VALUES (‘7‘, ‘m0001‘, ‘小明‘, ‘123‘, ‘1‘);
INSERT INTO `sys_user` VALUES (‘8‘, ‘m0001‘, ‘小红‘, ‘123‘, ‘1‘);

  

 

创建crm数据库,执行sql

 

效果如下图:

 技术分享

 

 

3.   工程搭建

使用的Bootstrap前端框架,官方网站

http://www.bootcss.com/

 

工程使用Springmvc、spring、mybatis框架整合完成。

 

3.1. 需要的jar包

  1. spring(包括springmvc)
  2. mybatis
  3. mybatis-spring整合包
  4. 数据库驱动
  5. 第三方连接池。
  6. Json依赖包Jackson

 

jar包位置如下图:

 技术分享

 

3.2. 整合思路

Dao层:

1、SqlMapConfig.xml,空文件即可,但是需要文件头。

2、applicationContext-dao.xml

a)       数据库连接Druid

b)      SqlSessionFactory对象,需要spring和mybatis整合包下的。

c)       配置mapper文件扫描器。Mapper动态代理开发 增强版

 

Service层:

1、applicationContext-service.xml包扫描器,扫描@service注解的类。

2、applicationContext-trans.xml配置事务。

 

Controller层:

1、Springmvc.xml

a)       包扫描器,扫描@Controller注解的类。

b)      配置注解驱动

c)       配置视图解析器

 

Web.xml文件:

1、配置spring监听器

2、配置前端控制器。

 

3.3. 创建工程

创建动态web工程,步骤如下图:

 

 技术分享

 

创建boot-crm,如下图

 技术分享

 

 

3.4. 加入jar包

加入资料中的jar包

 

3.5. 加入配置文件

创建config资源文件夹,在里面创建mybatis和spring文件夹

3.5.1. SqlMapConfig.xml

空文件即可

1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
3 "http://mybatis.org/dtd/mybatis-3-config.dtd">
4 <configuration>
5 
6  
7 
8 </configuration>

 

 

3.5.2. applicationContext-dao.xml

需要配置:

加载properties文件,数据源,SqlSessionFactory,Mapper扫描

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
 4     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 5     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
 7     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
 8     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
 9     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
10 
11     <!-- 配置 读取properties文件 jdbc.properties -->
12     <context:property-placeholder location="classpath:jdbc.properties" />
13 
14     <!-- 配置 数据源 -->
15     <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
16         <property name="driverClassName" value="${jdbc.driver}" />
17         <property name="url" value="${jdbc.url}" />
18         <property name="username" value="${jdbc.username}" />
19         <property name="password" value="${jdbc.password}" />
20     </bean>
21 
22     <!-- 配置SqlSessionFactory -->
23     <bean class="org.mybatis.spring.SqlSessionFactoryBean">
24         <!-- 设置MyBatis核心配置文件 -->
25         <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
26         <!-- 设置数据源 -->
27         <property name="dataSource" ref="dataSource" />
28     </bean>
29 
30     <!-- 配置Mapper扫描 -->
31     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
32         <!-- 设置Mapper扫描包 -->
33         <property name="basePackage" value="cn.itcast.crm.mapper" />
34     </bean>
35 </beans>

 

 

3.5.3. jdbc.properties

配置数据库信息

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/crm?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

 

 

3.5.4. log4j.properties

配置日志信息

1 # Global logging configuration
2 log4j.rootLogger=DEBUG, stdout
3 # Console output...
4 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
6 log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

 

 

3.5.5. applicationContext-service.xml

配置service扫描

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
 4     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 5     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
 7     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
 8     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
 9     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
10 
11     <!-- 配置Service扫描 -->
12     <context:component-scan base-package="cn.itcast.crm.service" />
13 </beans>

 

 

3.5.6. applicationContext-trans.xml

配置事务管理:事务管理器、通知、切面

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
 4     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 5     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
 7     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
 8     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
 9     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
10 
11     <!-- 事务管理器 -->
12     <bean id="transactionManager"    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
13         <!-- 数据源 -->
14         <property name="dataSource" ref="dataSource" />
15     </bean>
16 
17     <!-- 通知 -->
18     <tx:advice id="txAdvice" transaction-manager="transactionManager">
19         <tx:attributes>
20             <!-- 传播行为 -->
21             <tx:method name="save*" propagation="REQUIRED" />
22             <tx:method name="insert*" propagation="REQUIRED" />
23             <tx:method name="add*" propagation="REQUIRED" />
24             <tx:method name="create*" propagation="REQUIRED" />
25             <tx:method name="delete*" propagation="REQUIRED" />
26             <tx:method name="update*" propagation="REQUIRED" />
27             <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
28             <tx:method name="select*" propagation="SUPPORTS" read-only="true" />
29             <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
30             <tx:method name="query*" propagation="SUPPORTS" read-only="true" />
31         </tx:attributes>
32     </tx:advice>
33 
34     <!-- 切面 -->
35     <aop:config>
36         <aop:advisor advice-ref="txAdvice"
37             pointcut="execution(* cn.itcast.crm.service.*.*(..))" />
38     </aop:config>
39 
40 </beans>

 

 

 

3.5.7. Springmvc.xml

配置SpringMVC表现层:Controller扫描、注解驱动、视图解析器

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:mvc="http://www.springframework.org/schema/mvc"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
 7         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
 8         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
 9     <!-- 配置Controller扫描 -->
10     <context:component-scan base-package="cn.itcast.crm.controller" />
11 
12     <!-- 配置注解驱动 -->
13     <mvc:annotation-driven />
14 
15     <!-- 配置视图解析器 -->
16     <bean    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
17         <!-- 前缀 -->
18         <property name="prefix" value="/WEB-INF/jsp/" />
19         <!-- 后缀 -->
20         <property name="suffix" value=".jsp" />
21     </bean>
22 </beans>

 

 

3.5.8. Web.xml

配置Spring、SpringMVC、解决post乱码问题

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://java.sun.com/xml/ns/javaee"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 5     id="WebApp_ID" version="2.5">
 6     <display-name>boot-crm</display-name>
 7     <welcome-file-list>
 8         <welcome-file>index.jsp</welcome-file>
 9     </welcome-file-list>
10 
11     <!-- 配置spring -->
12     <context-param>
13         <param-name>contextConfigLocation</param-name>
14         <param-value>classpath:spring/applicationContext-*.xml</param-value>
15     </context-param>
16 
17     <!-- 配置监听器加载spring -->
18     <listener>
19         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
20     </listener>
21 
22     <!-- 配置过滤器,解决post的乱码问题 -->
23     <filter>
24         <filter-name>encoding</filter-name>    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
25     <init-param>
26             <param-name>encoding</param-name>
27             <param-value>UTF-8</param-value>
28     </init-param>
29     </filter>
30     <filter-mapping>
31         <filter-name>encoding</filter-name>
32         <url-pattern>/*</url-pattern>
33     </filter-mapping>
34 
35     <!-- 配置SpringMVC -->
36     <servlet>
37         <servlet-name>boot-crm</servlet-name>
38         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
39         <init-param>
40             <param-name>contextConfigLocation</param-name>
41             <param-value>classpath:spring/springmvc.xml</param-value>
42         </init-param>
43         <!-- 配置springmvc什么时候启动,参数必须为整数 -->
44         <!-- 如果为0或者大于0,则springMVC随着容器启动而启动 -->
45         <!-- 如果小于0,则在第一次请求进来的时候启动 -->
46         <load-on-startup>1</load-on-startup>
47     </servlet>
48     <servlet-mapping>
49         <servlet-name>boot-crm</servlet-name>
50         <!-- 所有的请求都进入springMVC -->
51         <url-pattern>/</url-pattern>
52     </servlet-mapping>
53 </web-app>

 

3.6. 加入静态资源

最终效果如下图:

 技术分享

 

NavigationTag.java代码如下:

package com.itheima.common.utils;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * 显示格式 上一页 1 2 3 4 5 下一页
 */
public class NavigationTag extends TagSupport {
    
    
    static final long serialVersionUID = 2372405317744358833L;
    
    /**
     * request 中用于保存Page<E> 对象的变量名,默认为“page”
     */
    private String bean = "page";
    
    /**
     * 分页跳转的url地址,此属性必须
     */
    private String url = null;
    
    /**
     * 显示页码数量
     */
    private int number = 5;
    
    @Override
    public int doStartTag() throws JspException {
        JspWriter writer = pageContext.getOut();
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        Page page = (Page)request.getAttribute(bean); 
        if (page == null) 
            return SKIP_BODY;
        url = resolveUrl(url, pageContext);
        try {
            //计算总页数
            int pageCount = page.getTotal() / page.getSize();
            if (page.getTotal() % page.getSize() > 0) {
                pageCount++;
            }
            writer.print("<nav><ul class=\"pagination\">");
            //显示“上一页”按钮
            if (page.getPage() > 1) {
                String preUrl = append(url, "page", page.getPage() - 1);
                preUrl = append(preUrl, "rows", page.getSize());
                writer.print("<li><a href=\"" + preUrl + "\">上一页</a></li>");
            } else {
                writer.print("<li class=\"disabled\"><a href=\"#\">上一页</a></li>");
            }
            //显示当前页码的前2页码和后两页码 
            //若1 则 1 2 3 4 5, 若2 则 1 2 3 4 5, 若3 则1 2 3 4 5,
            //若4 则 2 3 4 5 6 ,若10  则 8 9 10 11 12
            int indexPage = (page.getPage() - 2 > 0)? page.getPage() - 2 : 1;  
            for(int i=1; i <= number && indexPage <= pageCount; indexPage++, i++) {
                if(indexPage == page.getPage()) {
                    writer.print( "<li class=\"active\"><a href=\"#\">"+indexPage+"<span class=\"sr-only\">(current)</span></a></li>");
                    continue;
                }
                String pageUrl  = append(url, "page", indexPage);
                pageUrl = append(pageUrl, "rows", page.getSize());
                writer.print("<li><a href=\"" + pageUrl + "\">"+ indexPage +"</a></li>");
            }
            //显示“下一页”按钮
            if (page.getPage() < pageCount) {
                String nextUrl  = append(url, "page", page.getPage() + 1);
                nextUrl = append(nextUrl, "rows", page.getSize());
                writer.print("<li><a href=\"" + nextUrl + "\">下一页</a></li>");
            } else {
                writer.print("<li class=\"disabled\"><a href=\"#\">下一页</a></li>");
            }
            writer.print("</nav>");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return SKIP_BODY;
    }
    
    private String append(String url, String key, int value) {

        return append(url, key, String.valueOf(value));
    }
    
    /**
     * 为url 参加参数对儿
     * 
     * @param url
     * @param key
     * @param value
     * @return
     */
    private String append(String url, String key, String value) {
        if (url == null || url.trim().length() == 0) {
            return "";
        }

        if (url.indexOf("?") == -1) {
            url = url + "?" + key + "=" + value;
        } else {
            if(url.endsWith("?")) {
                url = url + key + "=" + value;
            } else {
                url = url + "&amp;" + key + "=" + value;
            }
        }
        
        return url;
    }
    
    /**
     * 为url 添加翻页请求参数
     * 
     * @param url
     * @param pageContext
     * @return
     * @throws javax.servlet.jsp.JspException
     */
    private String resolveUrl(String url, javax.servlet.jsp.PageContext pageContext) throws JspException{
        //UrlSupport.resolveUrl(url, context, pageContext)
        Map params = pageContext.getRequest().getParameterMap();
        for (Object key:params.keySet()) {
            if ("page".equals(key) || "rows".equals(key)) continue;
            Object value = params.get(key);
            if (value == null) continue;
            if (value.getClass().isArray()) {
                url = append(url, key.toString(), ((String[])value)[0]);
            } else if (value instanceof String) {
                url = append(url, key.toString(), value.toString());
            }
        }
        return url;
    }
    
    

    /**
     * @return the bean
     */
    public String getBean() {
        return bean;
    }

    /**
     * @param bean the bean to set
     */
    public void setBean(String bean) {
        this.bean = bean;
    }

    /**
     * @return the url
     */
    public String getUrl() {
        return url;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = url;
    }

    public void setNumber(int number) {
        this.number = number;
    }
    
}

 

page.java代码如下:

package com.itheima.common.utils;

import java.util.List;

public class Page<T> {

    //总条数
    private int total;

    //页码数
    private int page;

    //每页多少条记录,要用它和total计算页码数,不能为空
    private int size;

    private List<T> rows;
    public int getTotal() {
        return total;
    }
    public void setTotal(int total) {
        this.total = total;
    }
    public int getPage() {
        return page;
    }
    public void setPage(int page) {
        this.page = page;
    }
    public int getSize() {
        return size;
    }
    public void setSize(int size) {
        this.size = size;
    }
    public List<T> getRows() {
        return rows;
    }
    public void setRows(List<T> rows) {
        this.rows = rows;
    }
    
    
    
}

 

commons.tld 代码如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
    <tlib-version>2.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>common</short-name>
    <uri>http://itcast.cn/common/</uri>
    <display-name>Common Tag</display-name>
    <description>Common Tag library</description>

    <tag>
        <name>page</name>
        <tag-class>com.itheima.common.utils.NavigationTag</tag-class>
        <body-content>JSP</body-content>
        <description>create navigation for paging</description>
        <attribute>
            <name>bean</name>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>number</name>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>url</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>
</taglib>

其他JS fonts css资料这里不要上传,如果你要的请联系我,我的邮箱为:450853723@qq.com

 

4.   实现页面展示

4.1. 代码实现

编写CustomerController 显示用户列表

 1 @Controller
 2 @RequestMapping("customer")
 3 public class CustomerController {
 4 
 5     /**
 6      * 显示用户列表
 7      * 
 8      * @return
 9      */
10     @RequestMapping("list")
11     public String queryCustomerList() {
12         return "customer";
13     }
14 
15 }

 

前端页面的总体代码,customer.jsp如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itcast.cn/common/"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<title>客户列表-BootCRM</title>

<!-- Bootstrap Core CSS -->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

<!-- MetisMenu CSS -->
<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet">

<!-- DataTables CSS -->
<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet">

<!-- Custom Fonts -->
<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet"
    type="text/css">
<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet"
    type="text/css">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn‘t work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation"
            style="margin-bottom: 0">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse"
                data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span> <span
                    class="icon-bar"></span> <span class="icon-bar"></span> <span
                    class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.html">BOOT客户管理系统 v2.0</a>
        </div>
        <!-- /.navbar-header -->

        <ul class="nav navbar-top-links navbar-right">
            <li class="dropdown"><a class="dropdown-toggle"
                data-toggle="dropdown" href="#"> <i class="fa fa-envelope fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-messages">
                    <li><a href="#">
                            <div>
                                <strong>令狐冲</strong> <span class="pull-right text-muted">
                                    <em>昨天</em>
                                </span>
                            </div>
                            <div>今天晚上向大哥找我吃饭,讨论一下去梅庄的事...</div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a class="text-center" href="#"> <strong>查看全部消息</strong>
                            <i class="fa fa-angle-right"></i>
                    </a></li>
                </ul> <!-- /.dropdown-messages --></li>
            <!-- /.dropdown -->
            <li class="dropdown"><a class="dropdown-toggle"
                data-toggle="dropdown" href="#"> <i class="fa fa-tasks fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-tasks">
                    <li><a href="#">
                            <div>
                                <p>
                                    <strong>任务 1</strong> <span class="pull-right text-muted">完成40%</span>
                                </p>
                                <div class="progress progress-striped active">
                                    <div class="progress-bar progress-bar-success"
                                        role="progressbar" aria-valuenow="40" aria-valuemin="0"
                                        aria-valuemax="100" style="width: 40%">
                                        <span class="sr-only">完成40%</span>
                                    </div>
                                </div>
                            </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                            <div>
                                <p>
                                    <strong>任务 2</strong> <span class="pull-right text-muted">完成20%</span>
                                </p>
                                <div class="progress progress-striped active">
                                    <div class="progress-bar progress-bar-info" role="progressbar"
                                        aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
                                        style="width: 20%">
                                        <span class="sr-only">完成20%</span>
                                    </div>
                                </div>
                            </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a class="text-center" href="#"> <strong>查看所有任务</strong>
                            <i class="fa fa-angle-right"></i>
                    </a></li>
                </ul> <!-- /.dropdown-tasks --></li>
            <!-- /.dropdown -->
            <li class="dropdown"><a class="dropdown-toggle"
                data-toggle="dropdown" href="#"> <i class="fa fa-bell fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-alerts">
                    <li><a href="#">
                            <div>
                                <i class="fa fa-comment fa-fw"></i> 新回复 <span
                                    class="pull-right text-muted small">4分钟之前</span>
                            </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                            <div>
                                <i class="fa fa-envelope fa-fw"></i> 新消息 <span
                                    class="pull-right text-muted small">4分钟之前</span>
                            </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                            <div>
                                <i class="fa fa-tasks fa-fw"></i> 新任务 <span
                                    class="pull-right text-muted small">4分钟之前</span>
                            </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                            <div>
                                <i class="fa fa-upload fa-fw"></i> 服务器重启 <span
                                    class="pull-right text-muted small">4分钟之前</span>
                            </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a class="text-center" href="#"> <strong>查看所有提醒</strong>
                            <i class="fa fa-angle-right"></i>
                    </a></li>
                </ul> <!-- /.dropdown-alerts --></li>
            <!-- /.dropdown -->
            <li class="dropdown"><a class="dropdown-toggle"
                data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="#"><i class="fa fa-user fa-fw"></i> 用户设置</a></li>
                    <li><a href="#"><i class="fa fa-gear fa-fw"></i> 系统设置</a></li>
                    <li class="divider"></li>
                    <li><a href="login.html"><i class="fa fa-sign-out fa-fw"></i>
                            退出登录</a></li>
                </ul> <!-- /.dropdown-user --></li>
            <!-- /.dropdown -->
        </ul>
        <!-- /.navbar-top-links -->

        <div class="navbar-default sidebar" role="navigation">
            <div class="sidebar-nav navbar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="sidebar-search">
                        <div class="input-group custom-search-form">
                            <input type="text" class="form-control" placeholder="查询内容...">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button">
                                    <i class="fa fa-search" style="padding: 3px 0 3px 0;"></i>
                                </button>
                            </span>
                        </div> <!-- /input-group -->
                    </li>
                    <li><a href="customer.action" class="active"><i
                            class="fa fa-edit fa-fw"></i> 客户管理</a></li>
                    <li><a href="salevisit.action"><i
                            class="fa fa-dashboard fa-fw"></i> 客户拜访</a></li>
                </ul>
            </div>
            <!-- /.sidebar-collapse -->
        </div>
        <!-- /.navbar-static-side --> </nav>

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">客户管理</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="panel panel-default">
                <div class="panel-body">
                    <form class="form-inline" action="${pageContext.request.contextPath }/customer/list.action" method="post">
                        <div class="form-group">
                            <label for="customerName">客户名称</label> 
                            <input type="text" class="form-control" id="customerName" value="${custName }" name="custName">
                        </div>
                        <div class="form-group">
                            <label for="customerFrom">客户来源</label> 
                            <select    class="form-control" id="customerFrom" placeholder="客户来源" name="custSource">
                                <option value="">--请选择--</option>
                                <c:forEach items="${fromType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="custIndustry">所属行业</label> 
                            <select    class="form-control" id="custIndustry"  name="custIndustry">
                                <option value="">--请选择--</option>
                                <c:forEach items="${industryType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="custLevel">客户级别</label>
                            <select    class="form-control" id="custLevel" name="custLevel">
                                <option value="">--请选择--</option>
                                <c:forEach items="${levelType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                        <button type="submit" class="btn btn-primary">查询</button>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">客户信息列表</div>
                        <!-- /.panel-heading -->
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>客户名称</th>
                                    <th>客户来源</th>
                                    <th>客户所属行业</th>
                                    <th>客户级别</th>
                                    <th>固定电话</th>
                                    <th>手机</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${page.rows}" var="row">
                                    <tr>
                                        <td>${row.cust_id}</td>
                                        <td>${row.cust_name}</td>
                                        <td>${row.cust_source}</td>
                                        <td>${row.cust_industry}</td>
                                        <td>${row.cust_level}</td>
                                        <td>${row.cust_phone}</td>
                                        <td>${row.cust_mobile}</td>
                                        <td>
                                            <a href="#" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#customerEditDialog" onclick="editCustomer(${row.cust_id})">修改</a>
                                            <a href="#" class="btn btn-danger btn-xs" onclick="deleteCustomer(${row.cust_id})">删除</a>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                        <div class="col-md-12 text-right">
                            <itheima:page url="${pageContext.request.contextPath }/customer/list.action" />
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- 客户编辑对话框 -->
    <div class="modal fade" id="customerEditDialog" tabindex="-1" role="dialog"
        aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">修改客户信息</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" id="edit_customer_form">
                        <input type="hidden" id="edit_cust_id" name="cust_id"/>
                        <div class="form-group">
                            <label for="edit_customerName" class="col-sm-2 control-label">客户名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="edit_customerName" placeholder="客户名称" name="cust_name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_customerFrom" style="float:left;padding:7px 15px 0 27px;">客户来源</label> 
                            <div class="col-sm-10">
                                <select    class="form-control" id="edit_customerFrom" placeholder="客户来源" name="cust_source">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${fromType}" var="item">
                                        <option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_custIndustry" style="float:left;padding:7px 15px 0 27px;">所属行业</label>
                            <div class="col-sm-10"> 
                                <select    class="form-control" id="edit_custIndustry"  name="cust_industry">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${industryType}" var="item">
                                        <option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_custLevel" style="float:left;padding:7px 15px 0 27px;">客户级别</label>
                            <div class="col-sm-10">
                                <select    class="form-control" id="edit_custLevel" name="cust_level">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${levelType}" var="item">
                                        <option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_linkMan" class="col-sm-2 control-label">联系人</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="edit_linkMan" placeholder="联系人" name="cust_linkman">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_phone" class="col-sm-2 control-label">固定电话</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="edit_phone" placeholder="固定电话" name="cust_phone">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_mobile" class="col-sm-2 control-label">移动电话</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="edit_mobile" placeholder="移动电话" name="cust_mobile">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_zipcode" class="col-sm-2 control-label">邮政编码</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="edit_zipcode" placeholder="邮政编码" name="cust_zipcode">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit_address" class="col-sm-2 control-label">联系地址</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="edit_address" placeholder="联系地址" name="cust_address">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="updateCustomer()">保存修改</button>
                </div>
            </div>
        </div>
    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="<%=basePath%>js/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="<%=basePath%>js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="<%=basePath%>js/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    <script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
    <script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="<%=basePath%>js/sb-admin-2.js"></script>
    
    <script type="text/javascript">
        function editCustomer(id) {
            $.ajax({
                type:"get",
                url:"<%=basePath%>customer/edit.action",
                data:{"id":id},
                success:function(data) {  
                    $("#edit_cust_id").val(data.cust_id);
                    $("#edit_customerName").val(data.cust_name);
                    $("#edit_customerFrom").val(data.cust_source)
                    $("#edit_custIndustry").val(data.cust_industry)
                    $("#edit_custLevel").val(data.cust_level)
                    $("#edit_linkMan").val(data.cust_linkman);
                    $("#edit_phone").val(data.cust_phone);
                    $("#edit_mobile").val(data.cust_mobile);
                    $("#edit_zipcode").val(data.cust_zipcode);
                    $("#edit_address").val(data.cust_address);
                    
                }
            });
        }
        function updateCustomer() {
            $.post("<%=basePath%>customer/update.action",$("#edit_customer_form").serialize(),function(data){
                alert("客户信息更新成功!");
                window.location.reload();
            });
        }
        
        function deleteCustomer(id) {
            if(confirm(确实要删除该客户吗?)) {
                $.post("<%=basePath%>customer/delete.action",{"id":id},function(data){
                    alert("客户删除更新成功!");
                    window.location.reload();
                });
            }
        }
    </script>

</body>

</html>

 

4.2. 页面显示问题

访问页面,发现不能正常显示

 技术分享

 

打开开发者工具,选择Network,

发现css、js等资源文件无法加载

 技术分享

 

 

原因:web.xml配置时,是设置所有的请求都进入SpringMVC。但是SpringMVC      无法处理css、js等静态资源,所以无法正常显示

 

解决方案:

1. 在springmvc.xml中配置

 

1 <!-- 解决静态资源无法被springMVC处理的问题 -->
2     <mvc:default-servlet-handler />

 

 

2. 修改web.xml,让所有以action结尾的请求都进入SpringMVC

 

1 <servlet-mapping>
2         <servlet-name>boot-crm</servlet-name>
3         <!-- 所有的请求都进入springMVC -->
4         <url-pattern>*.action</url-pattern>
5     </servlet-mapping>

 

 

解决后的效果如下图,可以正常显示页面样式:

 技术分享

 

 

我们使用第二种方式解决,因为此项目中的页面的请求都是以action结尾的,所以使用第二种方式,在web.xml里面进行相应的配置

   

1 <servlet-mapping>
2         <servlet-name>boot-crm</servlet-name>
3         <!-- 所有以action结尾的请求都进入springMVC -->
4         <url-pattern>*.action</url-pattern>
5     </servlet-mapping>

 

 

5.   实现查询条件初始化

5.1. 需求分析

 

页面效果如上图,在查询客户的时候,可以选择客户来源,所属行业,客户级别信息,页面加载时需要初始化查询条件下拉列表。

 技术分享

 

前端jsp逻辑

 1 <form class="form-inline" action="${pageContext.request.contextPath }/customer/list.action" method="get">
 2     <div class="form-group">
 3         <label for="customerName">客户名称</label> 
 4         <input type="text" class="form-control" id="customerName" value="${custName }" name="custName">
 5     </div>
 6     <div class="form-group">
 7         <label for="customerFrom">客户来源</label> 
 8         <select    class="form-control" id="customerFrom" placeholder="客户来源" name="custSource">
 9             <option value="">--请选择--</option>
10             <c:forEach items="${fromType}" var="item">
11                 <option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
12             </c:forEach>
13         </select>
14     </div>
15     <div class="form-group">
16         <label for="custIndustry">所属行业</label> 
17         <select    class="form-control" id="custIndustry"  name="custIndustry">
18             <option value="">--请选择--</option>
19             <c:forEach items="${industryType}" var="item">
20                 <option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
21             </c:forEach>
22         </select>
23     </div>
24     <div class="form-group">
25         <label for="custLevel">客户级别</label>
26         <select    class="form-control" id="custLevel" name="custLevel">
27             <option value="">--请选择--</option>
28             <c:forEach items="${levelType}" var="item">
29                 <option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
30             </c:forEach>
31         </select>
32     </div>
33     <button type="submit" class="btn btn-primary">查询</button>
34 </form>

 

 

按照jsp的要求,把对应的数据查询出来,放到模型中。

数据存放在base_dict表,可以使用dict_type_code类别代码进行查询

使用需要获取的数据如下图:

 技术分享

 

 

使用的sql:

SELECT * FROM base_dict WHERE dict_type_code = ‘001‘

 

5.2. 实现DAO开发

5.2.1. pojo

因为页面显示的名字是下划线方式,和数据库表列名一样,根据页面的样式,编写pojo

 1 public class BaseDict {
 2     private String dict_id;
 3     private String dict_type_code;
 4     private String dict_type_name;
 5     private String dict_item_name;
 6     private String dict_item_code;
 7     private Integer dict_sort;
 8     private String dict_enable;
 9     private String dict_memo;
10 get/set方法自己实现
11 }

 

 

 

5.2.2. Mapper

编写BaseDictMapper

 1 public interface BaseDictMapper {
 2     /**
 3      * 根据类别代码查询数据
 4      * 
 5      * @param dictTypeCode
 6      * @return
 7      */
 8     List<BaseDict> queryBaseDictByDictTypeCode(String dictTypeCode);
 9     
10 }

 

 

 

5.2.3. Mapper.xml

编写BaseDictMapper.xml

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 <mapper namespace="cn.itcast.crm.mapper.BaseDictMapper">
 6 
 7     <!-- 根据类别代码查询数据 -->
 8     <select id="queryBaseDictByDictTypeCode" parameterType="String"
 9         resultType="cn.itcast.crm.pojo.BaseDict">
10         SELECT * FROM base_dict WHERE dict_type_code =
11         #{dict_type_code}
12     </select>
13 
14 </mapper>

 

 

5.3. 实现Service开发

5.3.1. BaseDictService 接口

 1 public interface BaseDictService {
 2 
 3     /**
 4      * 根据类别代码查询
 5      * 
 6      * @param dictTypeCode
 7      * @return
 8      */
 9     List<BaseDict> queryBaseDictByDictTypeCode(String dictTypeCode);
10 }

 

 

 

5.3.2. BaseDictServiceImpl 实现类

 1 @Service
 2 public class BaseDictServiceImpl implements BaseDictService {
 3 
 4     @Autowired
 5     private BaseDictMapper baseDictMapper;
 6 
 7     @Override
 8     public List<BaseDict> queryBaseDictByDictTypeCode(String dictTypeCode) {
 9 
10         List<BaseDict> list = this.baseDictMapper.queryBaseDictByDictTypeCode(dictTypeCode);
11         return list;
12     }
13 }

 

 

 

5.4. 实现Controller开发

5.4.1. 修改之前编写的controller

 1 @Controller
 2 @RequestMapping("customer")
 3 public class CustomerController {
 4 
 5     @Autowired
 6     private BaseDictService baseDictService;
 7 
 8     /**
 9      * 显示客户列表
10      * 
11      * @return
12      */
13     @RequestMapping("list")
14     public String queryCustomerList(Model model) {
15         // 客户来源
16         List<BaseDict> fromType = this.baseDictService.queryBaseDictByDictTypeCode("002");
17         // 所属行业
18         List<BaseDict> industryType = this.baseDictService.queryBaseDictByDictTypeCode("001");
19         // 客户级别
20         List<BaseDict> levelType = this.baseDictService.queryBaseDictByDictTypeCode("006");
21 
22         // 把前端页面需要显示的数据放到模型中
23         model.addAttribute("fromType", fromType);
24         model.addAttribute("industryType", industryType);
25         model.addAttribute("levelType", levelType);
26 
27         return "customer";
28     }
29 }

 

 

5.4.2. 效果

实现效果如下图:

 技术分享

 

5.4.3. 硬编码问题

这里是根据dict_type_code类别代码查询数据,这里的查询条件是写死的,有硬编码问题。可以把类别代码提取到配置文件中,再使用@value注解进行加载。

5.4.3.1. 添加env.properties

添加env.properties配置文件

#客户来源
CUSTOMER_FROM_TYPE=002
#客户行业
CUSTOMER_INDUSTRY_TYPE=001
#客户级别
CUSTOMER_LEVEL_TYPE=006

 

 

5.4.3.2. 修改springmvc.xml配置文件

在springmvc.xml中加载env.properties

   

1 <!-- 加载controller需要的配置信息 -->
2     <context:property-placeholder location="classpath:env.properties" />

 

 

注意:Controller需要的配置文件信息必须添加到springmvc的配置文件中

 

5.4.3.3. 修改Controller方法

 1 @Controller
 2 @RequestMapping("customer")
 3 public class CustomerController {
 4 
 5     // 客户来源
 6     @Value("${CUSTOMER_FROM_TYPE}")
 7     private String CUSTOMER_FROM_TYPE;
 8     // 客户行业
 9     @Value("${CUSTOMER_INDUSTRY_TYPE}")
10     private String CUSTOMER_INDUSTRY_TYPE;
11     // 客户级别
12     @Value("${CUSTOMER_LEVEL_TYPE}")
13     private String CUSTOMER_LEVEL_TYPE;
14 
15     @Autowired
16     private BaseDictService baseDictService;
17 
18     /**
19      * 显示客户列表
20      * 
21      * @return
22      */
23     @RequestMapping("list")
24     public String queryCustomerList(Model model) {
25         // 客户来源
26         List<BaseDict> fromType = this.baseDictService.queryBaseDictByDictTypeCode(this.CUSTOMER_FROM_TYPE);
27         // 所属行业
28         List<BaseDict> industryType = this.baseDictService.queryBaseDictByDictTypeCode(this.CUSTOMER_INDUSTRY_TYPE);
29         // 客户级别
30         List<BaseDict> levelType = this.baseDictService.queryBaseDictByDictTypeCode(this.CUSTOMER_LEVEL_TYPE);
31 
32         // 把前端页面需要显示的数据放到模型中
33         model.addAttribute("fromType", fromType);
34         model.addAttribute("industryType", industryType);
35         model.addAttribute("levelType", levelType);
36 
37         return "customer";
38     }
39 
40 }

 

6.   客户列表展示

6.1. 需求

展示客户列表,并且可以根据查询条件过滤查询结果,并且实现分页。

效果如下图:

 技术分享

 

 

页面代码:

 1 <div class="panel-heading">客户信息列表</div>
 2 <!-- /.panel-heading -->
 3 <table class="table table-bordered table-striped">
 4     <thead>
 5         <tr>
 6             <th>ID</th>
 7             <th>客户名称</th>
 8             <th>客户来源</th>
 9             <th>客户所属行业</th>
10             <th>客户级别</th>
11             <th>固定电话</th>
12             <th>手机</th>
13             <th>操作</th>
14         </tr>
15     </thead>
16     <tbody>
17         <c:forEach items="${page.rows}" var="row">
18             <tr>
19                 <td>${row.cust_id}</td>
20                 <td>${row.cust_name}</td>
21                 <td>${row.cust_source}</td>
22                 <td>${row.cust_industry}</td>
23                 <td>${row.cust_level}</td>
24                 <td>${row.cust_phone}</td>
25                 <td>${row.cust_mobile}</td>
26                 <td>
27                     <a href="#" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#customerEditDialog" onclick="editCustomer(${row.cust_id})">修改</a>
28                     <a href="#" class="btn btn-danger btn-xs" onclick="deleteCustomer(${row.cust_id})">删除</a>
29                 </td>
30             </tr>
31         </c:forEach>
32     </tbody>
33 </table>

 

 

分析我们需要根据四个条件进行查询,返回数据是分页对象Page

 

Sql语句:

 1 SELECT
 2     a.cust_id,
 3     a.cust_name,
 4     a.cust_user_id,
 5     a.cust_create_id,
 6     b.dict_item_name cust_source,
 7     c.dict_item_name cust_industry,
 8     d.dict_item_name cust_level,
 9     a.cust_linkman,
10     a.cust_phone,
11     a.cust_mobile,
12     a.cust_zipcode,
13     a.cust_address,
14     a.cust_createtime
15 FROM
16     customer a
17 LEFT JOIN base_dict b ON a.cust_source = b.dict_id
18 LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
19 LEFT JOIN base_dict d ON a.cust_level = d.dict_id
20 WHERE
21     a.cust_name LIKE %马%
22 AND a.cust_source = 6
23 AND a.cust_industry = 2
24 AND a.cust_level = 22
25 LIMIT 0, 10

 

 

6.2. 创建pojo开发

public class Customer {

    private Long cust_id;
    private String cust_name;
    private Long cust_user_id;
    private Long cust_create_id;
    private String cust_source;
    private String cust_industry;
    private String cust_level;
    private String cust_linkman;
    private String cust_phone;
    private String cust_mobile;
    private String cust_zipcode;
    private String cust_address;
    private Date cust_createtime;
get/set。。。。。。
}

 

 

 

 

6.3. 实现DAO

分析:

1. 前台发起请求,需要接收请求过来的查询条件数据,可以使用pojo接收数据。需要依此编写查询逻辑。

2. 前台需要分页显示,根据准备好的分页实现,应该返回分页类Page,而创建Page分页类需要数据总条数,所以也需要查询数据总条数的逻辑。

 

根据分析,DAO需要编写两个方法:

1. 需要根据条件分页查询客户信息

2. 需要根据条件查询数据总条数

 

6.3.1. 创建QueryVo

需要编写QueryVo,里面包含查询条件属性和分页数据。

创建接受请求参数的QueryVo:

public class QueryVo {

    private String custName;
    private String custSource;
    private String custIndustry;
    private String custLevel;

    // 当前页码数
    private Integer page = 1;
    // 数据库从哪一条数据开始查
    private Integer start;
    // 每页显示数据条数
    private Integer rows = 10;
get/set。。。。。。
}

 

 

 

6.3.2. Mapper

创建CustomerMapper 接口

public interface CustomerMapper {

    /**
     * 根据queryVo分页查询数据
     * 
     * @param queryVo
     * @return
     */
    List<Customer> queryCustomerByQueryVo(QueryVo queryVo);

    /**
     * 根据queryVo查询数据条数
     * 
     * @param queryVo
     * @return
     */
    int queryCountByQueryVo(QueryVo queryVo);

}

 

 

6.3.3. Mapper.xml

创建CustomerMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.itcast.crm.mapper.CustomerMapper">
    <sql id="customerQueryVo">
        <where>
            <if test="custName != null and custName != ‘‘">
                AND a.cust_name LIKE ‘%${custName}%‘
            </if>
            <if test="custSource != null and custSource != ‘‘">
                AND a.cust_source = #{custSource}
            </if>
            <if test="custIndustry != null and custIndustry != ‘‘">
                AND a.cust_industry = #{custIndustry}
            </if>
            <if test="custLevel != null and custLevel != ‘‘">
                AND a.cust_level = #{custLevel}
            </if>
        </where>
    </sql>

    <!-- 根据queryVo分页查询数据 -->
    <select id="queryCustomerByQueryVo" parameterType="cn.itcast.crm.pojo.QueryVo"
        resultType="cn.itcast.crm.pojo.Customer">
      SELECT
        a.cust_id,
        a.cust_name,
        a.cust_user_id,
        a.cust_create_id,
        b.dict_item_name cust_source,
        c.dict_item_name cust_industry,
        d.dict_item_name cust_level,
        a.cust_linkman,
        a.cust_phone,
        a.cust_mobile,
        a.cust_zipcode,
        a.cust_address,
        a.cust_createtime
      FROM
        customer a
        LEFT JOIN base_dict b ON a.cust_source = b.dict_id
        LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
        LEFT JOIN base_dict d ON a.cust_level = d.dict_id
        <include refid="customerQueryVo" />
        <if test="start != null">
            LIMIT #{start}, #{rows}
        </if>
    </select>

    <!-- 根据queryVo查询数据条数 -->
    <select id="queryCountByQueryVo" parameterType="cn.itcast.crm.pojo.QueryVo"
        resultType="int">
        SELECT count(1) FROM customer a
        <include refid="customerQueryVo" />
    </select>
</mapper>

 

6.4. 实现service

6.4.1. 接口

编写接口CustomerService

public interface CustomerService {
    /**
     * 根据条件分页查询客户
     * 
     * @param queryVo
     * @return
     */
    Page<Customer> queryCustomerByQueryVo(QueryVo queryVo);
}

 

 

6.4.2. 实现类

编写接口实现类CustomerServiceImpl

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public Page<Customer> queryCustomerByQueryVo(QueryVo queryVo) {
        // 设置查询条件,从哪一条数据开始查
        queryVo.setStart((queryVo.getPage() - 1) * queryVo.getRows());

        // 查询数据结果集
        List<Customer> list = this.customerMapper.queryCustomerByQueryVo(queryVo);
        // 查询到的数据总条数
        int total = this.customerMapper.queryCountByQueryVo(queryVo);

        // 封装返回的page对象
        Page<Customer> page = new Page<>(total, queryVo.getPage(), queryVo.getRows(), list);

        return page;
    }
}

 

 

6.5. 实现Controller

改造Controller的方法

@RequestMapping("list")
public String queryCustomerList(QueryVo queryVo, Model model) {

    try {
        // 解决get请求乱码问题
        if (StringUtils.isNotBlank(queryVo.getCustName())) {
            queryVo.setCustName(new String(queryVo.getCustName().getBytes("ISO-8859-1"), "UTF-8"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // 客户来源
    List<BaseDict> fromType = this.baseDictService.queryBaseDictByDictTypeCode(this.CUSTOMER_FROM_TYPE);
    // 所属行业
    List<BaseDict> industryType = this.baseDictService.queryBaseDictByDictTypeCode(this.CUSTOMER_INDUSTRY_TYPE);
    // 客户级别
    List<BaseDict> levelType = this.baseDictService.queryBaseDictByDictTypeCode(this.CUSTOMER_LEVEL_TYPE);

    // 把前端页面需要显示的数据放到模型中
    model.addAttribute("fromType", fromType);
    model.addAttribute("industryType", industryType);
    model.addAttribute("levelType", levelType);

    // 分页查询数据
    Page<Customer> page = this.customerService.queryCustomerByQueryVo(queryVo);
    // 把分页查询的结果放到模型中
    model.addAttribute("page", page);

    // 数据回显
    model.addAttribute("custName", queryVo.getCustName());
    model.addAttribute("custSource", queryVo.getCustSource());
    model.addAttribute("custIndustry", queryVo.getCustIndustry());
    model.addAttribute("custLevel", queryVo.getCustLevel());

    return "customer";
}

 

 

7.   修改客户信息

7.1. 需求

页面效果如下图:

 技术分享

 

1、客户列表中点击“修改”按钮弹出客户信息修改窗,并初始化客户信息

2、点击“保存修改”按钮将修改后的结果保存到数据库中

 

 

 

 

7.2. 实现编辑数据回显

在客户列表显示中,可以点击修改按钮,弹出修改界面,打开浏览器的开发者工具,发现当点击修改按钮,会发起一个请求

如下图方式进行查看

 技术分享

 

 

分析这里应该是发起请求到后台,获取该用户的详细信息,在页面上可以回显

 

复制请求路径中的edit.action,在customer.jsp页面中搜索,找到请求逻辑

找到的代码如下图:

 技术分享

 

发现这里是一个Ajax请求,根据这个请求我们可以开发后台逻辑,提供给前端页面进行调用

 

7.3. 回显功能实现

7.3.1. Mapper接口

在CustomerMapper添加方法

/**
 * 根据id查询客户
 * 
 * @param id
 * @return
 */
Customer queryCustomerById(Long id);

 

 

7.3.2. Mapper.xml

在CustomerMapper.xml编写sql

<!-- 根据id查询用户 -->
<select id="queryCustomerById" resultType="cn.itcast.crm.pojo.Customer">
    SELECT * FROM customer WHERE cust_id = #{id}
</select>

 

 

7.3.3. Service接口

编写CustomerService.接口方法

/**
 * 根据id查询数据
 * 
 * @param id
 * @return
 */
Customer queryCustomerById(Long id);

 

 

7.3.4. Service接口实现类

在CustomerServiceImpl实现接口方法

@Override
public Customer queryCustomerById(Long id) {
    Customer customer = this.customerMapper.queryCustomerById(id);
    return customer;
}

 

7.3.5. Controller

在CustomerController编写方法

/**
 * 根据id查询用户,返回json格式数据
 * 
 * @param id
 * @return
 */
@RequestMapping("edit")
@ResponseBody
public Customer queryCustomerById(Long id) {
    Customer customer = this.customerService.queryCustomerById(id);
    return customer;
}

 

 

7.4. 实现编辑客户数据

在编辑框,点击保存修改按钮,应该进行数据保存,如下图所示:

 

 技术分享

 

发起请求如下图:

 技术分享

 

 

在页面找到的请求逻辑是:

function updateCustomer() {
    $.post("<%=basePath%>customer/update.action",$("#edit_customer_form").serialize(),function(data){
        alert("客户信息更新成功!");
        window.location.reload();
    });
}

 

 

 

7.5. 编辑功能实现

7.5.1. Mapper接口

在CustomerMapper添加方法

/**
 * 根据id编辑客户
 * 
 * @param customer
 */
void updateCustomerById(Customer customer);

 

 

7.5.2. Mapper.xml

在CustomerMapper.xml编写sql

<select id="updateCustomerById" parameterType="cn.itcast.crm.pojo.Customer">
    UPDATE `customer`
    SET
    <if test="cust_name !=null and cust_name != ‘‘">
        `cust_name` = #{cust_name},
    </if>
    <if test="cust_user_id !=null">
        `cust_user_id` = #{cust_user_id},
    </if>
    <if test="cust_create_id !=null">
        `cust_create_id` = #{cust_create_id},
    </if>
    <if test="cust_source !=null and cust_source != ‘‘">
        `cust_source` = #{cust_source},
    </if>
    <if test="cust_industry !=null and cust_industry != ‘‘">
        `cust_industry` = #{cust_industry},
    </if>
    <if test="cust_level !=null and cust_level != ‘‘">
        `cust_level` = #{cust_level},
    </if>
    <if test="cust_linkman !=null and cust_linkman != ‘‘">
        `cust_linkman` = #{cust_linkman},
    </if>
    <if test="cust_phone !=null and cust_phone != ‘‘">
        `cust_phone` = #{cust_phone},
    </if>
    <if test="cust_mobile !=null and cust_mobile != ‘‘">
        `cust_mobile` = #{cust_mobile},
    </if>
    <if test="cust_zipcode !=null and cust_zipcode != ‘‘">
        `cust_zipcode` = #{cust_zipcode},
    </if>
    <if test="cust_address !=null and cust_address != ‘‘">
        `cust_address` = #{cust_address},
    </if>
    `cust_createtime` = NOW()
    WHERE
    (`cust_id` = #{cust_id});
</select>

 

7.5.3. Service接口

编写CustomerService.接口方法

/**

 * 根据id编辑客户数据

 *

 * @param customer

 */

void updateCustomerById(Customer customer);

 

7.5.4. Service接口实现类

在CustomerServiceImpl实现接口方法

@Override
public void updateCustomerById(Customer customer) {
    this.customerMapper.updateCustomerById(customer);
}

 

 

7.5.5. Controller

在CustomerController编写方法

需要正确的响应,要告诉前端更新成功。返回值有没有都可以。

这里需要加@ResponseBody注解,使其不走视图解析器。

/**
 * 根据id查询用户,返回更新后客户的json格式数据
 * 
 * @param id
 * @return
 */
@RequestMapping("update")
@ResponseBody
public String updateCustomerById(Customer customer) {
    Customer result = this.customerService.updateCustomerById(customer);
    return "OK";
}

 

 

8.   删除客户

8.1. 需求分析

点击客户列表中的删除按钮,提示“警告信息”,如下图

 技术分享

 

 

如下图,点击确定后删除用户信息,并刷新页面。

 

 技术分享

 

 

发起的请求如下图:

 技术分享

 

 

搜索前端jsp页面逻辑找到如下代码:

function deleteCustomer(id) {
    if(confirm(‘确实要删除该客户吗?‘)) {
        $.post("<%=basePath%>customer/delete.action",{"id":id},function(data){
            alert("客户删除更新成功!");
            window.location.reload();
        });
    }
}

 

 

 

8.2. 功能开发

8.2.1. Mapper接口

在CustomerMapper添加方法

/**
 * 根据id删除用户
 * 
 * @param id
 */
void deleteCustomerById(Long id);

 

 

8.2.2. Mapper.xml

在CustomerMapper.xml编写sql

<!-- 根据id删除客户 -->
<delete id="deleteCustomerById" parameterType="long">
    DELETE FROM
    customer WHERE cust_id = #{id}
</delete>

 

8.2.3. Service接口

在CustomerService编写接口方法

/**
 * 根据id删除客户
 * 
 * @param id
 */
void deleteCustomerById(Long id);

 

 

8.2.4. Service实现类

在CustomerServiceImpl实现接口方法

@Override
public void deleteCustomerById(Long id) {
    this.customerMapper.deleteCustomerById(id);
}

 

 

8.2.5. Controller

在CustomerController编写方法

/**
 * 删除用户
 * 
 * @param id
 * @return
 */
@RequestMapping("delete")
@ResponseBody
public String deleteCustomerById(Long id) {
    this.customerService.deleteCustomerById(id);
    return "ok";
}

 

SSM框架整合,以CRM为例子

标签:www   编辑功能   ntb   icon   path   ast   bind   next   attr   

原文地址:http://www.cnblogs.com/huangjuncong/p/7225176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!