数据库课程设计——火车票售票系统

很烦数据库课程设计?阅读本篇文章会让你不那么烦躁~

话不多说先放源代码:
https://github.com/shadowings-zy/TrainTicketsSystem

由于数据库部署在了我自己的服务器上,所以如果各位想要修改源代码,或者搭建自己的系统,请自行根据下文的表结构搭建数据库,并且修改Beans.xml中数据库连接的部分。

其中train-tickets-back-end为后台工程文件。
train-tickets-front-end为前端工程文件。

系统开发平台:

开发工具:eclipse,webstorm
开发语言:Java,HTML,CSS,JavaScript
数据库:MySQL
中间件:tomcat 8.0
后台框架:SpringMVC
前端框架:React(前端只是做了一个展示,不是很重要)

系统功能:

在本系统中,前端和后台使用json进行数据交互,下面的每一个功能均对应着一个接口,括号中为接口的URL,具体实现可以参考源代码。

用户层面:

添加用户,即注册。(/register)
根据用户名和密码获取用户的所有信息,即登录。 (/login)
修改用户。 (/updateUser)

订单层面:

添加订单,在本系统中添加订单就意味着锁定座位。(/lockSeat)
修改订单。(/updateOrder)
删除订单。(/deleteOrder)
根据用户ID获取订单信息。(/queryOrder)

火车层面:

根据车站获取列车ID。(/getTrainByStop)
根据列车ID获取列车信息。(/getTrainByTrainId)
列车换乘查询。(/getTransfer)
查询列车座位剩余。(/getRemainSeats)
查询所有通列车的城市。(/getAllCities)

数据库设计(表结构加表数据):

用户表:

火车表:

火车经停车站表:

火车状态表(是否停运):

火车座次表:

订单表:

难点SQL语句设计:

以下SQL语句均基于上述表结构进行的设计,数据库名为12307

//根据起至车站查询火车
select a.train_id, train_name, a.stop_id as start_index, b.stop_id as end_index, a.station_name as start, b.station_name as end, a.arrive_time as start_time, b.arrive_time as end_time, (b.mileage - a.mileage) as mileage
from `12307`.stop as a,`12307`.stop as b,`12307`.train as c
where a.city_name = '沈阳' and b.city_name = '济南' and a.stop_id < b.stop_id and a.train_id = b.train_id and a.train_id = c.train_id and a.train_id not in (select train_idfrom `12307`.statuswhere date = '2019-12-12' and status = '停运')
//根据起至车站查询换乘火车
select a.train_id as first_tid, d.train_id as second_tid, e.train_name as first_tname, f.train_name as second_tname, b.station_name as transfer_station
from `12307`.stop as a, `12307`.stop as b, `12307`.stop as c, `12307`.stop as d, `12307`.train as e, `12307`.train as f
where a.city_name = '广州' and d.city_name = '长春' and a.train_id = b.train_id and b.station_name = c.station_name and c.train_id = d.train_id and b.train_id <> c.train_id and a.stop_id < b.stop_id and c.stop_id < d.stop_id and b.arrive_time < c.arrive_time
and a.train_id not in (select train_id from `12307`.status where date = '2019-10-10' and status = '停运')
and d.train_id not in (select train_id from `12307`.status where date = '2019-10-10' and status = '停运')
and a.train_id = e.train_id and d.train_id = f.train_id
//查询余票数量
select t.train_id, s.seat_type, count(s.seat_type)
from `12307`.train as t, `12307`.seat as s
where t.train_id = 5 and t.train_id = s.train_id and s.seat_id not in (select seat_idfrom `12307`.orderwhere train_id = 5 and date = '2019-01-02' and ((start_stop_id >= 2 and start_stop_id < 3) or (end_stop_id > 2 and end_stop_id <= 3)))
group by s.seat_type
//查询余票具体座位情况
select t.train_id, s.seat_id, s.carriage, s.seat_type, s.seat_location
from `12307`.train as t, `12307`.seat as s
where t.train_id = 1 and t.train_id = s.train_id and s.seat_id not in (select seat_idfrom `12307`.orderwhere train_id = 1 and date = '2019-01-01' and ((start_stop_id >= 0 and start_stop_id < 2) or (end_stop_id > 0 and end_stop_id <= 2)))
//锁定座位(实际上就是插入一条订单)
insert into `12307`.order (user_id, passenger_id, user_name, train_id, carriage, seat_type, seat_id, seat_location, start_stop_id, start_station_name, end_stop_id, end_station_name, date, create_at, status) values ('1', '000000000000000001', 'user1', '1', '1', '一等座', '0', '01A', '0', '沈阳北', 2, '深圳北', '2019-01-01', '2018-12-31 12:00:00', '未付款')

