/*
Navicat Premium Data Transfer
Source Server : MySQL
Source Server Type : MySQL
Source Server Version : 50743
Source Host : localhost:3306
Source Schema : yonghe
Target Server Type : MySQL
Target Server Version : 50743
File Encoding : 65001
Date: 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文件中引入相关依赖
4.0.0
com.qcby
yonghe
0.0.1-SNAPSHOT
org.apache.maven.plugins
maven-compiler-plugin
8
war
junit
junit
4.10
org.slf4j
slf4j-log4j12
1.6.4
javax.servlet
servlet-api
2.5
provided
javax.servlet
jsp-api
2.0
provided
jstl
jstl
1.2
org.springframework
spring-webmvc
4.1.3.RELEASE
org.springframework
spring-jdbc
4.1.3.RELEASE
org.springframework
spring-aspects
4.1.3.RELEASE
org.mybatis
mybatis
3.2.8
org.mybatis
mybatis-spring
1.2.2
mysql
mysql-connector-java
5.1.32
com.alibaba
druid
1.1.6
commons-fileupload
commons-fileupload
1.3.1
commons-io
commons-io
2.4
2、配置web.xml文件
day17-springmvc
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
500
/WEB-INF/pages/500.jsp
404
/WEB-INF/pages/404.jsp
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/*.xml
1
springmvc
/
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF8
encodingFilter
/*
3、创建spring文件夹,在spring文件夹下创建并配置applicationContext.xml和springsmv-config.xml文件
applicationContext.xml文件配置
springsmv-config.xml文件配置
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方法
@Override
public 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方法
@Override
public 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; //所属门店id
public 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;
}
@Override
public 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;
}
@Override
public 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;
}
@Override
public 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 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
delete from tb_door where id=#{id}
insert into tb_door value
(null,#{name},#{tel},#{addr})
update tb_door set name=#{name},
tel=#{tel},addr=#{addr}
where id=#{id}
2、OrderMapper
package com.qcby.dao;
import com.qcby.pojo.Order;
import java.util.List;
/** 订单模块的mapper接口 */
public interface OrderMapper {
/** 1.查询所有订单信息 */
public List 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
delete from tb_order where id=#{id}
insert into tb_order value
(null,#{doorId},#{orderNo},#{orderType},
#{pnum},#{cashierId},#{orderTime},#{payTime},
#{payType},#{price})
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}
3、CashierMapper
package com.qcby.dao;
import com.qcby.pojo.Cashier;
import java.util.List;
public interface CashierMapper {
/** 1.查询所有收银员信息 */
public List 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
delete from tb_cashier where id=#{id}
insert into tb_cashier value
(null,#{cname},#{gender},#{age},
#{telephone},#{work_time},#{door_id})
update tb_cashier set cname=#{cname},gender=#{gender},
age=#{age},telephone=#{telephone},
work_time=#{work_time},door_id=#{door_id}
where id=#{id}
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
MenuMapper.xml
delete from tb_menu where id=#{id}
insert into tb_menu value
(null,#{dish_name},#{dish_price},#{discription},
#{img},#{category_id})
update tb_menu set dish_name=#{dish_name},dish_price=#{dish_price},
discription=#{discription},img=#{img},category_id=#{category_id}
where id=#{id}
5、CategoryMapper
package com.qcby.dao;
import com.qcby.pojo.Category;
import java.util.List;
public interface CategoryMapper {
/** 1.查询所有菜单名信息 */
public List findAll();
}
CategoryMapper.xml
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 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接口的子类实例
@Autowired
OrderMapper orderMapper;
//获取DoorMapper接口的子类实例
@Autowired
DoorMapper doorMapper;
@Autowired
CashierMapper cashierMapper;
/** 1.查询所有订单信息 */
@RequestMapping("/orderList")
public String orderList( Model model ) {
//查询所有的订单信息,并将订单信息存入model中
List orderList = orderMapper.findAll();
model.addAttribute( "oList", orderList );
//同时查询所有的门店信息,并将门店信息存入model中
List doorList = doorMapper.findAll();
model.addAttribute( "dList", doorList );
List 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 doorList = doorMapper.findAll();
model.addAttribute( "dList", doorList );
List 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 doorList = doorMapper.findAll();
model.addAttribute( "dList", doorList );
List 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 {
@Autowired
CashierMapper cashierMapper;
@Autowired
DoorMapper doorMapper;
/** 1.查询所有订单信息 */
@RequestMapping("/cashierList")
public String orderList( Model model ) {
//查询所有的订单信息,并将订单信息存入model中
List cashierList = cashierMapper.findAll();
model.addAttribute( "cList", cashierList );
//同时查询所有的门店信息,并将门店信息存入model中
List 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 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 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接口的子类实例
@Autowired
MenuMapper menuMapper;
//获取DoorMapper接口的子类实例
@Autowired
CategoryMapper categoryMapper;
/** 1.查询所有订单信息 */
@RequestMapping("/menuList")
public String orderList( Model model ) {
//查询所有的订单信息,并将订单信息存入model中
List menuList = menuMapper.findAll();
model.addAttribute( "mList", menuList );
//同时查询所有的门店信息,并将门店信息存入model中
List 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 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 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 menuList = menuMapper.findByName(dish_name,discription);
System.out.println(menuList);
model.addAttribute( "mList", menuList );
List 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中找这个接口对应
* 的子类实例,找到之后会将接口的子类实例赋值给当前这个成员变量. */
@Autowired
DoorMapper doorMapper;
/* 2、测试ssm的运行环境 */
@RequestMapping("/testssm")
public String testssm() {
//查询所有的门店信息
List 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)
@ResponseBody
public ResponseEntity 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-sdfw
String 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);
}
}
1、管理页面(index.jsp、_top.jsp、_right.jsp、_left.jsp)
①index.jsp
<%@ page pageEncoding="utf-8"%>
②_top.jsp
<%@ page pageEncoding="utf-8"%>
雍禾门店管理系统
③_right.jsp
<%@ page pageEncoding="utf-8"%>
欢迎访问雍禾门店管理系统...
④_left.jsp
<%@ page pageEncoding="utf-8"%>
⑤页面效果
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" %>
门店管理
门店管理
序号
门店名称
联系电话
门店地址
操 作
${ vs.count }
${ door.name }
${ door.tel }
${ door.addr }
删除
|
修改
提示:删除门店同时会删除该门店下的所有订单!
页面效果:
②door_add.jsp
<%@ page pageEncoding="utf-8"%>
新增门店
新增门店
页面效果:
③door_update.jsp
<%@ page pageEncoding="utf-8"%>
修改门店
修改门店
页面效果:
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" %>
订单管理
订单管理
序号
所属门店
订单号
类型
人数
收银员
下单时间
结账时间
支付方式
金额
操 作
${ vs.count }
<%--
model.addAttribute( "dList", doorList );
在order对象中虽然没有记录所属的门店名称,但是有记录所属的门店编号
遍历门店集合,将每一个门店(${door.id})的编号,与订单中记录的所属门店编号(${order.doorId})
进行比较, 如果二者相等,就取出这个门店编号所对应的门店名称,显示在下面的td标签内部
--%>
${ door.id==order.doorId ? door.name : "" }
${ order.orderNo }
${ order.orderType }
${ order.pnum }
${ cashier.id==order.cashierId ? cashier.cname : "" }
${ order.payType }
${ order.price }
删除
|
修改
页面效果:
②order_add.jsp
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="c"
uri="http://java.sun.com/jsp/jstl/core" %>
新增订单
新增订单
页面效果:
③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" %>
修改订单
修改订单
页面效果:
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" %>
订单管理
收银员管理
序号
姓名
性别
年龄
联系电话
工作时间段
所属门店
操 作
${ vs.count }
${ cashier.cname }
${ cashier.gender }
${ cashier.age }
${ cashier.telephone }
${ cashier.work_time }
${ door.id==cashier.door_id ? door.name : "" }
删除
|
修改
页面效果:
②cashier_add.jsp
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="c"
uri="http://java.sun.com/jsp/jstl/core" %>
新增菜单
新增收银员
页面效果:
③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" %>
修改收银员信息
修改收银员信息
页面效果:
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" %>
菜单管理
<%-- --%>
<%-- --%>
菜单管理
序号
菜名
价格
描述
照片
类别
操 作
${ vs.count }
${ menu.dish_name }
${ menu.dish_price }
${ menu.discription }
${ menu.category_id==category.id ? category.category : "" }
删除
|
修改
页面效果:
②menu_add.jsp
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="c"
uri="http://java.sun.com/jsp/jstl/core" %>
新增菜单
新增菜单
页面效果:
③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" %>
修改菜单
修改订单
页面效果: