1.数据库设计
1.用户表:用户Id(主键),登录名,登录密码,手机号,用户状态(0存在,1注销(数据不可用))
(增,删,改(修改信息,注销),查(查所有,按照编号、手机号进行查询))
3.管理员:管理员id,管理员密码,管理员权限(0管理用户,1管理司机,车辆,2管理订单和退款,评论等)
4.车辆信息表:车辆id(主键),司机id(外键),车牌号,车型,颜色,状态(0正常形式,1注销,2处理中),类别id(外键)
5.业务类别:类别id(主键),类别名称
6.订单表:订单id(主键),车辆id(外键),用户id(外键),订单创建时间,订单结束时间,起始位置,目的地,订单状态(0进行中,1取消,2 结束,3处理中),订单金额
7.退款记录表:记录表id,订单id,退款原因,退款开始时间,退款结束时间,记录表状态(0退款中,1退款成功,2退款失败),退款金额
8.评论表:评论表id,订单Id,评论时间,评论内容,回复内容,打分
关系:
1.订单表和用户表、车辆信息表是一对一
2.车辆信息表和司机表是多对一的关系
3.业务类别和车辆表是一对多的关系
4.退款记录表和订单表是一对一的关系
5.评论表和订单是多对一的关系
--用户表--
create table users
(
user_id number(4) not null,
user_name nvarchar2(10) not null,
user_password nvarchar2(20) not null,
user_phone nvarchar2(22) not null,
user_state nvarchar2(2) not null,
constraint PK_STUDENT primary key (user_id)
);
--司机表--
create table driver
(
driver_id number(4) not null,
driver_name nvarchar2(10) not null,
driver_idcard nvarchar2(20) not null,
driver_phone nvarchar2(11) not null,
driver_state nvarchar2(2) not null,
driver_service number(4) not null,
driver_amount nvarchar2(10) not null,
constraint PK_DRIVER primary key (driver_id)
);
--管理员表--
create table admin
(
admin_id number(4) not null,
admin_name nvarchar2(10) not null,
admin_password nvarchar2(20) not null,
admin_limits nvarchar2(2) not null,
constraint PK_ADMIN primary key (admin_id)
);
--汽车信息表--
create table car
(
car_id number(4) not null,
car_number nvarchar2(10) not null,
car_type nvarchar2(20) not null,
car_color nvarchar2(10) not null,
car_state nvarchar2(2) not null,
driver_id number(4) not null,
sort_id number(4) not null,
constraint PK_CAR primary key (car_id)
);
--业务类别表--
create table sort
(
sort_id number(4) not null,
sort_name nvarchar2(6) not null,
constraint PK_SORT primary key (sort_id)
);
--订单表--
create table orderform
(
orderform_id number(4) not null,
orderform_createdtime nvarchar2(30) not null,
orderform_finishedtime nvarchar2(30) not null,
orderform_startaddress nvarchar2(200) not null,
orderform_endaddress nvarchar2(200) not null,
orderform_state nvarchar2(2) not null,
orderform_money number(5,2) not null,
car_id number(4) not null,
user_id number(4) not null,
constraint PK_ORDER primary key (orderform_id)
);
--退款记录表--退款记录表:记录表id,订单id,退款原因,
--退款开始时间,退款结束时间,记录表状态(0退款中,1退款成功,2退款失败),退款金额
create table refund
(
refund_id number(4) not null,
refund_reason nvarchar2(100) not null,
refund_startedtime nvarchar2(50) not null,
refund_finishedtime nvarchar2(50) not null,
refund_state nvarchar2(20) not null,
refund_money number(8,2) not null,
orderform_id number(4) not null,
constraint PK_REFUND primary key (refund_id)
);
--评论表:评论表id,订单Id,评论时间,评论内容,回复内容,打分
create table comments(
comments_id number(4) not null,
comments_time nvarchar2(100) not null,
comments_context nvarchar2(1000) ,
comments_grade number(4,2) not null,
comments_reply nvarchar2(100),
orderform_id number(4) not null,
constraint PK_COMMENTS primary key (comments_id)
);
2.实体类编写及映射文件配置
package com.vo;
public class Car {
private int car_id;
private String car_number;
private String car_type;
private String car_color;
private String car_state;
private Driver driver;
private Sort sort;
public Car() {
super();
// TODO Auto-generated constructor stub
}
public Car(int car_id, String car_number, String car_type, String car_color, String car_state) {
super();
this.car_id = car_id;
this.car_number = car_number;
this.car_type = car_type;
this.car_color = car_color;
this.car_state = car_state;
}
public Car(int car_id, String car_number, String car_type, String car_color, String car_state, Driver driver,
Sort sort) {
super();
this.car_id = car_id;
this.car_number = car_number;
this.car_type = car_type;
this.car_color = car_color;
this.car_state = car_state;
this.driver = driver;
this.sort = sort;
}
// public Car(int car_id, String car_number, String car_type, String
// car_color, String car_state) {
// super();
// this.car_id = car_id;
// this.car_number = car_number;
// this.car_type = car_type;
// this.car_color = car_color;
// this.car_state = car_state;
// }
public int getCar_id() {
return car_id;
}
public void setCar_id(int car_id) {
this.car_id = car_id;
}
public String getCar_number() {
return car_number;
}
public void setCar_number(String car_number) {
this.car_number = car_number;
}
public String getCar_type() {
return car_type;
}
public void setCar_type(String car_type) {
this.car_type = car_type;
}
public String getCar_color() {
return car_color;
}
public void setCar_color(String car_color) {
this.car_color = car_color;
}
public String getCar_state() {
return car_state;
}
public void setCar_state(String car_state) {
this.car_state = car_state;
}
public String getCars_state() {
return car_state;
}
public void setCars_state(String car_state) {
this.car_state = car_state;
}
public Driver getDriver() {
return driver;
}
public void setDriver(Driver driver) {
this.driver = driver;
}
p