基于javaweb的停车位预定管理系统(java+jsp+javascript+html+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的停车位预定管理系统(java+JSP+JavaScript+HTML+Mysql)
项目介绍
管理员角色包含以下功能: 管理员登录页面,车位信息管理,停车位信息管理,系统帮助管理,注册用户管理,留言信息管理,预定信息管理等功能。
用户角色包含以下功能: 用户首页,用户登录,查看系统通知,发表留言,预定停车位,个人信息管理,查看我的预定信息等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;
技术栈
HTML+CSS+JavaScript+jsp+mysql
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/login.jsp 登录
用户管理控制层:
@Controller
@RequestMapping(“/user”)
public class UserController {
@Autowired
private UserService userService;
//登陆
@RequestMapping(“/login”)
public String login(@ModelAttribute(“users”) Users users,HttpSession session,Model model) {
Users user = userService.login(users);
if(user!=null) {
if(user.getStauts()==0) {
session.setAttribute(“LogUser”, user);
return “redirect:/index”;
}else {
model.addAttribute(“msg”, “该用户已被停用”);
}else {
model.addAttribute(“msg”, “用户名或密码错误”);
return “join”;
//查看个人信息
@RequestMapping(“/user-show”)
public String getById(@RequestParam(“id”)int id,Model model) {
Users userinfo = userService.getUserById(id);
model.addAttribute(“userinfo”,userinfo);
return “user-show”;
@RequestMapping(“/logout”)
public String logout(HttpSession session) {
session.removeAttribute(“LogUser”);
return “/join”;
//注册用户
@RequestMapping(“/user-save”)
public String saveUser(@ModelAttribute(“users”) Users users){
if(userService.addUser(users)) {
return “register-ok”;
return “404”;
//修改用户手机和邮箱
@RequestMapping(“/update-user”)
public String userUpdate(@ModelAttribute(“users”) Users user,Model model){
userService.updateUser(user);
Users userinfo = userService.getUserById(user.getId());
model.addAttribute(“userinfo”,userinfo);
return “user-show”;
//修改密码页
@RequestMapping(“/password”)
public String password() {
return “password”;
//修改密码
@RequestMapping(“/updatePwd”)
public String updatePwd(Model model,@RequestParam(“id”) int id,@RequestParam(“newpassword”) String newpassword,@RequestParam(“oldpassword”) String oldpassword) {
Users userinfo = userService.getUserById(id);
if(oldpassword.equals(userinfo.getPassword())) {
userinfo.setPassword(newpassword);
if(userService.updateUserPwd(userinfo)) {
return “redirect:/user/logout”;
}else {
model.addAttribute(“usermsg”,“原密码错误”);
return “password”;
订单管理控制层:
@Controller
@RequestMapping(“/order”)
public class OrderController {
@Autowired
private OrderService orderService;
@Autowired
private ParkService parkService;
//获取列表
@RequestMapping(“/showOrder”)
public String showOrder(Model model,HttpSession session) {
Users user = (Users)session.getAttribute(“LogUser”);
List orderList = orderService.getByUserId(user.getId());
model.addAttribute(“orderList”,orderList);
return “orderList”;
//获取列表
@RequestMapping(“/jiesuan”)
public String jiesuanOrder(@RequestParam(“id”) int id) {
Order order = orderService.getById(id);
order.setStatus(1);
if(orderService.updateOrderStatus(order)) {
Park park = parkService.getById(order.getPark_id());
park.setStatus(0);
parkService.updateCarStatus(park);
return “redirect:/order/showOrder”;
停车位管理控制层:
@Controller
@RequestMapping(“/car”)
public class ParkController {
@Autowired
private ParkService parkService;
@Autowired
private OrderService orderService;
@Autowired
private UserService userService;
@RequestMapping(“/car-select”)
public String getCarByKey(Model model) {
List carList = parkService.getAll();
model.addAttribute(“carList”,carList);
model.addAttribute(“carNum”,carList.size());
return “list”;
@RequestMapping(“/findCar”)
public String findCar(@RequestParam(“status”) int status,Model model) {
model.addAttribute(“status”,status);
if(status==-1) {
List carList = parkService.getAll();
model.addAttribute(“carList”,carList);
}else {
List carList = parkService.getAllByKey(status);
model.addAttribute(“carList”,carList);
model.addAttribute(“carNum”,carList.size());
return “list”;
@RequestMapping(“/detail”)
public String editCar(@RequestParam(“id”) int id,Model model){
Park car = parkService.getById(id);
model.addAttribute(“car”,car);
return “detail”;
@RequestMapping(“/buy”)
public String buy(HttpSession session,@RequestParam(“id”) int id){
Park car = parkService.getById(id);
Users user = (Users)session.getAttribute(“LogUser”);
int p = user.getPoint();
car.setStatus(1);
if(parkService.updateCarStatus(car)) {
Order order =new Order();
order.setUser_id(user.getId());
order.setPark_id(id);
if(p>=100&&p<300) {
order.setTotal(car.getPrice()*0.9);
}else if(p>=300&&p<500) {
order.setTotal(car.getPrice()*0.8);
}else if(p>=500) {
order.setTotal(car.getPrice()*0.7);
if(orderService.addOrder(order)) {
user.setPoint(p+10);
userService.updatePoint(user);
return “redirect:/order/showOrder”;