作者主页:舒克日记
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文中获取源码
课题意义:
功能:
用户端:首页、查车位、预定车位、个人中心、订单管理、留言管理
管理员端:信息发布管理、车位管理、订单管理、积分管理、投诉建议管理、系统管理
1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat7.x,8.X,9.x版本均可
4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;
5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目
6.数据库:MySql5.7/8.0等版本均可;
1.使用Navicati或者其它工具,在mysql中创建对应sq文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;
idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:
http://mtw.so/5MHvZq
源码地址:http://codegym.top。
ParkController
package com.imust.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.imust.entity.Park;
import com.imust.entity.Order;
import com.imust.entity.Users;
import com.imust.service.ParkService;
import com.imust.service.UserService;
import com.imust.service.OrderService;
@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<Park> 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<Park> carList = parkService.getAll();
model.addAttribute("carList",carList);
}else {
List<Park> 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";
}
}
MessageController
package com.imust.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.imust.entity.Message;
import com.imust.entity.Users;
import com.imust.service.MessageService;
@Controller
@RequestMapping("/message")
public class MessageController {
@Autowired
private MessageService messageService;
//添加留言
@RequestMapping("/message-save")
public String saveMessage(HttpSession session,@ModelAttribute("message") Message message,Model model){
Users user = (Users)session.getAttribute("LogUser");
message.setUser_id(user.getId());
message.setUser_name(user.getName());
messageService.addMessage(message);
List<Message> messageList = messageService.getMyMessage(user.getId());
model.addAttribute("messageList", messageList);
return "myMessage";
}
//用户删除
@RequestMapping("/delMsg")
public String delMsg(HttpSession session,@RequestParam("id") int id,Model model){
messageService.delMessage(id);
Users user = (Users)session.getAttribute("LogUser");
List<Message> messageList = messageService.getMyMessage(user.getId());
model.addAttribute("messageList", messageList);
return "myMessage";
}
@RequestMapping("/myMessage")
public String myMessage(@RequestParam("id") int id,Model model){
List<Message> messageList = messageService.getMyMessage(id);
model.addAttribute("messageList", messageList);
return "myMessage";
}
}