重点后台接口及返回样例:

注:所有请求的参数都为string类型,请求类型均为post请求,请求均可以跨域。

1、/login
请求参数:

{username, password
}

返回结果:

{content: "{"idcard":"1","password":"123","status":"正常","telephone":"12","userId":"1","userName":"user1"}", discription: "successful", statusCode: "1000"}

2、/register
请求参数:

{username, password,idcard,telephone
}

返回结果:

{content: "{"idcard":"4","password":"123","status":"正常","telephone":"4","userId":"303","userName":"user4"}", discription: "successful", statusCode: "1000"}

3、/updateUser
请求参数:

{username, password,idcard,telephone
}

返回结果:

{content: "{"idcard":"4","password":"123","status":"正常","telephone":"4","userId":"303","userName":"user4"}", discription: "successful", statusCode: "1000"}

4、/queryOrder
请求参数:

{idcard
}

返回结果:

{content: "[{"carriage":"1","createAt":"2018-12-31","date":"2…trainName":"G5","userId":"1","userName":"user1"}]", discription: "successful", statusCode: "1000"}

5、/deleteOrder
请求参数:

{orderId
}

返回结果:

{content: "修改成功", discription: "successful", statusCode: "1000"}

6、/getTrainByStop
请求参数:

{fromCity,toCity,date
}

返回结果:

{content: "[{"end":"沈阳北","endIndex":"4","endTime":"17:00:00",…"trainId":"5","trainName":"G5","trainType":"高铁"}]", discription: "successful", statusCode: "1000"}

7、/getTransfer
请求参数:

{fromCity,toCity,date
}

返回结果:

{content: "[{"firstTid":"5","firstTname":"G5","secondTid":"3","secondTname":"G3","transferStation":"沈阳北"}]", discription: "successful", statusCode: "1000"}

8、/getRemainSeats
请求参数:

{trainId,date,fromStopId,toStopId
}

返回结果:

{content: "[{"carriage":"1","seatId":"0","seatLocation":"01A"…tId":"17","seatLocation":"02F","seatType":"二等座"}]", discription: "successful", statusCode: "1000"}

9、/lockSeat
请求参数:

 {userId,passengerId,userName,trainId,trainName,carriage,seatType,seatId,seatLocation,startTime,startStopId,startStationName,endStopId,endStationName,date,createAt,status
}

返回结果:

{content: "{"carriage":"2","createAt":"2018-12-31","date":"20…"trainName":"G1","userId":"1","userName":"user1"}", discription: "successful", statusCode: "1000"}

项目结构:

controller中的三个类分别对应着:
user相关的接口,order相关的接口和train相关的接口。

model.order,model.train,model.user分别对应着:
订单类实现及相关数据查询方法,火车类实现及相关数据查询方法和用户类实现及相关数据查询方法。

test中的SQLTest类是测试所有sql语句的方法。

tools中的两个类包含了对HTTP请求进行处理的方法。

Beans.xml包含了spring框架和jdbc的基本配置。

WebContent中的test.html是用来调试接口的界面。

部署须知:

前端页面的开发需要安装node.js
之后进入train-tickets-front-end文件夹,输入npm install, 然后输入npm run start
访问localhost:3000即可进行开发。

前端页面部署需要先输入npm run build打包前端页面。
然后将打包出的build文件夹中的全部文件放到train-tickets-back-end/WebContent文件夹中。

最后进行后台的部署,将train-tickets-back-end项目打包成war文件后,直接丢到tomcat里。
向localhost:8080/TrainTickets/xxx (xxx为对应的接口)发起post请求就可以了。

项目截图

