【停车场车辆管理系统】从零搭建——数据库搭建

【停车场车辆管理系统】从零搭建——项目分析

【停车场车辆管理系统】从零搭建——数据库搭建

【停车场车辆管理系统】从零搭建——后端搭建

【停车场车辆管理系统】从零搭建——后端Model类

【停车场车辆管理系统】从零搭建——Mapper搭建

【停车场车辆管理系统】从零搭建——AdminController搭建

【停车场车辆管理系统】从零搭建——UserController搭建

【停车场车辆管理系统】从零搭建——前端react搭建

文章目录

  • 建立数据库
  • 车主表
  • 小区表
  • 管理员表
  • 汽车表
  • 车位表
  • 申请表
  • 订单表
  • 完整数据库代码
    • 仅结构
    • 结构和数据

上一篇已经提到了数据库的设计,这篇就把数据库设计具体搭建出来。
这个数据库里面我已经添加了数据,insert部分可以不执行,当然执行了也没问题,各位依照自己选择酌情删减。

建立数据库

create database vehicle_management;

首先创建一个vehicle_management数据,然后选中这个数据库

use vehicle_mmanagement;

车主表

车主:id、姓名、手机号、所在小区、详细住址、密码,账号就用手机号

首先创建一个车主的表:

CREATE TABLE `user` (
  `userId` int(11) NOT NULL AUTO_INCREMENT,
  `userName` varchar(36) DEFAULT NULL COMMENT '姓名',
  `userPhone` varchar(36) DEFAULT NULL COMMENT '手机号',
  `cityId` int(11) DEFAULT NULL COMMENT '所在小区id',
  `userAddress` varchar(36) DEFAULT NULL COMMENT '详细住址',
  `userPassword` varchar(36) DEFAULT NULL COMMENT '密码',
  PRIMARY KEY (`userId`),
  UNIQUE KEY `user_userId_uindex` (`userId`)
);

往表里填点数据进去

INSERT INTO `user` VALUES (1,'测试数据111','111',1,'1','111'),(2,'2','222',1,'222','222'),(3,'3','333',2,'333','333');

【停车场车辆管理系统】从零搭建——数据库搭建_第1张图片
可以看到,其中有一个cityId,这个字段需要关联到一个存储小区的表格中去,所以下面创建一个小区表

小区表

小区:id、小区名

小区表很简单,只有一个id和小区名称

CREATE TABLE `city` (
  `cityId` int(11) NOT NULL AUTO_INCREMENT,
  `cityName` varchar(36) DEFAULT NULL COMMENT '小区名称',
  PRIMARY KEY (`cityId`),
  UNIQUE KEY `city_cityId_uindex` (`cityId`)
) ;

添加一点数据

INSERT INTO `city` VALUES (1,'小区1'),(2,'小区2'),(3,'小区3'),(4,'小区4'),(5,'小区5');

【停车场车辆管理系统】从零搭建——数据库搭建_第2张图片

管理员表

管理员:id、姓名、手机号、密码、所管理小区

CREATE TABLE `admin` (
  `adminId` int(11) NOT NULL AUTO_INCREMENT,
  `adminName` varchar(36) DEFAULT NULL  COMMENT '姓名',
  `adminPhone` varchar(36) DEFAULT NULL COMMENT '手机号',
  `adminPassword` varchar(36) DEFAULT NULL COMMENT '密码',
  `cityId` int(11) DEFAULT NULL COMMENT '所管理小区id',
  PRIMARY KEY (`adminId`),
  UNIQUE KEY `admin_adminId_uindex` (`adminId`)
) ;

添加一点数据

INSERT INTO `admin` VALUES (1,'管理员11','1','1',1),(2,'2','2','2',2);

在这里插入图片描述
然后车主需要有车,加一张汽车表

汽车表

车辆:id、车牌号、属于哪个车主

CREATE TABLE `car` (
  `carId` int(11) NOT NULL AUTO_INCREMENT,
  `carNumber` varchar(36) DEFAULT NULL COMMENT '车牌号',
  `userId` int(11) DEFAULT NULL COMMENT '属于哪个车主',
  PRIMARY KEY (`carId`),
  UNIQUE KEY `car_carId_uindex` (`carId`)
);

