zx 5 years ago
parent 03b7d322b5
commit 386950e265

@ -10,16 +10,16 @@ Target Server Type : MYSQL
Target Server Version : 80018
File Encoding : 65001
Date: 2020-06-16 11:11:40
Date: 2020-06-22 23:19:39
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for book_list
-- Table structure for book
-- ----------------------------
DROP TABLE IF EXISTS `book`;
CREATE TABLE `book_list` (
CREATE TABLE `book` (
`bookname` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`kind` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`price` float(10,2) NOT NULL,
@ -27,12 +27,12 @@ CREATE TABLE `book_list` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ----------------------------
-- Records of book_list
-- Records of book
-- ----------------------------
INSERT INTO `book_list` VALUES ('全国计算机等级考试二级教程', '考试', '43.00');
INSERT INTO `book_list` VALUES ('别再叫我宠物猫', '小说', '12.50');
INSERT INTO `book_list` VALUES ('学在中国', '历史', '68.00');
INSERT INTO `book_list` VALUES ('小芳园诗草', '文学', '175.00');
INSERT INTO `book_list` VALUES ('社会史研究', '社会', '98.00');
INSERT INTO `book_list` VALUES ('统计热力学', '科学', '48.00');
INSERT INTO `book_list` VALUES ('计算机网络', '教育', '59.00');
INSERT INTO `book` VALUES ('全国计算机等级考试二级教程', '考试', '43.00');
INSERT INTO `book` VALUES ('别再叫我宠物猫', '小说', '12.50');
INSERT INTO `book` VALUES ('学在中国', '历史', '68.00');
INSERT INTO `book` VALUES ('小芳园诗草', '文学', '175.00');
INSERT INTO `book` VALUES ('社会史研究', '社会', '98.00');
INSERT INTO `book` VALUES ('统计热力学', '科学', '48.00');
INSERT INTO `book` VALUES ('计算机网络', '教育', '59.00');

@ -10,22 +10,23 @@ Target Server Type : MYSQL
Target Server Version : 80018
File Encoding : 65001
Date: 2020-06-16 11:11:52
Date: 2020-06-22 23:19:48
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for user_cart
-- Table structure for cart
-- ----------------------------
DROP TABLE IF EXISTS `cart`;
CREATE TABLE `user_cart` (
`username` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
CREATE TABLE `cart` (
`username` varchar(11) COLLATE utf8_unicode_ci NOT NULL,
`bookname` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`price` float(10,2) NOT NULL,
`count` int(11) NOT NULL
`count` int(11) NOT NULL,
PRIMARY KEY (`username`,`bookname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ----------------------------
-- Records of user_cart
-- Records of cart
-- ----------------------------

@ -10,24 +10,23 @@ Target Server Type : MYSQL
Target Server Version : 80018
File Encoding : 65001
Date: 2020-06-16 11:11:46
Date: 2020-06-23 00:20:11
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for order_details
-- Table structure for order
-- ----------------------------
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order_details` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bookname` varchar(100) NOT NULL,
`count` int(11) NOT NULL,
`price` float(10,2) NOT NULL,
`username` int(40) NOT NULL,
CREATE TABLE `order` (
`id` varchar(11) COLLATE utf8_unicode_ci NOT NULL,
`username` varchar(11) COLLATE utf8_unicode_ci NOT NULL,
`ortime` date NOT NULL,
`state` int(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ----------------------------
-- Records of order_details
-- Records of order
-- ----------------------------

@ -10,15 +10,15 @@ Target Server Type : MYSQL
Target Server Version : 80018
File Encoding : 65001
Date: 2020-06-16 11:11:57
Date: 2020-06-22 23:20:03
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for user_list
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user_list`;
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`username` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
@ -27,6 +27,6 @@ CREATE TABLE `user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ----------------------------
-- Records of user_list
-- Records of user
-- ----------------------------
INSERT INTO `user_list` VALUES ('admin1', 'admin1', '1');
INSERT INTO `user` VALUES ('admin1', 'admin1', '1');

@ -7,13 +7,13 @@ import org.springframework.stereotype.Repository;
@Repository
@Mapper
public interface CartMapper {
@Insert("insert into user_cart values (#{username},#{bookname})")
@Insert("insert into cart values (#{username},#{bookname})")
int insertItem(String username,String bookname);
@Delete("delete from user_cart where username=#{username}")
@Delete("delete from cart where username=#{username}")
void clearCart(String username);
@Select("select * from user_cart where username=#{username}")
@Select("select * from cart where username=#{username}")
Cart queryByName(String username);
@Update({"update user_cart set username=#{username}", "update user_cart set bookname=#{bookname}", "update user_cart set count=#{count}"})
@Update({"update cart set username=#{username}", "update user_cart set bookname=#{bookname}", "update user_cart set count=#{count}"})
int updateCount(String username,String bookname,int count);
}

@ -1,9 +1,19 @@
package com.book.demo.mapper;
import com.book.demo.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.Date;
@Mapper
@Repository
public interface OrderMapper {
@Select("select * from order where username=#{username}")
Order[] getOrderByName(String username);
@Insert("insert into order (username,date,state) values(#{username},#{date},0)")
int createOrder(String username, Date data);
}

@ -1,6 +1,6 @@
server.port=8099
server.port=8090
spring.datasource.url=jdbc:mysql://localhost:3306/bookstore?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
spring.datasource.url=jdbc:mysql://localhost:3306/test02?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root

Loading…
Cancel
Save