开发工具:idea (eclipse) 环境:jdk1.8 mysql5.7
博客导入教程:
https://blog.csdn.net/qq_22860341/article/details/89841188
idea导入更加简单,没有教程。注意mysql版本和jdk版本jdk1.8 mysql5.7
-- ----------------------------
-- Table structure for admin_user
-- ----------------------------
DROP TABLE IF EXISTS `admin_user`;
CREATE TABLE `admin_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`password` varchar(255) DEFAULT NULL,
`username` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of admin_user
-- ----------------------------
INSERT INTO `admin_user` VALUES ('1', 'admin', 'admin');
-- ----------------------------
-- Table structure for classification
-- ----------------------------
DROP TABLE IF EXISTS `classification`;
CREATE TABLE `classification` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cname` varchar(255) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
`type` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of classification
-- ----------------------------
INSERT INTO `classification` VALUES ('28', '国产水果', '0', '1');
INSERT INTO `classification` VALUES ('29', '国外水果', '0', '1');
INSERT INTO `classification` VALUES ('30', '热带水果', '0', '1');
INSERT INTO `classification` VALUES ('31', '瓜果类', '0', '1');
INSERT INTO `classification` VALUES ('32', '柑橘类', '0', '1');
INSERT INTO `classification` VALUES ('34', '桃李类', '0', '1');
INSERT INTO `classification` VALUES ('35', '热带水果', '0', '1');
INSERT INTO `classification` VALUES ('36', '桃子', '28', '2');
INSERT INTO `classification` VALUES ('37', '梨子', '28', '2');
INSERT INTO `classification` VALUES ('38', '哈密瓜', '28', '2');
INSERT INTO `classification` VALUES ('39', '橘子', '32', '2');
INSERT INTO `classification` VALUES ('40', '猕猴桃', '33', '2');
INSERT INTO `classification` VALUES ('41', '西瓜', '28', '2');
INSERT INTO `classification` VALUES ('42', '哈密瓜', '28', '2');
INSERT INTO `classification` VALUES ('43', '葡萄', '28', '2');
INSERT INTO `classification` VALUES ('44', '甜瓜', '28', '2');
-- ----------------------------
-- Table structure for order
-- ----------------------------
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`addr` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`order_time` datetime DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`state` int(11) DEFAULT NULL,
`total` double DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of order
-- ----------------------------
-- ----------------------------
-- Table structure for order_item
-- ----------------------------
DROP TABLE IF EXISTS `order_item`;
CREATE TABLE `order_item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`count` int(11) DEFAULT NULL,
`order_id` int(11) DEFAULT NULL,
`product_id` int(11) DEFAULT NULL,
`sub_total` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of order_item
-- ----------------------------
-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`csid` int(11) DEFAULT NULL,
`desc` varchar(1000) DEFAULT NULL,
`image` varchar(255) DEFAULT NULL,
`is_hot` int(11) DEFAULT NULL,
`market_price` double DEFAULT NULL,
`pdate` datetime DEFAULT NULL,
`shop_price` bigint(20) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of product
-- ----------------------------
INSERT INTO `product` VALUES ('30', '39', '甜蜜清香 用口感打动你的心', '/mall/admin/product/img/4C29D22E42290E22EA81298314A64A.jpg', '1', '23', '2019-05-18 16:43:04', '18', '展卉 广西沃柑 1.5kg 新鲜水果');
INSERT INTO `product` VALUES ('31', '39', '皮薄易剥 酸甜多汁', '/mall/admin/product/img/65DC54077844BE43AA0305035649A0.jpg', '1', '24', '2019-05-18 16:44:11', '16', '四川蒲江丑柑 丑橘不知火1.5kg装 新鲜水果');
INSERT INTO `product` VALUES ('32', '41', '清新甘甜 汁水充盈', '/mall/admin/product/img/97E498C5BA71436B51A9134C18AF19.jpg', '1', '56', '2019-05-18 16:46:58', '40', '海南麒麟西瓜 1个 单果重2.5kg-3.5kg 新鲜水果');
INSERT INTO `product` VALUES ('33', '44', '鲜甜爽口 香味浓郁', '/mall/admin/product/img/41922CCEB83AB193DACC8243F7452F.jpg', '1', '77', '2019-05-18 16:53:43', '56', '展卉 海南红心木瓜 2个装 单果重量约450-500g 新鲜水果');
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`addr` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
’
package priv.jesse.mall.web.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import priv.jesse.mall.entity.Order;
import priv.jesse.mall.entity.OrderItem;
import priv.jesse.mall.entity.pojo.ResultBean;
import priv.jesse.mall.service.OrderService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Controller
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
/**
* 打开订单列表页面
*
* @return
*/
@RequestMapping("/toList.html")
public String toOrderList() {
return "mall/order/list";
}
/**
* 查询用户订单列表
*
* @param request
* @return
*/
@RequestMapping("/list.do")
@ResponseBody
public ResultBean<List<Order>> listData(HttpServletRequest request) {
List<Order> orders = orderService.findUserOrder(request);
return new ResultBean<>(orders);
}
/**
* 查询订单详情
*
* @param orderId
* @return
*/
@RequestMapping("/getDetail.do")
@ResponseBody
public ResultBean<List<OrderItem>> getDetail(int orderId) {
List<OrderItem> orderItems = orderService.findItems(orderId);
return new ResultBean<>(orderItems);
}
/**
* 提交订单
*
* @param name
* @param phone
* @param addr
* @param request
* @param response
*/
@RequestMapping("/submit.do")
public void submit(String name,
String phone,
String addr,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
orderService.submit(name, phone, addr, request, response);
}
/**
* 支付方法
*
* @param orderId
*/
@RequestMapping("pay.do")
@ResponseBody
public ResultBean<Boolean> pay(int orderId, HttpServletResponse response) throws IOException {
orderService.pay(orderId);
return new ResultBean<>(true);
}
/**
* 确认收货
* @param orderId
* @param response
* @return
* @throws IOException
*/
@RequestMapping("receive.do")
@ResponseBody
public ResultBean<Boolean> receive(int orderId, HttpServletResponse response) throws IOException {
orderService.receive(orderId);
return new ResultBean<>(true);
}
}