INSERT INTO `car` VALUES (1,'123',1),(5,'123123',1),(6,'1',1),(7,'2',1),(8,'3',1);
 

【停车场车辆管理系统】从零搭建——数据库搭建_第3张图片
小区还需要一些车位

车位表

车位:id、车位编号、属于哪个小区、是否已被占用、承包费用、停车费用

CREATE TABLE `park` (
  `parkId` int(11) NOT NULL AUTO_INCREMENT,
  `parkNumber` varchar(36) DEFAULT NULL COMMENT '车位编号',
  `cityId` int(11) DEFAULT NULL COMMENT '所属小区id',
  `parkState` int(11) DEFAULT '0' COMMENT '是否被占用:0-空闲 1-被承包 2-被停车 3-被删除',
  `rentPrice` decimal(10,2) DEFAULT NULL COMMENT '承包价格',
  `parkingPrice` decimal(10,2) DEFAULT NULL COMMENT '停车价格',
  `carId` int(11) DEFAULT '0',
  PRIMARY KEY (`parkId`),
  UNIQUE KEY `park_parkId_uindex` (`parkId`)
);
INSERT INTO `park` VALUES (1,'1',1,1,200.00,2.00,1),(2,'2',1,0,200.00,1.00,0),(3,'3',1,2,11.00,1.00,5),(4,'4',1,0,11.00,1.00,0),(5,'5',1,0,55.00,5.00,0); 

【停车场车辆管理系统】从零搭建——数据库搭建_第4张图片

车主进行车位承包的时候需要提交申请,创建一张申请表

申请表

车位承包信息:id、车位id、车辆id、车主id、承包申请是否通过

CREATE TABLE `rentapplication` (
  `rentApplicationId` int(11) NOT NULL AUTO_INCREMENT,
  `parkId` int(11) DEFAULT NULL COMMENT '车位id',
  `carId` int(11) DEFAULT NULL COMMENT '车辆id',
  `userId` int(11) DEFAULT NULL COMMENT '车主id',
  `rentApplicationState` int(11) DEFAULT '0' COMMENT '申请是否通过:0-待审批 1-同意 2-拒绝',
  PRIMARY KEY (`rentApplicationId`),
  UNIQUE KEY `rentApplication_rentApplicationId_uindex` (`rentApplicationId`)
);
INSERT INTO `rentapplication` VALUES (1,1,1,1,1),(2,2,6,1,2);
 

在这里插入图片描述车主进行停车的时候还需要收费,创建一张订单表

订单表

停车订单:id、车位id、车辆id、车主id、费用、日期、是否缴费、类型(承包/停车)

CREATE TABLE `parkingorder` (
  `parkingOrderId` int(11) NOT NULL AUTO_INCREMENT,
  `parkId` int(11) DEFAULT NULL COMMENT '车位id',
  `carId` int(11) DEFAULT NULL COMMENT '车辆id',
  `userId` int(11) DEFAULT NULL COMMENT '车主id',
  `parkingOrderPrice` decimal(10,2) DEFAULT NULL COMMENT '费用',
  `parkingTime` datetime DEFAULT NULL COMMENT '停车时间',
  `expirationTime` datetime DEFAULT NULL COMMENT '终止时间',
  `parkingOrderState` int(11) DEFAULT NULL COMMENT '停车类型:0-承包 1-停车',
  `payState` int(11) DEFAULT '0' COMMENT '是否缴费:0-未交费 1-已缴费',
  `cityId` int(11) DEFAULT NULL,
  PRIMARY KEY (`parkingOrderId`),
  UNIQUE KEY `parkingOrder_parkingOrderId_uindex` (`parkingOrderId`)
);
INSERT INTO `parkingorder` VALUES (1,1,1,1,24.00,'2022-03-11 00:17:47','2022-03-12 01:07:31',1,1,1),(2,2,5,1,1.00,'2022-03-11 23:29:18','2022-03-12 01:03:54',1,1,1),(3,3,6,1,0.00,'2022-03-12 00:12:10','2022-03-12 00:58:23',1,1,1),(4,1,1,1,2.00,'2022-03-12 01:21:29','2022-03-12 04:06:00',1,1,1),(5,1,1,1,200.00,'2022-03-12 23:04:29','2022-04-11 23:04:29',0,1,1),(6,3,5,1,0.00,'2022-03-12 23:13:30','2022-03-12 23:21:28',1,0,1);