数据库课程设计——MySQL火车票售票系统相关推荐

  1. 汽车站订票系统mysql实验_数据库课程设计报告-车站售票管理系统

    数据库课程设计报告-车站售票管理系统 吉林工程技术师范学院 课程设计报告 设计名称: 车站售票信息管理系统 姓 名: 孟祥丽 学 号: 23号 专 业: 计算机科学与技术 班 级: C1042 院 系 ...

  2. 大学生数据库课程设计之学生选课系统(一个超级简单的系统)

    大学数据库课程设计–一个简单的学生选课系统 一.系统简介 一个超级简单的学生选课系统,使用Windows窗体设计界面,使用C#语言实现各种功能,数据库使用的是SQL.由于时间原因,做的非常仓促,系统中 ...

  3. 数据库课程设计:图书借阅系统(Java+MySQL)

    应粉丝要求,出个借阅系统swing版的,时间有些赶,可能还存在一些bug,不过不要紧,发现bug提给我,我逐个去修复与完善程序. 问题描述 实现简易版图书借阅管理系统,学生(读者)在系统里可以检索图书 ...

  4. 数据库课程设计·淘宝购物系统

    数据库大作业·淘宝购物系统 对接支付宝网站支付·仅支持PC端 在线体验地址:https://mysql.cxyepoch.cn 1.前台: ①商品列表可通过左右隐藏按钮进行轮换. ②用户未登陆时显示未 ...

  5. 山东大学数据库课程设计火车票系统报告

    数据库课程设计报告 ​ ----火车票订票系统 ​ ​​ 学院: 专业: 班级: 姓名: 学号: 目录 一.系统开发平台 3 二.数据库规划 3 2.1  任务陈述 3 2.2  任务目标 3 三.系 ...

  6. 数据库课程设计--淘宝购物订单系统

    数据库课程设计–淘宝订单系统 也不知道那个憨批给我改的鸟名,孩他妈只能一个月一改,我服了. 过几天写个java版本的出来,php写的感觉技术含量太低,效率也低 前台:https://mysql.cxy ...

  7. oracle学生考勤,Oracle数据库课程设计――学生考勤系统的Oracle实现1

    Oracle数据库课程设计――学生考勤系统的Oracle实现1 辽宁工程技术大学 Oracle数据库课程设计报告 学生考勤系统 姓 名: XXXXX 班 级: 计SJ08-1班 学 号: 完成日期: ...

  8. 数据库课程设计——火车票售票系统

    摘要 数据库课程设计的题目,设计了一个火车票售票系统,实现了列车信息查询,车票查询及购买,订单查询,个人信息管理等功能,数据是从12306爬取的真实数据. 项目链接 前端项目链接:https://gi ...

  9. jsp mysql火车票预定系统_火车票网络订票售票系统的设计与实现(NetBeans,MySQL)

    火车票网络预订售票系统的设计与实现(NetBeans,MySQL)(任务书,开题报告,中期检查表,文献综述,毕业论文16000字,程序代码,MySQL数据库) 本文针对火车站的售票实际情况,按照软件工 ...

最新文章

  1. 如何优雅的使用 Angular 表单验证
  2. 大数据分布式集群搭建(8)
  3. 人工智能艺术:一场前所未有的新艺术创造
  4. 前端学习(2539):节点类型
  5. 【Flink】flink sql的并行度怎么单独设置
  6. 网上图书商城项目学习笔记-008修改密码功能
  7. 水土不服?谈一谈机器学习在金融风控实践经验
  8. Leetcode每日一题:122.best-time-to-buy-and-sell-stock-ii(买股票的最佳时机Ⅱ)
  9. Android Webview 设置Cookie问题
  10. AD7705在STM32F103RBT6上的移植[硬件SPI]
  11. linux系统可以下steam吗,linux – 是否可以使用optirun运行Steam游戏?
  12. java生成短连接(调用新浪微博api生成)
  13. 计算机二级MS office(word 01)
  14. EasyExcel表头校验,表内容校验
  15. Mac配置item2高亮颜色
  16. 例题5.20 秦始皇修路 LA5713
  17. 数字VR虚拟博物馆的功能介绍
  18. 解决git每次提交代码都要输入帐号密码
  19. 我不看好中移动充当4G急先锋
  20. C++ 实现判断插入USB的设备是U盘,移动硬盘,光驱

热门文章

  1. 【北京-知春路】这10家公司值得你加入
  2. Redis分布式锁实现原理
  3. iOS汇编基础(二)寄存器
  4. php wps 读取word内容,PHP-如何使用PHP解析WPS格式的Excel文档
  5. 教你纯手工制作代码删除顽固文件,再也不用文件粉碎工具了。
  6. (附源码)计算机毕业设计SSM教师业绩考核和职称评审系统
  7. 计蒜客T1068救援
  8. shopee选品技巧有哪些?另类选品技巧及角度让你轻松“爆单”
  9. C#学习之帧校验序列码FCS
  10. 计算机办公类常用excel,[计算机软件及应用]办公常用EXCEL大全.ppt