SSM框架实现简单门店管理系统

一、创建数据库

/*Navicat Premium Data TransferSource Server         : MySQLSource Server Type    : MySQLSource Server Version : 50743Source Host           : localhost:3306Source Schema         : yongheTarget Server Type    : MySQLTarget Server Version : 50743File Encoding         : 65001Date: 14/02/2024 15:16:09
*/SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for tb_cashier
-- ----------------------------
DROP TABLE IF EXISTS `tb_cashier`;
CREATE TABLE `tb_cashier`  (`id` int(11) NOT NULL AUTO_INCREMENT,`cname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`gender` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`age` int(11) DEFAULT NULL,`telephone` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`work_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`door_id` int(11) DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of tb_cashier
-- ----------------------------
INSERT INTO `tb_cashier` VALUES (1, '张鱼与', '男', 24, '13827364723', '8:00-18:00', 1);
INSERT INTO `tb_cashier` VALUES (2, '李四', '男', 25, '18732364732', '8:00-18:00', 2);
INSERT INTO `tb_cashier` VALUES (3, '王五', '男', 30, '13764738273', '8:00-18:00', 3);
INSERT INTO `tb_cashier` VALUES (4, '赵六', '男', 28, '16273647231', '8:00-18:00', 4);
INSERT INTO `tb_cashier` VALUES (5, '周七', '女', 22, '13748548319', '8:00-18:00', 5);
INSERT INTO `tb_cashier` VALUES (6, '周红', '女', 22, '16937200932', '8:00-18:00', 6);
INSERT INTO `tb_cashier` VALUES (7, '冯鱼鱼', '女', 27, '17623609212', '8:00-18:00', 7);
INSERT INTO `tb_cashier` VALUES (8, '王小花', '女', 21, '18723642909', '8:00-18:00', 8);
INSERT INTO `tb_cashier` VALUES (9, '张小草', '男', 37, '17823762109', '8:00-18:00', 9);
INSERT INTO `tb_cashier` VALUES (10, '陈虎', '男', 32, '16723647109', '8:00-18:00', 10);
INSERT INTO `tb_cashier` VALUES (11, '刘雨燕', '女', 30, '13872378472', '8:00-18:00', 11);-- ----------------------------
-- Table structure for tb_category
-- ----------------------------
DROP TABLE IF EXISTS `tb_category`;
CREATE TABLE `tb_category`  (`id` int(11) NOT NULL AUTO_INCREMENT,`category` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of tb_category
-- ----------------------------
INSERT INTO `tb_category` VALUES (1, '主菜');
INSERT INTO `tb_category` VALUES (2, '前菜');
INSERT INTO `tb_category` VALUES (3, '甜品');
INSERT INTO `tb_category` VALUES (4, '饮料');
INSERT INTO `tb_category` VALUES (5, '主食');-- ----------------------------
-- Table structure for tb_door
-- ----------------------------
DROP TABLE IF EXISTS `tb_door`;
CREATE TABLE `tb_door`  (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`tel` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`addr` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of tb_door
-- ----------------------------
INSERT INTO `tb_door` VALUES (1, '永和大王(北三环西路店)', '010-62112313', '北三环西路甲18号院-1号大钟寺中坤广场d座');
INSERT INTO `tb_door` VALUES (2, '永和大王(知春路店)', '010-82356537', '知春路29号大运金都');
INSERT INTO `tb_door` VALUES (3, '永和大王(东直门)', '010-84477746', '东直门外大街48号东方银座b2-08');
INSERT INTO `tb_door` VALUES (4, '永和大王(北京站)', '010-65286602', '毛家湾胡同甲13号北京站候车大厅2层');
INSERT INTO `tb_door` VALUES (5, '永和大王(西直门)', '010-62152539', '西直门地铁站C口');
INSERT INTO `tb_door` VALUES (6, '永和大王(王府井)', '010-62152539', '王府井小吃街');
INSERT INTO `tb_door` VALUES (7, '永和大王(四道口)', '010-62152539', '学院南路37号超市发四道口店四道口西北角');
INSERT INTO `tb_door` VALUES (8, '永和大王(灯市口)', '010-62152539', '灯市口地铁站A口');
INSERT INTO `tb_door` VALUES (9, '永和大王(北大)', '010-62152539', '北京大学西门');
INSERT INTO `tb_door` VALUES (10, '永和大王(苏州街)', '010-62152539', '苏州街地铁站B口');
INSERT INTO `tb_door` VALUES (11, '永和大王(莲池区店)', '010-05151533', '莲池路123号');-- ----------------------------
-- Table structure for tb_menu
-- ----------------------------
DROP TABLE IF EXISTS `tb_menu`;
CREATE TABLE `tb_menu`  (`id` int(11) NOT NULL AUTO_INCREMENT,`dish_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`dish_price` double(10, 2) DEFAULT NULL,`discription` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`img` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,`category_id` int(11) DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of tb_menu
-- ----------------------------
INSERT INTO `tb_menu` VALUES (1, '红烧肉', 56.00, '红烧肉属于中华传统名菜之一,以五花肉为主料,加入糖色、酱油等调料慢炖而成,口感软糯、肥而不腻。', 'uploads/C76E68E0B50245B390398F4B15B4AC80_lunbo4.jpg', 1);
INSERT INTO `tb_menu` VALUES (2, '鱼香肉丝', 48.00, '川菜中的代表性菜品之一,由猪里脊肉丝、木耳、胡萝卜等蔬菜烹制而成,味道酸甜辣香四味俱全,鱼香味浓郁但并不含鱼。', 'uploads/83A06A42A00A4346BEF1AE6EB7E4AE4A_`Y4N_UNJMLFCHX_GA94KMKL.png', 1);
INSERT INTO `tb_menu` VALUES (3, '清蒸鲈鱼', 55.00, '一道清淡而鲜美的菜肴,选用新鲜的鲈鱼清蒸而成,肉质细嫩、口感爽滑,搭配葱姜蒜提味,营养丰富。', 'uploads/53E02DD07511401A877E97494E82E24D_MN]PP$5}TPP5O$_`_6TENQT.png', 1);
INSERT INTO `tb_menu` VALUES (4, '麻婆豆腐', 30.00, '四川传统名菜之一,以豆腐为主料,搭配豆瓣酱、花椒等调料炒制而成,口感麻辣鲜香,色泽红亮诱人。', 'uploads/E88EBC3F47F24858B31E2DA7E7B663F6_C1@6DISF]Q83XIOP4)@JY0Y.png', 1);
INSERT INTO `tb_menu` VALUES (5, '米饭', 2.00, '大米饭单人份', 'uploads/221755AA32E74452A867BAB03F789CD5_~C)@@08}F1BZ{H~MQ]U5H7V.png', 5);
INSERT INTO `tb_menu` VALUES (6, '酸梅汁', 5.00, '80ml一份', 'uploads/54F0218F4B8444DA9C5AC92E8F70C965_C1@6DISF]Q83XIOP4)@JY0Y.png', 4);
INSERT INTO `tb_menu` VALUES (7, '橙汁', 6.00, '85ml一份', 'uploads/AC6953C939724D71B21CCE09CDAF46A7__@780W8Z4}GT8K`}BNI]93V.png', 4);
INSERT INTO `tb_menu` VALUES (8, '凉拌海蜇', 18.00, '这是一道清爽的凉菜,以海蜇皮为主料,搭配醋、蒜泥、芝麻等调料凉拌而成。口感爽滑,味道酸辣可口,是夏季消暑的佳品。', 'uploads/9E4DDB3CB5A3463C8E4EAEDF7884B3E3__@780W8Z4}GT8K`}BNI]93V.png', 2);
INSERT INTO `tb_menu` VALUES (9, '拍黄瓜', 18.00, '简单的家常菜,以黄瓜为主料,用刀拍松后加入蒜泥、醋、香油等调料拌匀而成。口感清脆爽口,味道清新宜人,是夏季常见的开胃小菜。', 'uploads/E9D785930EE8417FA90CD445A5E4B526_MN]PP$5}TPP5O$_`_6TENQT.png', 2);
INSERT INTO `tb_menu` VALUES (10, '泡菜', 10.00, '在韩餐或一些中式餐厅中,泡菜也是常见的前菜之一。泡菜以蔬菜为主料,经过腌制发酵而成,口感酸辣可口,有助于增进食欲。', 'uploads/005F76B33ACF47CC9719F81E3523DEEA__@780W8Z4}GT8K`}BNI]93V.png', 2);
INSERT INTO `tb_menu` VALUES (11, '法式焦糖布丁', 15.00, '这是一款法国传统甜品,也被称为“焦糖蛋糕”。它的外层覆盖着一层焦糖,酥脆的外壳与布丁的细腻口感形成完美对比,让人上瘾。', 'uploads/CD2CE06F6F5541AAA5C38CA6188BBF1D_MN]PP$5}TPP5O$_`_6TENQT.png', 3);
INSERT INTO `tb_menu` VALUES (12, '奶油泡芙', 12.00, '泡芙皮酥脆,内馅奶油丰富,口感轻盈不腻人,无论是孩子还是甜品爱好者都非常喜欢。', 'uploads/F1CB70F15DD4449CAFF6FF089EFE0437_C1@6DISF]Q83XIOP4)@JY0Y.png', 3);
INSERT INTO `tb_menu` VALUES (18, '当归蛋', 190.00, '拉拉', 'uploads/E6E1911DBA614912BA8DAFEC0DA7A412_lunbo1.jpg', 1);-- ----------------------------
-- Table structure for tb_order
-- ----------------------------
DROP TABLE IF EXISTS `tb_order`;
CREATE TABLE `tb_order`  (`id` int(11) NOT NULL AUTO_INCREMENT,`door_id` int(11) DEFAULT NULL,`order_no` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`order_type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`pnum` int(11) DEFAULT NULL,`cashier_id` int(11) DEFAULT NULL,`order_time` datetime(0) DEFAULT NULL,`pay_time` datetime(0) DEFAULT NULL,`pay_type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`price` double DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE,INDEX `door_id`(`door_id`) USING BTREE,CONSTRAINT `tb_order_ibfk_1` FOREIGN KEY (`door_id`) REFERENCES `tb_door` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of tb_order
-- ----------------------------
INSERT INTO `tb_order` VALUES (1, 1, 'P001', '堂食', 1, 11, '2018-04-26 14:49:07', '2018-04-26 14:50:38', '微支付', 16);
INSERT INTO `tb_order` VALUES (2, 1, 'P003', '外卖', 3, 1, '2018-04-27 13:34:07', '2018-04-27 13:34:38', '现金', 60);
INSERT INTO `tb_order` VALUES (3, 2, 'P005', '打包', 1, 2, '2019-01-22 11:59:22', '2019-01-22 11:59:22', '微支付', 28);
INSERT INTO `tb_order` VALUES (4, 2, 'P007', '堂食', 4, 3, '2019-01-23 13:01:26', '2019-01-23 13:01:26', '现金', 149);
INSERT INTO `tb_order` VALUES (6, 3, 'P008', '堂食', 2, 4, '2020-05-23 13:01:26', '2019-01-23 13:01:26', '支付宝', 56);
INSERT INTO `tb_order` VALUES (7, 4, 'P005', '打包', 1, 5, '2020-05-22 16:56:22', '2019-01-22 11:59:22', '支付宝', 28);
INSERT INTO `tb_order` VALUES (8, 5, 'P007', '堂食', 2, 6, '2020-07-23 16:09:26', '2019-01-23 13:01:26', '现金', 59);
INSERT INTO `tb_order` VALUES (9, 5, 'P007', '食堂', 2, 10, '2020-07-23 17:01:26', '2019-01-23 13:01:26', '微支付', 48);
INSERT INTO `tb_order` VALUES (10, 6, 'P007', '外卖', 2, 8, '2020-09-23 17:06:26', '2019-01-23 13:01:26', '现金', 33);
INSERT INTO `tb_order` VALUES (11, 7, 'P007', '堂食', 2, 9, '2020-09-23 17:06:26', '2019-01-23 13:01:26', '现金', 89);
INSERT INTO `tb_order` VALUES (14, 1, 'P004', '堂食', 1, 10, '2019-01-23 13:01:26', '2019-01-23 13:01:26', '支付宝', 112);SET FOREIGN_KEY_CHECKS = 1;

二、文件配置

1、创建maven java web项目,在pom.xml文件中引入相关依赖

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.qcby</groupId><artifactId>yonghe</artifactId><version>0.0.1-SNAPSHOT</version><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin></plugins></build><packaging>war</packaging><dependencies><!-- 单元测试 --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.10</version></dependency><!-- 整合log4j --><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>1.6.4</version></dependency><!-- Servlet/JSP/JSTL --><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jsp-api</artifactId><version>2.0</version><scope>provided</scope></dependency><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency><!-- 整合spring框架(包含springmvc) 这个jar文件包含springmvc开发时的核心类, 同时也会将依赖的相关jar文件引入进来(spring的核心jar文件也包含在内) --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>4.1.3.RELEASE</version></dependency><!--这个jar文件包含对Spring对JDBC数据访问进行封装的所有类 --><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>4.1.3.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId><version>4.1.3.RELEASE</version></dependency><!-- 整合mybatis框架 --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.2.8</version></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>1.2.2</version></dependency><!-- mysql驱动 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.32</version></dependency><!-- druid连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.6</version></dependency><!--文件上传--><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.3.1</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.4</version></dependency></dependencies></project>

2、配置web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"version="2.5"><display-name>day17-springmvc</display-name><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file> </welcome-file-list><!-- 配置全站500异常跳转页面 --><error-page><error-code>500</error-code><location>/WEB-INF/pages/500.jsp</location></error-page><!-- 配置全站404跳转页面 --><error-page><error-code>404</error-code><location>/WEB-INF/pages/404.jsp</location></error-page><!-- 配置springmvc的前端控制器(DispatcherServlet) ctrl+shift+T --><servlet><servlet-name>springmvc</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><!-- 配置springmvc核心配置文件的位置(contextConfigLocation是固定的名字,不能写错!) --><param-name>contextConfigLocation</param-name><param-value>classpath:spring/*.xml</param-value></init-param><!--启动加载--><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>springmvc</servlet-name><!-- 配置前端控制器拦截对当前应用下的所有资源的访问(除了JSP) --><url-pattern>/</url-pattern></servlet-mapping><!-- 配置(启用)springmvc的乱码处理过滤器,用于处理POST提交中文参数的乱码问题! --><filter><filter-name>encodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF8</param-value></init-param></filter><filter-mapping><filter-name>encodingFilter</filter-name><!-- /*表示拦截所有的请求,对所有请求都进行过滤 --><url-pattern>/*</url-pattern></filter-mapping></web-app>

3、创建spring文件夹,在spring文件夹下创建并配置applicationContext.xml和springsmv-config.xml文件

applicationContext.xml文件配置

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://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.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"><!-- 1.加载jdbc.properties文件的位置 --><context:property-placeholder location="classpath:jdbc.properties"/><!-- 2.配置druid连接池 ,id是固定值,class是druid连接池类的全路径 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><!-- 配置连接数据库的基本信息 --><property name="driverClassName" value="${db.driverClassName}"></property><property name="url" value="${db.url}"></property><property name="username" value="${db.username}"></property><property name="password" value="${db.password}"></property></bean><!-- 3.整合spring和mybatis框架	将SqlSession等对象的创建交给Spring容器id值(sqlSessionFactory)是固定值--><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 3.1.指定mybatis核心配置文件的位置 --><property name="configLocation" value="classpath:mybatis/mybatis-config.xml"></property><!-- 3.2.配置连接池(数据源) ref指向连接池bean对象的id值 --><property name="dataSource" ref="dataSource"></property><!-- 3.3、扫描所有的 XxxMapper.xml映射文件,读取其中配置的SQL语句 --><property name="mapperLocations" value="classpath:mybatis/mapper/*.xml"/></bean><!-- 4、定义mapper接口扫描器如果bean标签上没有id,默认id值是当前类的类名,首字母小写扫描 com.qcby.dao包下的所有接口,由框架负责提供接口的子类由spring容器负责创建接口的子类实例(spring会将创建好的接口子类实例存到map中)--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><!-- 扫描所有XxxMapper接口,将接口实例的创建交给spring容器 --><property name="basePackage" value="com.qcby.dao"/></bean></beans>

springsmv-config.xml文件配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 1.配置前端控制器放行静态资源(html/css/js等,否则静态资源将无法访问) --><mvc:default-servlet-handler/><!-- 2.启用默认配置, 配置注解驱动,用于识别注解(比如@Controller) --><mvc:annotation-driven></mvc:annotation-driven><!-- 3.配置需要扫描的包:spring自动去扫描 base-package 下的类,如果扫描到的类上有 @Controller、@Service、@Component等注解,将会自动将类注册为bean --><context:component-scan base-package="com.qcby"></context:component-scan><!-- 4.配置内部资源视图解析器prefix:配置路径前缀suffix:配置文件后缀--><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/pages/"/><property name="suffix" value=".jsp"/></bean><mvc:view-controller path="/" view-name="index"/><!--配置文件上传的解析器组件。id的名称是固定,不能乱写--><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><!--设置上传文件的总大小 8M = 8 * 1024 * 1024 --><property name="maxUploadSize" value="8388608" /></bean>
</beans>

4、jdbc.properties文件配置

db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql:///yonghe?characterEncoding=utf-8
db.username=root
db.password=123456

三、编写实体类

1、门店Door

package com.qcby.pojo;/** 用于封装门店信息 */
public class Door {//声明门店的属性private Integer id;private String name;private String tel;private String addr;//提供get和set方法public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getTel() {return tel;}public void setTel(String tel) {this.tel = tel;}public String getAddr() {return addr;}public void setAddr(String addr) {this.addr = addr;}//重写toString方法@Overridepublic String toString() {return "Door [id=" + id + ", name=" + name + ", tel=" + tel + ", addr=" + addr + "]";}
}

2、订单Order

package com.qcby.pojo;import java.util.Date;/** 用于封装订单信息的实体类 */
public class Order {private Integer id;		//订单编号private Integer doorId;	//订单所属的门店编号private String orderNo;	//下单号private String orderType;	//订单类型private Integer pnum;	//用餐人数private Integer cashierId;	//收银员编号private Date orderTime;	//下单时间private Date payTime;	//支付时间private String payType;	//支付类型private Double price;	//支付金额//提供get和set方法public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public Integer getDoorId() {return doorId;}public void setDoorId(Integer doorId) {this.doorId = doorId;}public String getOrderNo() {return orderNo;}public void setOrderNo(String orderNo) {this.orderNo = orderNo;}public String getOrderType() {return orderType;}public void setOrderType(String orderType) {this.orderType = orderType;}public Integer getPnum() {return pnum;}public void setPnum(Integer pnum) {this.pnum = pnum;}public Integer getCashierId() {return cashierId;}public void setCashierId(Integer cashierId) {this.cashierId = cashierId;}public Date getOrderTime() {return orderTime;}public void setOrderTime(Date orderTime) {this.orderTime = orderTime;}public Date getPayTime() {return payTime;}public void setPayTime(Date payTime) {this.payTime = payTime;}public String getPayType() {return payType;}public void setPayType(String payType) {this.payType = payType;}public Double getPrice() {return price;}public void setPrice(Double price) {this.price = price;}//重写toString方法@Overridepublic String toString() {return "Order [id=" + id + ", doorId=" + doorId + ", orderNo=" + orderNo + ", orderType=" + orderType+ ", pnum=" + pnum + ", cashierId=" + cashierId + ", orderTime=" + orderTime + ", payTime=" + payTime+ ", payType=" + payType + ", price=" + price + "]";}}

3、收银员Cashier

package com.qcby.pojo;/** 用于封装收银员信息 */
public class Cashier {private Integer id;   //收银员编号private String cname;  //姓名private String gender;   //性别private Integer age;   //年龄private String telephone;   //联系电话private String work_time;   //工作时间段private Integer door_id;   //所属门店idpublic Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getCname() {return cname;}public void setCname(String cname) {this.cname = cname;}public String getGender() {return gender;}public void setGender(String gender) {this.gender = gender;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}public String getTelephone() {return telephone;}public void setTelephone(String telephone) {this.telephone = telephone;}public String getWork_time() {return work_time;}public void setWork_time(String work_time) {this.work_time = work_time;}public Integer getDoor_id() {return door_id;}public void setDoor_id(Integer door_id) {this.door_id = door_id;}@Overridepublic String toString() {return "Cashier{" +"id=" + id +", cname='" + cname + '\'' +", gender='" + gender + '\'' +", age=" + age +", telephone='" + telephone + '\'' +", work_time='" + work_time + '\'' +", door_id=" + door_id +'}';}
}

4、菜单Menu

package com.qcby.pojo;/** 用于封装菜单信息 */
public class Menu {private Integer id;		//菜名编号private String dish_name;	//菜名private Double dish_price;	//价格private String discription;	//描述private String img;	//图片private Integer category_id;	//类别编号public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getDish_name() {return dish_name;}public void setDish_name(String dish_name) {this.dish_name = dish_name;}public Double getDish_price() {return dish_price;}public void setDish_price(Double dish_price) {this.dish_price = dish_price;}public String getDiscription() {return discription;}public void setDiscription(String discription) {this.discription = discription;}public String getImg() {return img;}public void setImg(String img) {this.img = img;}public Integer getCategory_id() {return category_id;}public void setCategory_id(Integer category_id) {this.category_id = category_id;}@Overridepublic String toString() {return "Menu{" +"id=" + id +", dish_name='" + dish_name + '\'' +", dish_price=" + dish_price +", discription='" + discription + '\'' +", img='" + img + '\'' +", category_id=" + category_id +'}';}
}

5、菜类别Category

package com.qcby.pojo;/** 用于封装菜名种类信息 */
public class Category {private Integer id;		//类别编号private String category;   //类别名称public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getCategory() {return category;}public void setCategory(String category) {this.category = category;}@Overridepublic String toString() {return "Category{" +"id=" + id +", category='" + category + '\'' +'}';}
}

四、编写持久层

1、DoorMapper

package com.qcby.dao;import com.qcby.pojo.Door;import java.util.List;/* 接口由我们开发人员负责提供,但接口的实现类(子类)由框架负责提供* 如果不整合mybatis和spring框架,接口的子类实例也是由mybatis负责创建* 如果整合了mybatis和spring框架,接口的子类实例将会由spring容器负责创建 */
public interface DoorMapper {/** 1.查询所有门店信息 */public List<Door> findAll();/** 2.根据id删除门店信息 */public void deleteById( Integer id );/** 3.新增门店信息 */public void add( Door door );/** 4.根据id查询门店信息 */public Door findById( Integer id );/** 5.根据id修改门店信息 */public void updateById( Door door );}

DoorMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 门店表的映射文件	namespace值为对应接口的全路径 -->
<mapper namespace="com.qcby.dao.DoorMapper"><!-- 1.查询所有门店信息,id值为对应接口中方法的名字resultType指定将查询的结果封装到哪个pojo对象中--><select id="findAll" resultType="com.qcby.pojo.Door">select * from tb_door</select><!-- 2.根据id删除门店信息 --><delete id="deleteById">delete from tb_door where id=#{id}</delete><!-- 3.新增门店信息 --><insert id="add">insert into tb_door value(null,#{name},#{tel},#{addr})</insert><!-- 4.根据id查询门店信息 --><select id="findById" resultType="com.qcby.pojo.Door">select * from tb_door where id=#{id}</select><!-- 5.根据id修改门店信息 --><update id="updateById">update tb_door set name=#{name},tel=#{tel},addr=#{addr}where id=#{id}</update></mapper>

2、OrderMapper

package com.qcby.dao;import com.qcby.pojo.Order;import java.util.List;/** 订单模块的mapper接口 */
public interface OrderMapper {/** 1.查询所有订单信息 */public List<Order> findAll();/** 2.根据id删除订单信息 */public void deleteById(Integer id);/** 3.新增订单信息 */public void add( Order order );/** 4.根据id查询订单信息 */public Order findById( Integer id );/** 5.根据id修改订单信息 */public void updateById( Order order );}

OrderMapper.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 订单表的映射文件	namespace值为对应接口的全路径 -->
<mapper namespace="com.qcby.dao.OrderMapper"><!-- 1.查询所有订单信息,id值为对应接口中方法的名字resultType指定将查询的结果封装到哪个pojo对象中通过给查询的列指定别名,解决查询的数据封装不到实体对象中的问题!!--><select id="findAll" resultType="com.qcby.pojo.Order">select id,door_id as doorId,order_no as orderNo,order_type as orderType,pnum,cashier_id as cashierId,order_time as orderTime,pay_time as payTime,pay_type as payType,pricefrom tb_order</select><!-- 2.根据id删除订单信息 --><delete id="deleteById">delete from tb_order where id=#{id}</delete><!-- 3.新增订单信息 --><insert id="add">insert into tb_order value(null,#{doorId},#{orderNo},#{orderType},#{pnum},#{cashierId},#{orderTime},#{payTime},#{payType},#{price})</insert><!-- 4.根据id查询订单信息 --><select id="findById" resultType="com.qcby.pojo.Order">select id,door_id as doorId,order_no as orderNo,order_type as orderType,pnum,cashier_id as cashierId,order_time as orderTime,pay_time as payTime,pay_type as payType,pricefrom tb_orderwhere id=#{id}</select><!-- 5.根据id修改订单信息 --><update id="updateById">update tb_order set door_id=#{doorId},order_no=#{orderNo},order_type=#{orderType},pnum=#{pnum},cashier_id=#{cashierId},order_time=#{orderTime},pay_time=#{payTime},pay_type=#{payType},price=#{price}where id=#{id}</update></mapper>

3、CashierMapper

package com.qcby.dao;import com.qcby.pojo.Cashier;import java.util.List;public interface CashierMapper {/** 1.查询所有收银员信息 */public List<Cashier> findAll();/** 2.根据id删除收银员信息 */public void deleteById( Integer id );/** 3.新增收银员信息 */public void add( Cashier cashier );/** 4.根据id查询收银员信息 */public Cashier findById( Integer id );/** 5.根据id修改收银员信息 */public void updateById( Cashier cashier );
}

CashierMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 订单表的映射文件	namespace值为对应接口的全路径 -->
<mapper namespace="com.qcby.dao.CashierMapper"><!-- 1.查询所有收银员信息--><select id="findAll" resultType="com.qcby.pojo.Cashier">select * from tb_cashier</select><!-- 2.根据id删除收银员信息 --><delete id="deleteById">delete from tb_cashier where id=#{id}</delete><!-- 3.新增收银员信息 --><insert id="add">insert into tb_cashier value(null,#{cname},#{gender},#{age},#{telephone},#{work_time},#{door_id})</insert><!-- 4.根据id查询收银员信息 --><select id="findById" resultType="com.qcby.pojo.Cashier">select * from tb_cashierwhere id=#{id}</select><!-- 5.根据id修改收银员信息 --><update id="updateById">update tb_cashier set cname=#{cname},gender=#{gender},age=#{age},telephone=#{telephone},work_time=#{work_time},door_id=#{door_id}where id=#{id}</update></mapper>

4、MenuMapper

package com.qcby.dao;import com.qcby.pojo.Menu;
import org.apache.ibatis.annotations.Param;import java.util.List;public interface MenuMapper {/** 1.查询所有菜单信息 */public List<Menu> findAll();/** 2.根据id删除菜单信息 */public void deleteById(Integer id);/** 3.新增菜单信息 */public void add( Menu Menu );/** 4.根据id查询菜单信息 */public Menu findById( Integer id );/** 5.根据id修改菜单信息 */public void updateById( Menu menu );/** 6.根据菜名模糊查询菜单信息 */public List<Menu> findByName(@Param("dish_name") String dish_name, @Param("discription") String discription);
}

MenuMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 订单表的映射文件	namespace值为对应接口的全路径 -->
<mapper namespace="com.qcby.dao.MenuMapper"><!-- 1.查询所有菜单信息--><select id="findAll" resultType="com.qcby.pojo.Menu">select * from tb_menu</select><!-- 2.根据id删除菜单信息 --><delete id="deleteById">delete from tb_menu where id=#{id}</delete><!-- 3.新增菜单信息 --><insert id="add">insert into tb_menu value(null,#{dish_name},#{dish_price},#{discription},#{img},#{category_id})</insert><!-- 4.根据id查询菜单信息 --><select id="findById" resultType="com.qcby.pojo.Menu">select * from tb_menuwhere id=#{id}</select><!-- 5.根据id修改菜单信息 --><update id="updateById">update tb_menu set dish_name=#{dish_name},dish_price=#{dish_price},discription=#{discription},img=#{img},category_id=#{category_id}where id=#{id}</update><!-- 模糊查询 --><select id="findByName" resultType="com.qcby.pojo.Menu" parameterType="map">select * from tb_menu<where><if test="dish_name != null and dish_name != ''">and dish_name like CONCAT('%', #{dish_name}, '%')</if><if test="discription != null and discription != ''">and discription like CONCAT('%', #{discription}, '%')</if></where></select></mapper>

5、CategoryMapper

package com.qcby.dao;import com.qcby.pojo.Category;import java.util.List;public interface CategoryMapper {/** 1.查询所有菜单名信息 */public List<Category> findAll();
}

CategoryMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 订单表的映射文件	namespace值为对应接口的全路径 -->
<mapper namespace="com.qcby.dao.CategoryMapper"><!-- 1.查询所有菜类别信息--><select id="findAll" resultType="com.qcby.pojo.Category">select id,category from tb_category</select></mapper>

五、编写表现层

1、DoorController   门店管理

package com.qcby.controller;import com.qcby.dao.DoorMapper;
import com.qcby.pojo.Door;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import java.util.List;
/*** 门店模块的controller*/
@Controller
public class DoorController {//获取DoorMapper接口的子类实例@Autowired //自动装配DoorMapper doorMapper;/** 1.查询所有门店信息* 	点击 "门店管理" 后,访问/doorList,执行当前方法,查询所有门店信息 */@RequestMapping("/doorList")public String doorList( Model model ) {List<Door> list = doorMapper.findAll();//将门店信息集合存入Model中,转发带到门店列表页面显示model.addAttribute("doorList", list);//转发到 door_list.jsp, 显示所有门店信息return "door_list";}/*** 2.根据id删除门店信息* @param id 所要删除门店的id值* @return  */@RequestMapping("/doorDelete")public String doorDelete(Integer id) {doorMapper.deleteById( id );//更新成功后,转发到查询所有门店信息的方法,显示最新门店信息return "forward:/doorList";}/*** 3.新增门店信息* @param door 接收浏览器提交过来的门店信息(name、tel、addr)* @return */@RequestMapping("/doorAdd")public String doorAdd( Door door ) {doorMapper.add( door );//更新成功后,转发到查询所有门店信息的方法,显示最新门店信息return "forward:/doorList";}/*** 4.根据id查询门店信息,将查询到的门店信息转发带到门店修改页面,进行数据的回显* @param id 门店的id值* @return 门店修改页面的jsp的名字*/@RequestMapping("/doorInfo")public String doorInfo( Integer id, Model model ) {//根据id查询门店信息,将门店对象存入Model中,转发带到门店修改页面Door door = doorMapper.findById( id );model.addAttribute( "door", door );//转发到门店修改页面return "door_update";}/*** 5.根据id修改门店信息* @param door 其中封装了门店的id以及修改后的门店信息* @return "forward:/doorList" 转发到查询所有门店信息的方法*/@RequestMapping("/doorUpdate")public String doorUpdate( Door door ) {doorMapper.updateById( door );//更新成功后,转发到查询所有门店信息的方法,显示最新门店信息return "forward:/doorList";}}

2、OrderController   订单管理

package com.qcby.controller;import com.qcby.dao.CashierMapper;
import com.qcby.dao.DoorMapper;
import com.qcby.dao.OrderMapper;
import com.qcby.pojo.Cashier;
import com.qcby.pojo.Door;
import com.qcby.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import java.util.List;/** 订单模块的controller */
@Controller
public class OrderController {//获取OrderMapper接口的子类实例@AutowiredOrderMapper orderMapper;//获取DoorMapper接口的子类实例@AutowiredDoorMapper doorMapper;@AutowiredCashierMapper cashierMapper;/** 1.查询所有订单信息 */@RequestMapping("/orderList")public String orderList( Model model ) {//查询所有的订单信息,并将订单信息存入model中List<Order> orderList = orderMapper.findAll();model.addAttribute( "oList", orderList );//同时查询所有的门店信息,并将门店信息存入model中List<Door> doorList = doorMapper.findAll();model.addAttribute( "dList", doorList );List<Cashier> cashierList = cashierMapper.findAll();model.addAttribute("cList", cashierList);//跳转到订单列表页面,显示所有订单信息return "order_list";}/** 2.根据id删除订单信息 */@RequestMapping("/orderDelete")public String orderDelete(Integer id) {orderMapper.deleteById( id );//转发到查询所有订单的方法,查询最新的订单信息并显示return "forward:/orderList";}/** 3.查询所有门店信息,将门店信息存入到Model中* 最终跳转到订单新增页面(order_add.jsp) */@RequestMapping("/toOrderAdd")public String toOrderAdd( Model model ) {//查询所有门店信息,将所有门店存入到Model中List<Door> doorList = doorMapper.findAll();model.addAttribute( "dList", doorList );List<Cashier> cashierList = cashierMapper.findAll();model.addAttribute("cList", cashierList);//转发到 订单新增页面, 在下拉选框中显示所有的门店列表return "order_add";}/** 4.点击新增订单页面中的"提交"后,访问当前这个方法,完成新增订单功能 */@RequestMapping("/orderAdd")public String orderAdd(Order order ) {orderMapper.add( order ); //新增订单信息//转发到查询所有订单的方法,查询最新的订单信息并显示return "forward:/orderList";}/** 5.根据id查询订单信息,将订单信息存入Model中,* 	带到订单修改页面(order_update.jsp)进行回显 */@RequestMapping("/orderInfo")public String orderInfo( Integer id, Model model ) {//根据id查询订单信息,将订单信息存入Model中Order order = orderMapper.findById( id );model.addAttribute("order", order);//查询所有门店信息,将所有门店存入到Model中List<Door> doorList = doorMapper.findAll();model.addAttribute( "dList", doorList );List<Cashier> cashierList = cashierMapper.findAll();model.addAttribute("cList", cashierList);//转发带到订单修改页面进行回显return "order_update";}/** 6.根据id修改订单信息 */@RequestMapping("/orderUpdate")public String orderUpdate( Order order ) {System.out.println(order);orderMapper.updateById( order );//转发到查询所有订单信息的方法,查询最新的订单信息并显示return "forward:/orderList";}}

3、CashierCntroller  收银员管理

package com.qcby.controller;import com.qcby.dao.CashierMapper;
import com.qcby.dao.DoorMapper;
import com.qcby.pojo.Cashier;
import com.qcby.pojo.Door;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import java.util.List;/** 收银员模块的controller */
@Controller
public class CashierController {@AutowiredCashierMapper cashierMapper;@AutowiredDoorMapper doorMapper;/** 1.查询所有订单信息 */@RequestMapping("/cashierList")public String orderList( Model model ) {//查询所有的订单信息,并将订单信息存入model中List<Cashier> cashierList = cashierMapper.findAll();model.addAttribute( "cList", cashierList );//同时查询所有的门店信息,并将门店信息存入model中List<Door> doorList = doorMapper.findAll();model.addAttribute( "dList", doorList );//跳转到订单列表页面,显示所有订单信息return "cashier_list";}/** 2.根据id删除订单信息 */@RequestMapping("/cashierDelete")public String orderDelete(Integer id) {cashierMapper.deleteById( id );//转发到查询所有订单的方法,查询最新的订单信息并显示return "forward:/cashierList";}/** 3.查询所有门店信息,将门店信息存入到Model中* 最终跳转到订单新增页面(order_add.jsp) */@RequestMapping("/toCashierAdd")public String toCashierAdd( Model model ) {//查询所有门店信息,将所有门店存入到Model中List<Door> doorList = doorMapper.findAll();model.addAttribute( "dList", doorList );//转发到 订单新增页面, 在下拉选框中显示所有的门店列表return "cashier_add";}/** 4.点击新增订单页面中的"提交"后,访问当前这个方法,完成新增订单功能 */@RequestMapping("/cashierAdd")public String orderAdd(Cashier cashier ) {cashierMapper.add( cashier ); //新增订单信息//转发到查询所有订单的方法,查询最新的订单信息并显示return "forward:/cashierList";}/** 5.根据id查询订单信息,将订单信息存入Model中,* 	带到订单修改页面(order_update.jsp)进行回显 */@RequestMapping("/cashierInfo")public String cashierInfo( Integer id, Model model ) {//根据id查询订单信息,将订单信息存入Model中Cashier cashier = cashierMapper.findById( id );model.addAttribute("cashier", cashier);//查询所有门店信息,将所有门店存入到Model中List<Door> doorList = doorMapper.findAll();model.addAttribute( "dList", doorList );//转发带到订单修改页面进行回显return "cashier_update";}/** 6.根据id修改订单信息 */@RequestMapping("/cashierUpdate")public String orderUpdate( Cashier cashier ) {cashierMapper.updateById( cashier );//转发到查询所有订单信息的方法,查询最新的订单信息并显示return "forward:/cashierList";}}

4、MenuController  菜单管理

package com.qcby.controller;import com.qcby.dao.CategoryMapper;
import com.qcby.dao.MenuMapper;
import com.qcby.pojo.Category;
import com.qcby.pojo.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;import java.util.List;/** 菜单模块的controller */
@Controller
public class MenuController {//获取OrderMapper接口的子类实例@AutowiredMenuMapper menuMapper;//获取DoorMapper接口的子类实例@AutowiredCategoryMapper categoryMapper;/** 1.查询所有订单信息 */@RequestMapping("/menuList")public String orderList( Model model ) {//查询所有的订单信息,并将订单信息存入model中List<Menu> menuList = menuMapper.findAll();model.addAttribute( "mList", menuList );//同时查询所有的门店信息,并将门店信息存入model中List<Category> categoryList = categoryMapper.findAll();model.addAttribute( "cList", categoryList );//跳转到订单列表页面,显示所有订单信息return "menu_list";}/** 2.根据id删除订单信息 */@RequestMapping("/menuDelete")public String menuDelete(Integer id) {menuMapper.deleteById( id );//转发到查询所有订单的方法,查询最新的订单信息并显示return "forward:/menuList";}/** 3.查询所有菜单种类信息,将菜单信息存入到Model中* 最终跳转到订单新增页面(menu_add.jsp) */@RequestMapping("/toMenuAdd")public String toMenuAdd( Model model ) {//查询所有门店信息,将所有门店存入到Model中List<Category> categoryList = categoryMapper.findAll();model.addAttribute( "cList", categoryList );//转发到 订单新增页面, 在下拉选框中显示所有的门店列表return "menu_add";}/** 4.点击新增菜单页面中的"提交"后,访问当前这个方法,完成新增订单功能 */@RequestMapping("/menuAdd")public String menuAdd(Menu menu ) {System.out.println(menu.getImg());menuMapper.add( menu ); //新增订单信息//转发到查询所有订单的方法,查询最新的订单信息并显示return "forward:/menuList";}/** 5.根据id查询订单信息,将订单信息存入Model中,* 	带到订单修改页面(order_update.jsp)进行回显 */@RequestMapping("/menuInfo")public String menuInfo( Integer id, Model model ) {//根据id查询订单信息,将订单信息存入Model中Menu menu = menuMapper.findById( id );model.addAttribute("menu", menu);//查询所有菜单种类信息,将所有门店存入到Model中List<Category> categoryList = categoryMapper.findAll();model.addAttribute( "cList", categoryList );//转发带到订单修改页面进行回显return "menu_update";}/** 6.根据id修改订单信息 */@RequestMapping("/menuUpdate")public String orderUpdate( Menu menu ) {System.out.println("imgurl:"+menu.getImg());menuMapper.updateById( menu );//转发到查询所有订单信息的方法,查询最新的订单信息并显示return "forward:/menuList";}/** 7.根据条件查询菜单信息 */@RequestMapping(value = "/menuSearch", method = RequestMethod.GET)public String menuSearch(Model model, @RequestParam("dish_name") String dish_name, @RequestParam("discription") String discription ) {List<Menu> menuList = menuMapper.findByName(dish_name,discription);System.out.println(menuList);model.addAttribute( "mList", menuList );List<Category> categoryList = categoryMapper.findAll();model.addAttribute( "cList", categoryList );return "menu_list";}}

5、PageController  实现通用页面跳转

package com.qcby.controller;import com.qcby.dao.DoorMapper;
import com.qcby.pojo.Door;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;import java.util.List;/* @Controller (1)标识当前类属于Controller层* 	(2)spring容器会扫描当前包下的所有类,如果类上有@Controller注解* 	将会由spring容器创建该类的实例*/
@Controller
public class PageController {/* 1、测试springmvc的运行环境 */@RequestMapping("/testmvc")public String testmvc() {System.out.println("PageController.testmvc()...");return "test";}/* 获取DoorMapper接口的子类实例 * 由于前面我们在applicationContext.xml中配置了扫描dao包下的所有接口,由* 	spring框架为接口的创建子类实例,并将接口的子类实例存到spring的map中* @Autowired作用是,根据类型(DoorMapper)到spring的map中找这个接口对应* 	的子类实例,找到之后会将接口的子类实例赋值给当前这个成员变量. */@AutowiredDoorMapper doorMapper;/* 2、测试ssm的运行环境 */@RequestMapping("/testssm")public String testssm() {//查询所有的门店信息List<Door> doorList = doorMapper.findAll();for (Door door : doorList) {System.out.println( door );}return "test";}/* 3.提供通用的页面跳转方法 * 	/{}中的jspName用于获取(接收)访问的路径名* 	例如访问路径为:../_top,那么jspName的值就是 "_top"* 	@PathVariable注解,用于将  /{}中jspName的值 作为实参传递给* 	方法上的形参 jspName, 此时形参jspName的值也为 "_top", 最终将* 	"_top"直接return。即跳转到 _top.jsp* 	总结: 当访问的路径名为 xxx, 就可以跳转到 xxx.jsp*/@RequestMapping("/{jspName}")public String toJspPage( @PathVariable String jspName ) {System.out.println("-----执行通用的页面跳转方法,跳转到 ["+jspName+".jsp]...");return jspName;}}

6、UploadController  图片上传

package com.qcby.controller;import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.UUID;@Controller
public class UploadController {/*** 文件上传* MultipartFile upload 文件上传解析器对象解析request后,文件上传对象* @return*/@RequestMapping(value = "/upload", method = RequestMethod.POST)@ResponseBodypublic ResponseEntity<String> upload(@RequestParam("imgurl") MultipartFile upload, HttpServletRequest request) throws IOException {// 把文件上传到哪个位置String realPath = request.getSession().getServletContext().getRealPath("/uploads");// 创建该文件夹File file = new File(realPath);// 判断该文件夹是否存在if(!file.exists()){// 创建文件夹file.mkdirs();}// 获取到上传文件的名称String filename = upload.getOriginalFilename();//字符串切割//String suffix = filename.substring(filename.lastIndexOf("."));// 把文件的名称修改成为一的值 sdfs-csdf-fwer-sdfwString uuid = UUID.randomUUID().toString().replace("-", "").toUpperCase();// 唯一的值filename = uuid+"_"+filename;// 上传文件upload.transferTo(new File(file,filename));String img = "uploads/"+filename;System.out.println(img);// 使用ResponseEntity返回文件路径return new ResponseEntity<>(img, HttpStatus.OK);}
}

六、编写JSP页面

1、管理页面(index.jsp、_top.jsp、_right.jsp、_left.jsp)

①index.jsp

<%@ page pageEncoding="utf-8"%>
<!doctype html>
<html>
<head><meta charset="utf-8"/>
</head><!-- frameset标签必须要放在head和body之间--><frameset rows="14%,86%" frameborder="0"><frame src="_top" /><frameset cols="180px,*"><frame src="_left" /><frame src="_right" name="rightFrame"/></frameset></frameset><body></body>
</html>

②_top.jsp 

<%@ page pageEncoding="utf-8"%>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<style>body{background:#f1a98c;}h1{color:#fff;text-indent:20px;letter-spacing:5px;text-shadow:5px 5px 5px #ef6c6c;text-align: center;}
</style>
</head>
<body><h1>雍禾门店管理系统</h1>
</body>
</html>

③_right.jsp

<%@ page pageEncoding="utf-8"%>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<style>body{ background:#ffffff; }#welcome{font-size:36px;color:#f19d64;text-align:center;text-shadow:5px 5px 5px #d6b2b2;margin-top:180px;}
</style>
</head>
<body><div id="welcome">欢迎访问雍禾门店管理系统...</div>
</body>
</html>

④_left.jsp

<%@ page pageEncoding="utf-8"%>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<style>body{ background:#f1ac97;margin:0px; }.menu-bar a{ color:#fff;text-decoration:none; }.menu-bar{ font-size:22px;border-bottom:1px solid #fff;height:40px;line-height:40px;text-indent:18px;letter-spacing:5px; }.menu-bar:first-child{border-top:1px solid #fff;}.menu-bar:hover{background:#f46464;}
</style>
</head>
<body><div class="menu-bar"><a href="doorList" target="rightFrame">› 门店管理</a></div><div class="menu-bar"><a href="orderList" target="rightFrame">› 订单管理</a></div><div class="menu-bar"><a href="cashierList" target="rightFrame">› 收银员管理</a></div><div class="menu-bar"><a href="menuList" target="rightFrame">› 菜单管理</a></div>
</body>
</html>

⑤页面效果

2、门店管理(door_list.jsp、door_add.jsp、door_update.jsp) 

①door_list.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
<title>门店管理</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body{ font-family: "微软雅黑"; background-color: #ffff; }h2{ text-align: center;color: gray;}table{ width:96%; margin: 0 auto; text-align: center; border-collapse:collapse; font-size:16px;border-color: #f0a16c;}td, th{ padding: 5px;color: gray;}th{ background-color: #efb78d; width:120px;}th.width-40{ width: 40px; }th.width-70{ width: 70px; }th.width-80{ width: 80px; }hr{ margin-bottom:20px; border:1px solid #f1b5b5; }#add-door{text-align:right;font-size:20px;padding-right: 8%;}#add-door a{text-decoration: none;color: #f7ab07;}#add-door a:hover{color: #f36161;}td a{text-decoration: none;color: #f1a98c;}td a:hover{color: #ef6c6c;}
</style>
</head>
<body><!-- body-start  --><h2>门店管理</h2>
<div id="add-door"><a href="door_add" target="rightFrame">新增门店</a>
</div>
<hr/>
<table border="1"><tr><th class="width-40">序号</th><th>门店名称</th><th class="width-80">联系电话</th><th>门店地址</th><th class="width-80">操 作</th></tr><!-- 模版数据:  model.addAttribute("doorList", list); -->
<c:forEach items="${ doorList }" var="door" varStatus="vs"><tr><td>${ vs.count }</td><td>${ door.name }</td><td>${ door.tel }</td><td>${ door.addr }</td><td><a href="doorDelete?id=${ door.id }" onclick="return doorDelete()">删除</a>&nbsp;|&nbsp;<a href="doorInfo?id=${ door.id }">修改</a></td></tr>
</c:forEach>	</table>
<div style="text-align:center;color:#AAA;line-height:40px;">提示:删除门店同时会删除该门店下的所有订单!
</div><script type="text/javascript">function doorDelete(){return confirm("删除门店同时会删除该门店下的所有订单,确定要删除吗?");}
</script></body><!-- body-end  -->
</html>

页面效果:

 

②door_add.jsp

<%@ page pageEncoding="utf-8"%>
<!DOCTYPE HTML>
<html>
<head>
<title>新增门店</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 7px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}
</style>
</head>
<body><!-- body-start  --><h2>新增门店</h2>
<hr/>
<form action="doorAdd" method="POST"><table border="1"><tr><td width="30%">门店名称</td><td><input type="text" name="name"/></td></tr><tr><td>联系电话</td><td><input type="text" name="tel"/></td></tr><tr><td>门店地址</td><td><input type="text" name="addr"/></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form></body><!-- body-end  -->
</html>

页面效果:

③door_update.jsp

<%@ page pageEncoding="utf-8"%>
<!DOCTYPE HTML>
<html>
<head>
<title>修改门店</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color:gray; }table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 7px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac;}select{text-indent:0px;}textarea{height:100px;font-size:22px;}
</style>
</head>
<body><!-- body-start  --><h2>修改门店</h2>
<hr/>
<form action="doorUpdate" method="POST"><!-- hidden隐藏域,在提交表单时连door.id一起提交 --><input type="hidden" name="id" value="${ door.id }"/><table border="1"><tr><td width="30%">门店名称</td><!-- model.addAttribute("door", door ); --><td><input type="text" name="name" value="${ door.name }"/></td></tr><tr><td>联系电话</td><td><input type="text" name="tel" value="${ door.tel }"/></td></tr><tr><td>门店地址</td><td><input type="text" name="addr" value="${ door.addr }"/></td></tr><tr><td colspan="2"><input type="submit" value="提	交" /></td></tr></table>
</form></body><!-- body-end  -->
</html>

页面效果:

3、订单管理(order_list.jsp、order_add.jsp、order_update.jsp) 

①order_list.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
<title>订单管理</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body{ font-family: "微软雅黑"; background-color: #ffff; }h2{ text-align: center;color: gray;}table{ width:96%; margin: 0 auto; text-align: center; border-collapse:collapse; font-size:16px;border-color: #f0a16c;}td, th{ padding: 5px;color: gray;}th{ background-color: #efb78d; width:120px; }th.width-40{ width: 40px; }th.width-50{ width: 50px; }th.width-64{ width: 64px; }th.width-80{ width: 80px; }th.width-120{ width: 100px; }hr{ margin-bottom:20px; border:1px solid #f1b5b5; }#add-order{text-align:right;font-size:20px;padding-right: 5%;}#add-order a{text-decoration: none;color: #f7ab07;}#add-order a:hover{color: #f36161;}td a{text-decoration: none;color: #f1a98c;}td a:hover{color: #ef6c6c;}
</style><script type="text/javascript"></script>
</head>
<body>
<h2>订单管理</h2>
<div id="add-order"><!-- 点击后查询所有门店信息后再跳转到订单新增页面 --><a href="toOrderAdd" target="rightFrame">新增订单</a>
</div>
<hr/>
<table border="1"><tr><th class="width-40">序号</th><th class="width-120">所属门店</th><th class="width-50">订单号</th><th class="width-40">类型</th><th class="width-40">人数</th><th class="width-50">收银员</th><th class="width-120">下单时间</th><th class="width-120">结账时间</th><th class="width-50">支付方式</th><th class="width-50">金额</th><th class="width-80">操 作</th></tr><!-- 模版数据 model.addAttribute( "oList", orderList ); -->
<c:forEach items="${ oList }" var="order" varStatus="vs"><tr><td>${ vs.count }</td><%-- model.addAttribute( "dList", doorList );在order对象中虽然没有记录所属的门店名称,但是有记录所属的门店编号遍历门店集合,将每一个门店(${door.id})的编号,与订单中记录的所属门店编号(${order.doorId})进行比较, 如果二者相等,就取出这个门店编号所对应的门店名称,显示在下面的td标签内部--%><td><c:forEach items="${ dList }" var="door">${ door.id==order.doorId ? door.name : "" }</c:forEach></td><td>${ order.orderNo }</td><td>${ order.orderType }</td><td>${ order.pnum }</td><td><c:forEach items="${ cList }" var="cashier">${ cashier.id==order.cashierId ? cashier.cname : "" }</c:forEach></td><td><fmt:formatDate value="${ order.orderTime }"pattern="yyyy/MM/dd HH:mm:ss"/></td><td><fmt:formatDate value="${ order.payTime }"pattern="yyyy/MM/dd HH:mm:ss"/></td><td>${ order.payType }</td><td>${ order.price }</td><td><a href="orderDelete?id=${ order.id }" onclick="return orderDelete()">删除</a>&nbsp;|&nbsp;<a href="orderInfo?id=${ order.id }">修改</a></td></tr>
</c:forEach>
</table>
<script type="text/javascript">function orderDelete(){return confirm("确定要删除此订单吗?");}
</script>
</body><!-- body-end  -->
</html>

页面效果:

②order_add.jsp

<%@ page pageEncoding="utf-8"%>
<!-- 引入JSTL标签库 -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
<title>新增订单</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 5px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}
</style>
</head>
<body><!-- body-start  --><h2>新增订单</h2>
<hr/>
<form action="orderAdd" method="POST"><table border="1"><tr><td width="30%">所属门店</td><!-- model.addAttribute( "dList", doorList );通过c:forEach遍历门店集合,将每一个门店作为一个option(选项)添加到下拉选框中,每一个选框上显示的是门店名称,但如果选项被选中了,提交的则是门店的编号(也就是value值),因为订单表中只有保存门店编号的列,没有保存门店名称的列. --><td><select name="doorId"><c:forEach items="${ dList }" var="door"><option value="${ door.id }">${ door.name }</option></c:forEach></select></td></tr><tr><td>订单编号</td><td><input type="text" name="orderNo"/></td></tr><tr><td>订单类型</td><td>
<%--				<input type="text" name="orderType" --%>
<%--						value="堂食"/>--%><select id="orderType" name="orderType"><option value="食堂" selected>食堂</option><option value="外卖">外卖</option><option value="打包">打包</option></select></td></tr><tr><td>用餐人数</td><td><input type="text" name="pnum"value="1"/></td></tr><tr><td>收银员</td><td><select name="cashierId"><c:forEach items="${ cList }" var="cashier"><option value="${ cashier.id }">${ cashier.cname }</option></c:forEach></select></td></tr><tr><td>支付方式</td><td>
<%--				<input type="text" name="payType"--%>
<%--						value="微支付"/>--%><select id="payType" name="payType"><option value="微支付" selected>微支付</option><option value="支付宝">支付宝</option><option value="现金">现金</option></select></td></tr><tr><td>下单时间</td><td><input type="text" name="orderTime" /></td></tr><tr><td>结账时间</td><td><input type="text" name="payTime" /></td></tr><tr><td>支付金额</td><td><input type="text" name="price"/></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form></body><!-- body-end  -->
</html>

页面效果:

③order_update.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
<title>修改订单</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 5px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}
</style>
</head>
<body><!-- body-start  --><h2>修改订单</h2>
<hr/>
<form action="orderUpdate" method="POST"><!-- hidden隐藏域,在提交表单时连order.id一起提交 --><input type="hidden" name="id" value="${ order.id }"/><table border="1"><tr><!-- model.addAttribute( "dList", doorList );通过c:forEach遍历门店集合,将每一个门店作为一个option(选项)添加到下拉选框中,每一个选框上显示的是门店名称,但如果选项被选中了,提交的则是门店的编号(也就是value值),因为订单表中只有保存门店编号的列,没有保存门店名称的列. 设置所属门店的回显: 将订单中记录的门店编号,和正在遍历的每一个门店的编号进行比较,如果相等,就将当前这个option设置为默认被选中(加上selected属性即可!).--><td width="30%">所属门店</td><td><select id="doorId" name="doorId"><c:forEach items="${ dList }" var="door"><%--<c:if test="${ order.doorId == door.id }"><option value="${ door.id }" selected="selected">${ door.name }</option></c:if><c:if test="${ order.doorId != door.id }"><option value="${ door.id }">${ door.name }</option></c:if> --%><option ${ order.doorId==door.id ? "selected='selected'" : "" } value="${ door.id }">${ door.name }</option></c:forEach></select></td></tr><!-- model.addAttribute("order", order); --><tr><td>订单编号</td><td><input type="text" name="orderNo" value="${ order.orderNo }"/></td></tr><tr><td>订单类型</td><td>
<%--				<input type="text" name="orderType" value="${ order.orderType }"/>--%><select id="orderType" name="orderType"><option ${ order.orderType=='食堂' ? "selected='selected'" : ""} value="食堂">食堂</option><option ${ order.orderType=='外卖' ? "selected='selected'" : ""} value="外卖">外卖</option><option ${ order.orderType=='打包' ? "selected='selected'" : ""} value="打包">打包</option></select></td></tr><tr><td>用餐人数</td><td><input type="text" name="pnum" value="${ order.pnum }"/></td></tr><tr><td>收银员</td><td><select id="cashierId" name="cashierId"><c:forEach items="${ cList }" var="cashier"><option ${ order.cashierId==cashier.id ? "selected='selected'" : "" }value="${ cashier.id }">${ cashier.cname }</option></c:forEach></select></td></tr><tr><td>下单时间</td><td><input type="text" name="orderTime"value='<fmt:formatDatevalue="${ order.orderTime }"pattern="yyyy/MM/dd HH:mm:ss"/>'/>
<%--						pattern="yyyy-MM-dd'T'HH:mm:ss"/>'/>--%></td></tr><tr><td>结账时间</td><td><input type="text" name="payTime"value='<fmt:formatDate value="${ order.payTime }"pattern="yyyy/MM/dd HH:mm:ss"/>'/></td></tr><tr><td>支付方式</td><td>
<%--				<input type="text" name="payType" value="${ order.payType }"/>--%><select id="payType" name="payType"><option ${ order.payType=='微支付' ? "selected='selected'" : ""} value="微支付">微支付</option><option ${ order.payType=='支付宝' ? "selected='selected'" : ""} value="支付宝">支付宝</option><option ${ order.payType=='现金' ? "selected='selected'" : ""} value="现金">现金</option></select></td></tr><tr><td>支付金额</td><td><input type="text" name="price" value="${ order.price }"/></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form></body><!-- body-end  -->
</html>

页面效果:

3、收银员管理(cashier_list.jsp、cashier_add.jsp、cashier_update.jsp) 

①cashier_list.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c"uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head><title>订单管理</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css">body{ font-family: "微软雅黑"; background-color: #ffff; }h2{ text-align: center;color: gray;}table{ width:96%; margin: 0 auto; text-align: center; border-collapse:collapse; font-size:16px;border-color: #f0a16c;}td, th{ padding: 5px;color: gray;}th{ background-color: #efb78d; width:120px; }th.width-40{ width: 40px; }th.width-50{ width: 50px; }th.width-30{ width: 30px; }th.width-80{ width: 80px; }th.width-120{ width: 120px; }hr{ margin-bottom:20px; border:1px solid #f1b5b5; }#add-cashier{text-align:right;font-size:20px;padding-right: 5%;}#add-cashier a{text-decoration: none;color: #f7ab07;}#add-order a:hover{color: #f36161;}td a{text-decoration: none;color: #f1a98c;}td a:hover{color: #ef6c6c;}</style><script type="text/javascript"></script>
</head>
<body>
<h2>收银员管理</h2>
<div id="add-cashier"><!-- 点击后查询所有门店信息后再跳转到订单新增页面 --><a href="toCashierAdd" target="rightFrame">新增收银员</a>
</div>
<hr/>
<table border="1"><tr><th class="width-30">序号</th><th class="width-50">姓名</th><th class="width-30">性别</th><th class="width-30">年龄</th><th class="width-40">联系电话</th><th class="width-80">工作时间段</th><th class="width-120">所属门店</th><th class="width-80">操 作</th></tr><c:forEach items="${ cList }" var="cashier" varStatus="vs"><tr><td>${ vs.count }</td><td>${ cashier.cname }</td><td>${ cashier.gender }</td><td>${ cashier.age }</td><td>${ cashier.telephone }</td><td>${ cashier.work_time }</td><td><c:forEach items="${ dList }" var="door">${ door.id==cashier.door_id ? door.name : "" }</c:forEach></td><td><a href="cashierDelete?id=${ cashier.id }" onclick="return cashierDelete()">删除</a>&nbsp;|&nbsp;<a href="cashierInfo?id=${ cashier.id }">修改</a></td></tr></c:forEach>
</table>
<script type="text/javascript">function cashierDelete(){return confirm("确定要删除此收银员信息吗?");}
</script>
</body><!-- body-end  -->
</html>

页面效果:

②cashier_add.jsp

<%@ page pageEncoding="utf-8"%>
<!-- 引入JSTL标签库 -->
<%@ taglib prefix="c"uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head><title>新增菜单</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 5px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}</style>
</head>
<body><!-- body-start  --><h2>新增收银员</h2>
<hr/>
<form action="cashierAdd" method="POST"><table border="1"><tr><td>姓名</td><td><input type="text" name="cname"/></td></tr><tr><td>性别</td><td><select id="gender" name="gender"><option value="男" selected>男</option><option value="女">女</option></select></td></tr><tr><td>年龄</td><td><input type="number" name="age" min="18" max="60"/></td></tr><tr><td>联系电话</td><td><input type="text" name="telephone"/></td></tr><tr><td>工作时间段</td><td><input type="text" name="work_time"/></td></tr><tr><td width="30%">所属门店</td><td><select name="door_id"><c:forEach items="${ dList }" var="door"><option value="${ door.id }">${ door.name }</option></c:forEach></select></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form>
</body>
</html>

页面效果:

③cashier_update.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head><title>修改收银员信息</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 5px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}</style>
</head>
<body><!-- body-start  --><h2>修改收银员信息</h2>
<hr/>
<form action="cashierUpdate" method="POST"><!-- hidden隐藏域,在提交表单时连order.id一起提交 --><input type="hidden" name="id" value="${ cashier.id }"/><table border="1"><tr><td>姓名</td><td><input type="text" name="cname" value="${ cashier.cname }"/></td></tr><tr><td>性别  </td><td><select id="gender" name="gender"><option ${ cashier.gender=='男' ? "selected='selected'" : ""} value="男">男</option><option ${ cashier.gender=='女' ? "selected='selected'" : ""} value="女">女</option></select></td></tr><tr><td>年龄</td><td><input type="number" name="age" value="${ cashier.age }"/></td></tr><tr><td>联系电话</td><td><input type="text" name="telephone" value="${ cashier.telephone }"/></td></tr><tr><td>工作时间段</td><td><input type="text" name="work_time" value="${ cashier.work_time }"/></td></tr><tr><td width="30%">所属门店</td><td><select id="door_id" name="door_id"><c:forEach items="${ dList }" var="door"><option ${ cashier.door_id==door.id ? "selected='selected'" : "" }value="${ door.id }">${ door.name }</option></c:forEach></select></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form>
</body>
</html>

页面效果:

5、菜单管理(menu_list.jsp、menu_add.jsp、menu_update.jsp) 

①menu_list.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c"uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head><title>菜单管理</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css">body{ font-family: "微软雅黑"; background-color: #ffff; }h2{ text-align: center;color: gray;}table{ width:96%; margin: 0 auto; text-align: center; border-collapse:collapse; font-size:16px;border-color: #f0a16c;}td, th{ padding: 5px;color: gray;}th{ background-color: #efb78d; width:120px; }th.width-50{ width: 50px; }th.width-30{ width: 30px; }th.width-60{ width: 60px; }th.width-120{ width: 120px; }hr{ margin-bottom:20px; border:1px solid #f1b5b5; }.do{display: flex;}#search-menu{width: 80%;padding-left: 3%;}#search-menu input{height: 30px;text-align: center;margin-right: 10px;border-radius:5px 5px 5px 5px;border-color: #f0a16c;}#search-menu input[type='submit']{width:60px;cursor:pointer;background: #f1a98c;border: #ef6c6c;color: darkslategray;font-size: 16px;}#add-menu{text-align:right;font-size:20px;width:20%;padding-right: 5%;}#add-menu a{text-decoration: none;color: #f7ab07;}#add-order a:hover{color: #f36161;}td a{text-decoration: none;color: #f1a98c;}td a:hover{color: #ef6c6c;}</style>
<%--    <script src="/js/jquery.min.js" type="text/javascript"></script>--%>
<%--    <script>--%>
<%--        // 页面加载--%>
<%--        $(function(){--%>
<%--            var dish_name = $(".dish_name").val().trim()--%>
<%--            var discription = $(".discription").val().trim()--%>
<%--            $(".search_btn").click(function(){--%>
<%--                // 发送ajax的请求--%>
<%--                $.ajax({--%>
<%--                    url:"menuSearch?dish_name="+dish_name+"&discription="+discription,--%>
<%--                    type:"get",--%>
<%--                    success:function(value){--%>
<%--                        console.log("查询成功")--%>
<%--                    }--%>
<%--                });--%>
<%--            });--%>
<%--        });--%>
<%--    </script>--%>
</head>
<body>
<h2>菜单管理</h2>
<div class="do"><div id="search-menu"><form action="menuSearch" method="GET"><input type="text" placeholder="请输入菜名" name="dish_name"><input type="text" placeholder="请输入描述关键字" name="discription"><input type="submit" value="查找" class="search_btn"></form></div><div id="add-menu"><!-- 点击后查询所有菜单信息后再跳转到菜单新增页面 --><a href="toMenuAdd" target="rightFrame">新增菜单</a></div>
</div>
<hr/>
<table border="1"><tr><th class="width-30">序号</th><th class="width-50">菜名</th><th class="width-30">价格</th><th class="width-120">描述</th><th class="width-60">照片</th><th class="width-30">类别</th><th class="width-60">操 作</th></tr><c:forEach items="${ mList }" var="menu" varStatus="vs"><tr><td>${ vs.count }</td><td>${ menu.dish_name }</td><td>${ menu.dish_price }</td><td>${ menu.discription }</td><td><img src="${ menu.img }" alt="${ menu.dish_name }" width="75px" height="60px"/>  </td><td><c:forEach items="${ cList }" var="category">${ menu.category_id==category.id ? category.category : "" }</c:forEach></td><td><a href="menuDelete?id=${ menu.id }" onclick="return menuDelete()">删除</a>&nbsp;|&nbsp;<a href="menuInfo?id=${ menu.id }">修改</a></td></tr></c:forEach>
</table>
<script type="text/javascript">function menuDelete(){return confirm("确定要删除此菜单吗?");}
</script>
</body>
</html>

页面效果:

②menu_add.jsp

<%@ page pageEncoding="utf-8"%>
<!-- 引入JSTL标签库 -->
<%@ taglib prefix="c"uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head><title>新增菜单</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 5px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}</style><script src="/js/jquery.js" type="text/javascript"></script><script>$(function(){// 上传图片$(".imgurl").on("change", function(){var upload = new FormData();var fileInput = $(this)[0]; // 获取原生的DOM元素// 检查是否有文件被选中if(fileInput.files && fileInput.files[0]){// 将文件添加到FormData对象中upload.append("imgurl", fileInput.files[0]);$.ajax({url: "/upload",type: "post",data: upload,// 必须设置为false,以便发送正确的数据格式(multipart/form-data)contentType: false,// 必须设置为false,以便jQuery不处理发送的数据processData: false,success: function (value) {$(".imgbox img").attr('src', value)$(".img").empty();// 给隐藏域设置值$(".img").val(value);},error: function () {alert("上传图像出错啦!");}});} else {alert("请上传图片");}});});</script>
</head>
<body><!-- body-start  --><h2>新增菜单</h2>
<hr/>
<form action="menuAdd" method="POST"><table border="1"><tr><td>菜名</td><td><input type="text" name="dish_name"/></td></tr><tr><td>价格</td><td><input type="text" name="dish_price"/></td></tr><tr><td>描述</td><td>
<%--                <input type="text" name="discription"/>--%><textarea name="discription"></textarea></td></tr><tr><td>图片</td><td><input type="file" name="imgurl" class="imgurl"/><input type="hidden" name="img" class="img"/><div class="imgbox"><img src="" alt="${ menu.dish_name }" width="75px" height="60px"/></div></td></tr><tr><td width="30%">类别</td><td><select name="categoryId"><c:forEach items="${ cList }" var="category"><option value="${ category.id }">${ category.category }</option></c:forEach></select></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form>
</body>
</html>

页面效果:

③menu_update.jsp

<%@ page pageEncoding="utf-8"%>
<%-- 引入JSTL标签库 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head><title>修改菜单</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css">body{ font-family: "微软雅黑"; background-color: #fff; }h2{ text-align: center;font-size:26px; color: gray;}table{ margin: 30px auto; text-align: center; border-collapse:collapse; width:50%; border-color: #f0a16c;}td, th{ padding: 5px;font-size:18px;color: gray;}hr{ margin-bottom:20px; border:1px solid #f1b5b5; }input,select,textarea{ width:284px; height:30px; background:#f7e4d0; border:1px solid #ef9b9b; text-indent:5px; font-size:18px; color: gray;}input[type='submit']{ width:130px; height:36px; cursor:pointer; border-radius:5px 5px 5px 5px; background:#f5acac; }select{text-indent:0px;}textarea{height:100px;font-size:22px;}</style><script src="/js/jquery.js" type="text/javascript"></script><script>$(function(){// 上传图片$(".imgurl").on("change", function(){var upload = new FormData();var fileInput = $(this)[0]; // 获取原生的DOM元素// 检查是否有文件被选中if(fileInput.files && fileInput.files[0]){// 将文件添加到FormData对象中upload.append("imgurl", fileInput.files[0]);$.ajax({url: "/upload",type: "post",data: upload,// 必须设置为false,以便发送正确的数据格式(multipart/form-data)contentType: false,// 必须设置为false,以便jQuery不处理发送的数据processData: false,success: function (value) {$(".imgbox img").attr('src', value)$(".img").empty();// 给隐藏域设置值$(".img").val(value);},error: function () {alert("上传图像出错啦!");}});} else {alert("请上传图片");}});});</script>
</head>
<body><!-- body-start  --><h2>修改订单</h2>
<hr/>
<form action="menuUpdate" method="POST" enctype="multipart/form-data"><!-- hidden隐藏域,在提交表单时连order.id一起提交 --><input type="hidden" name="id" value="${ menu.id }"/><table border="1"><tr><td>菜名</td><td><input type="text" name="dish_name" value="${ menu.dish_name }"/></td></tr><tr><td>价格</td><td><input type="text" name="dish_price" value="${ menu.dish_price }"/></td></tr><tr><td>描述</td><td>
<%--                <input type="text" name="discription" value="${ menu.discription }"/>--%><textarea name="discription">${ menu.discription }</textarea></td></tr><tr><td>图片</td><td><input type="file" name="imgurl" class="imgurl"/><input type="hidden" name="img" class="img"/><div class="imgbox"><img src="${menu.img}" alt="${ menu.dish_name }" width="75px" height="60px"/></div></td></tr><tr><td width="30%">类别</td><td><select id="category_id" name="category_id"><c:forEach items="${ cList }" var="category"><option ${ menu.category_id==category.id ? "selected='selected'" : "" }value="${ category.id }">${ category.category }</option></c:forEach></select></td></tr><tr><td colspan="2"><input type="submit" value="提 	交"/></td></tr></table>
</form>
</body>
</html>

页面效果:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/468380.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【C++】内存五大区详解

&#x1f490; &#x1f338; &#x1f337; &#x1f340; &#x1f339; &#x1f33b; &#x1f33a; &#x1f341; &#x1f343; &#x1f342; &#x1f33f; &#x1f344;&#x1f35d; &#x1f35b; &#x1f364; &#x1f4c3;个人主页 &#xff1a;阿然成长日记 …

片上网络NoC(5)——非直连拓扑

目录 一、前言 二、概念阐述 三、交叉开关 四、蝶形网络 五、clos网络 六、fat tree网络 6.1 clos网络的折叠过程 七、总结 一、前言 本文继续介绍片上网络的拓扑&#xff0c;在之前的文章中&#xff0c;我们已经介绍了片上网络的拓扑指标和直连拓扑的相关内容&#xf…

2、6作业

TCP和UDP的区别 TCP和UDP都是通信协议 TCP提供有连接的&#xff0c;稳定的&#xff0c;无误码无失真无乱序无丢失的通信 UDP提供无连接的&#xff0c;尽力的&#xff0c;可能误码可能乱序&#xff0c;可能丢失的通信 TCP每发一个数据包就需要对方回应一个应答包&#xff0c…

分享88个CSS3特效,总有一款适合您

分享88个CSS3特效&#xff0c;总有一款适合您 88个CSS3特效下载链接&#xff1a;https://pan.baidu.com/s/1pDAyFESnO8HSnCZj4-DOzQ?pwd8888 提取码&#xff1a;8888 Python采集代码下载链接&#xff1a;采集代码.zip - 蓝奏云 学习知识费力气&#xff0c;收集整理更不…

python中库的安装和卸载

1 安装库的基本方法 pip install 库名 2 批量下载(pa.txt放入库的名称和版本要求&#xff09;格式如图所示&#xff1a; pip install -r pa.txt 3 官网下载安装库 https://pypi.org/project/ 搜索后点击Download files python -m pip install C:\Users\ZHUHUA\Downloads\…

第二节:轻松玩转书生·浦语大模型趣味Demo

参考教程&#xff1a;https://github.com/InternLM/tutorial/blob/main/helloworld/hello_world.md InternLM-Chat-7B 智能对话 Demo 终端运行 web demo 运行 1.首先启动服务&#xff1a; cd /root/code/InternLM streamlit run web_demo.py --server.address 127.0.0.1 --…

如何把华为手机上的数据转移到荣耀手机上?

方法/步骤 点击并进入华为手机&#xff08;旧手机&#xff09;的【手机克隆】应用&#xff0c;选择【这是旧设备】&#xff1b; 点击并进入荣耀手机&#xff08;新手机&#xff09;的【换机克隆】应用&#xff0c;选择【这是新设备】&#xff1b; 荣耀手机&#xff08;新…

AtCoder Beginner Contest 340 C - Divide and Divide【打表推公式】

原题链接&#xff1a;https://atcoder.jp/contests/abc340/tasks/abc340_c Time Limit: 2 sec / Memory Limit: 1024 MB Score: 300 points 问题陈述 黑板上写着一个整数 N。 高桥将重复下面的一系列操作&#xff0c;直到所有不小于2的整数都从黑板上移除&#xff1a; 选择…

H12-821_31

31.下面是一台路由器的部分配置,关于该配置描述正确的是: A.源地址为1.1.1.1的数据包匹配第一条ACL语句rule 0,匹配规则为允许 B.源地址为1.1.1.3的数据包匹配第三条ACL语句rule 2,匹配规则为拒绝 C.源地址为1.1.1.4的数据包匹配第四条ACL语句rule 3,匹配规则为允许 D.源地址为…

InstantBox:开箱即用的临时 Linux 环境

在云计算和虚拟化技术日益成熟的今天&#xff0c;我们有时需要一个快速、简单、临时的 Linux 环境来进行各种任务。这就是 InstantBox 的用武之地。 什么是 InstantBox&#xff1f; InstantBox 是一个开源项目&#xff0c;它可以快速启动临时的 Linux 系统&#xff0c;并提供…

自动生成测试用例_接口测试用例自动生成工具

前言 写用例之前&#xff0c;我们应该熟悉API的详细信息。建议使用抓包工具Charles或AnyProxy进行抓包。 har2case 我们先来了解一下另一个项目har2case 他的工作原理就是将当前主流的抓包工具和浏览器都支持将抓取得到的数据包导出为标准通用的 HAR 格式&#xff08;HTTP A…

Node.js开发-HTTP协议

HTTP协议 1) 概念2) 请求报文的组成3) HTTP 的请求行4) HTTP 请求头5) HTTP 的请求体6) 响应报文的组成7) 创建 HTTP 服务8) 获取 HTTP请求报文9) 设置 HTTP 响应报文10) 设置资源类型&#xff08;mime类型&#xff09;11) GET和POST请求的区别 1) 概念 HTTP&#xff08;hyper…