【停车场车辆管理系统】从零搭建——数据库搭建_第5张图片

完整数据库代码

仅结构

/*
 Navicat Premium Data Transfer

 Source Server         : 主机
 Source Server Type    : MySQL
 Source Server Version : 80028
 Source Host           : localhost:3306
 Source Schema         : vehicle_management

 Target Server Type    : MySQL
 Target Server Version : 80028
 File Encoding         : 65001

 Date: 13/05/2022 16:48:22
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin`  (
  `adminId` int NOT NULL AUTO_INCREMENT,
  `adminName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
  `adminPhone` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
  `adminPassword` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
  `cityId` int NULL DEFAULT NULL COMMENT '所管理小区id',
  PRIMARY KEY (`adminId`) USING BTREE,
  UNIQUE INDEX `admin_adminId_uindex`(`adminId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for car
-- ----------------------------
DROP TABLE IF EXISTS `car`;
CREATE TABLE `car`  (
  `carId` int NOT NULL AUTO_INCREMENT,
  `carNumber` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车牌号',
  `userId` int NULL DEFAULT NULL COMMENT '属于哪个车主',
  PRIMARY KEY (`carId`) USING BTREE,
  UNIQUE INDEX `car_carId_uindex`(`carId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for city
-- ----------------------------
DROP TABLE IF EXISTS `city`;
CREATE TABLE `city`  (
  `cityId` int NOT NULL AUTO_INCREMENT,
  `cityName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '小区名称',
  PRIMARY KEY (`cityId`) USING BTREE,
  UNIQUE INDEX `city_cityId_uindex`(`cityId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for park
-- ----------------------------
DROP TABLE IF EXISTS `park`;
CREATE TABLE `park`  (
  `parkId` int NOT NULL AUTO_INCREMENT,
  `parkNumber` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车位编号',
  `cityId` int NULL DEFAULT NULL COMMENT '所属小区id',
  `parkState` int NULL DEFAULT 0 COMMENT '是否被占用:0-空闲 1-被承包 2-被停车 3-被删除',
  `rentPrice` decimal(10, 2) NULL DEFAULT NULL COMMENT '承包价格',
  `parkingPrice` decimal(10, 2) NULL DEFAULT NULL COMMENT '停车价格',
  `carId` int NULL DEFAULT 0,
  PRIMARY KEY (`parkId`) USING BTREE,
  UNIQUE INDEX `park_parkId_uindex`(`parkId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for parkingorder
-- ----------------------------
DROP TABLE IF EXISTS `parkingorder`;
CREATE TABLE `parkingorder`  (
  `parkingOrderId` int NOT NULL AUTO_INCREMENT,
  `parkId` int NULL DEFAULT NULL COMMENT '车位id',
  `carId` int NULL DEFAULT NULL COMMENT '车辆id',
  `userId` int NULL DEFAULT NULL COMMENT '车主id',
  `parkingOrderPrice` decimal(10, 2) NULL DEFAULT NULL COMMENT '费用',
  `parkingTime` datetime NULL DEFAULT NULL COMMENT '停车时间',
  `expirationTime` datetime NULL DEFAULT NULL COMMENT '终止时间',
  `parkingOrderState` int NULL DEFAULT NULL COMMENT '停车类型:0-承包 1-停车',
  `payState` int NULL DEFAULT 0 COMMENT '是否缴费:0-未交费 1-已缴费',
  `cityId` int NULL DEFAULT NULL,
  PRIMARY KEY (`parkingOrderId`) USING BTREE,
  UNIQUE INDEX `parkingOrder_parkingOrderId_uindex`(`parkingOrderId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for rentapplication
-- ----------------------------
DROP TABLE IF EXISTS `rentapplication`;
CREATE TABLE `rentapplication`  (
  `rentApplicationId` int NOT NULL AUTO_INCREMENT,
  `parkId` int NULL DEFAULT NULL COMMENT '车位id',
  `carId` int NULL DEFAULT NULL COMMENT '车辆id',
  `userId` int NULL DEFAULT NULL COMMENT '车主id',
  `rentApplicationState` int NULL DEFAULT 0 COMMENT '申请是否通过:0-待审批 1-同意 2-拒绝',
  PRIMARY KEY (`rentApplicationId`) USING BTREE,
  UNIQUE INDEX `rentApplication_rentApplicationId_uindex`(`rentApplicationId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `userId` int NOT NULL AUTO_INCREMENT,
  `userName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
  `userPhone` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
  `cityId` int NULL DEFAULT NULL COMMENT '所在小区id',
  `userAddress` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '详细住址',
  `userPassword` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
  PRIMARY KEY (`userId`) USING BTREE,
  UNIQUE INDEX `user_userId_uindex`(`userId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

结构和数据

/*
 Navicat Premium Data Transfer

 Source Server         : 主机
 Source Server Type    : MySQL
 Source Server Version : 80028
 Source Host           : localhost:3306
 Source Schema         : vehicle_management

 Target Server Type    : MySQL
 Target Server Version : 80028
 File Encoding         : 65001

 Date: 13/05/2022 16:48:46
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin`  (
  `adminId` int NOT NULL AUTO_INCREMENT,
  `adminName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
  `adminPhone` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
  `adminPassword` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
  `cityId` int NULL DEFAULT NULL COMMENT '所管理小区id',
  PRIMARY KEY (`adminId`) USING BTREE,
  UNIQUE INDEX `admin_adminId_uindex`(`adminId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of admin
-- ----------------------------
INSERT INTO `admin` VALUES (1, '管理员11', '1', '1', 1);
INSERT INTO `admin` VALUES (2, '2', '2', '2', 2);

-- ----------------------------
-- Table structure for car
-- ----------------------------
DROP TABLE IF EXISTS `car`;
CREATE TABLE `car`  (
  `carId` int NOT NULL AUTO_INCREMENT,
  `carNumber` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车牌号',
  `userId` int NULL DEFAULT NULL COMMENT '属于哪个车主',
  PRIMARY KEY (`carId`) USING BTREE,
  UNIQUE INDEX `car_carId_uindex`(`carId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of car
-- ----------------------------
INSERT INTO `car` VALUES (1, '123', 1);
INSERT INTO `car` VALUES (5, '123123', 1);
INSERT INTO `car` VALUES (6, '1', 1);
INSERT INTO `car` VALUES (7, '2', 1);
INSERT INTO `car` VALUES (8, '3', 1);

-- ----------------------------
-- Table structure for city
-- ----------------------------
DROP TABLE IF EXISTS `city`;
CREATE TABLE `city`  (
  `cityId` int NOT NULL AUTO_INCREMENT,
  `cityName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '小区名称',
  PRIMARY KEY (`cityId`) USING BTREE,
  UNIQUE INDEX `city_cityId_uindex`(`cityId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of city
-- ----------------------------
INSERT INTO `city` VALUES (1, '小区1');
INSERT INTO `city` VALUES (2, '小区2');
INSERT INTO `city` VALUES (3, '小区3');
INSERT INTO `city` VALUES (4, '小区4');
INSERT INTO `city` VALUES (5, '小区5');

-- ----------------------------
-- Table structure for park
-- ----------------------------
DROP TABLE IF EXISTS `park`;
CREATE TABLE `park`  (
  `parkId` int NOT NULL AUTO_INCREMENT,
  `parkNumber` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车位编号',
  `cityId` int NULL DEFAULT NULL COMMENT '所属小区id',
  `parkState` int NULL DEFAULT 0 COMMENT '是否被占用:0-空闲 1-被承包 2-被停车 3-被删除',
  `rentPrice` decimal(10, 2) NULL DEFAULT NULL COMMENT '承包价格',
  `parkingPrice` decimal(10, 2) NULL DEFAULT NULL COMMENT '停车价格',
  `carId` int NULL DEFAULT 0,
  PRIMARY KEY (`parkId`) USING BTREE,
  UNIQUE INDEX `park_parkId_uindex`(`parkId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of park
-- ----------------------------
INSERT INTO `park` VALUES (1, '1', 1, 1, 200.00, 2.00, 1);
INSERT INTO `park` VALUES (2, '2', 1, 0, 200.00, 1.00, 0);
INSERT INTO `park` VALUES (3, '3', 1, 2, 11.00, 1.00, 5);
INSERT INTO `park` VALUES (4, '4', 1, 0, 11.00, 1.00, 0);
INSERT INTO `park` VALUES (5, '5', 1, 0, 55.00, 5.00, 0);

-- ----------------------------
-- Table structure for parkingorder
-- ----------------------------
DROP TABLE IF EXISTS `parkingorder`;
CREATE TABLE `parkingorder`  (
  `parkingOrderId` int NOT NULL AUTO_INCREMENT,
  `parkId` int NULL DEFAULT NULL COMMENT '车位id',
  `carId` int NULL DEFAULT NULL COMMENT '车辆id',
  `userId` int NULL DEFAULT NULL COMMENT '车主id',
  `parkingOrderPrice` decimal(10, 2) NULL DEFAULT NULL COMMENT '费用',
  `parkingTime` datetime NULL DEFAULT NULL COMMENT '停车时间',
  `expirationTime` datetime NULL DEFAULT NULL COMMENT '终止时间',
  `parkingOrderState` int NULL DEFAULT NULL COMMENT '停车类型:0-承包 1-停车',
  `payState` int NULL DEFAULT 0 COMMENT '是否缴费:0-未交费 1-已缴费',
  `cityId` int NULL DEFAULT NULL,
  PRIMARY KEY (`parkingOrderId`) USING BTREE,
  UNIQUE INDEX `parkingOrder_parkingOrderId_uindex`(`parkingOrderId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of parkingorder
-- ----------------------------
INSERT INTO `parkingorder` VALUES (1, 1, 1, 1, 24.00, '2022-03-11 00:17:47', '2022-03-12 01:07:31', 1, 1, 1);
INSERT INTO `parkingorder` VALUES (2, 2, 5, 1, 1.00, '2022-03-11 23:29:18', '2022-03-12 01:03:54', 1, 1, 1);
INSERT INTO `parkingorder` VALUES (3, 3, 6, 1, 0.00, '2022-03-12 00:12:10', '2022-03-12 00:58:23', 1, 1, 1);
INSERT INTO `parkingorder` VALUES (4, 1, 1, 1, 2.00, '2022-03-12 01:21:29', '2022-03-12 04:06:00', 1, 1, 1);
INSERT INTO `parkingorder` VALUES (5, 1, 1, 1, 200.00, '2022-03-12 23:04:29', '2022-04-11 23:04:29', 0, 1, 1);
INSERT INTO `parkingorder` VALUES (6, 3, 5, 1, 0.00, '2022-03-12 23:13:30', '2022-03-12 23:21:28', 1, 0, 1);

-- ----------------------------
-- Table structure for rentapplication
-- ----------------------------
DROP TABLE IF EXISTS `rentapplication`;
CREATE TABLE `rentapplication`  (
  `rentApplicationId` int NOT NULL AUTO_INCREMENT,
  `parkId` int NULL DEFAULT NULL COMMENT '车位id',
  `carId` int NULL DEFAULT NULL COMMENT '车辆id',
  `userId` int NULL DEFAULT NULL COMMENT '车主id',
  `rentApplicationState` int NULL DEFAULT 0 COMMENT '申请是否通过:0-待审批 1-同意 2-拒绝',
  PRIMARY KEY (`rentApplicationId`) USING BTREE,
  UNIQUE INDEX `rentApplication_rentApplicationId_uindex`(`rentApplicationId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of rentapplication
-- ----------------------------
INSERT INTO `rentapplication` VALUES (1, 1, 1, 1, 1);
INSERT INTO `rentapplication` VALUES (2, 2, 6, 1, 2);

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `userId` int NOT NULL AUTO_INCREMENT,
  `userName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
  `userPhone` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
  `cityId` int NULL DEFAULT NULL COMMENT '所在小区id',
  `userAddress` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '详细住址',
  `userPassword` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
  PRIMARY KEY (`userId`) USING BTREE,
  UNIQUE INDEX `user_userId_uindex`(`userId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, '测试数据111', '111', 1, '1', '111');
INSERT INTO `user` VALUES (2, '2', '222', 1, '222', '222');
INSERT INTO `user` VALUES (3, '3', '333', 2, '333', '333');

SET FOREIGN_KEY_CHECKS = 1;

你可能感兴趣的:(数据库,database,mysql)