源码获取:俺的博客首页 "资源" 里下载!
项目介绍
本项目包含管理员与普通用户两种角色;
管理员角色包含以下功能:
管理员登录,添加角色信息,管理角色信息,添加用户信息,管理用户信息,车位信息管理,IC卡信息管理,出入库管理,停车信息管理,临时车辆入库管理,车辆出库管理,修改密码等功能。
用户角色包含以下功能:
用户登录,临时车辆入库管理,车辆出库管理,修改密码,修改个人信息等功能。
环境需要
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版本;
6.是否Maven项目: 否;
技术栈
1. 后端:servlet
2. 前端:JSP+Javascript+css+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/
用户账号/密码:user/123456
管理员账号/密码:admin/admin
用户管理控制层:
@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("/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";
}
}
管理员控制层:
@Controller
@RequestMapping("/admin")
public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
private ParkService parkService;
@Autowired
private NoticeService noticeService;
@Autowired
private OrderService orderService;
@Autowired
private UserService userService;
@Autowired
private MessageService messageService;
@RequestMapping("/login")
public String login(@ModelAttribute("admin") Admin admin,HttpSession session,Model model) {
admin = adminService.login(admin);
if(admin!=null) {
session.setAttribute("LogAdmin", admin);
return "admin/index";
}else {
model.addAttribute("msg", "用户名或密码错误");
return "admin/login";
}
}
@RequestMapping("/logout")
public String logout(HttpSession session) {
session.removeAttribute("LogAdmin");
return "admin/login";
}
//获取管理员列表
@RequestMapping("/admin-list")
public String getAllAdmin(Model model) {
List<Admin> adminList = adminService.getAllAdmin();
model.addAttribute("adminList",adminList);
model.addAttribute("adminNum",adminList.size());
return "admin/admin-list";
}
@RequestMapping("/findAdminByName")
public String getByName(@RequestParam("nameTmp")String name,Model model) {
List<Admin> adminList = adminService.getAdminByName(name);
model.addAttribute("adminList",adminList);
model.addAttribute("adminNum",adminList.size());
model.addAttribute("nameTmp",name);
return "admin/admin-list";
}
@RequestMapping("/admin-add")
public String addAdmin(){
return "admin/admin-add";
}
@ResponseBody
@RequestMapping("/admin-save")
public Map<String,String> saveAdmin(@ModelAttribute("admin") Admin admin){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(adminService.addAdmin(admin)) {
map.put("res", "0");
}
return map;
}
//删除管理员账号用过Id
@ResponseBody
@RequestMapping("/delAdmin")
public Map<String,String> delAdmin(@RequestParam("adminId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(adminService.delAdmin(id)) {
map.put("res", "0");
}
return map;
}
@RequestMapping("/change-info")
public String editAdmin(@RequestParam("adminId") int id,Model model){
Admin admin = adminService.getAdminById(id);
model.addAttribute("admin",admin);
return "admin/change-info";
}
@ResponseBody
@RequestMapping("/updateAdmin")
public Map<String,String> updateAdmin(Admin admin){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(adminService.updateAdmin(admin)) {
map.put("res", "0");
}
return map;
}
关于车位开始
//获取列表
@RequestMapping("/car-list")
public String getAllCar(Model model) {
List<Park> carList = parkService.getAll();
model.addAttribute("carList",carList);
model.addAttribute("carNum",carList.size());
return "car/car-list";
}
@RequestMapping("/findCarByKey")
public String findCarByKey(@RequestParam("keyTmp")String key,Model model) {
List<Park> carList = parkService.getByKey(key);
model.addAttribute("carList",carList);
model.addAttribute("carNum",carList.size());
model.addAttribute("keyTmp",key);
return "car/car-list";
}
@RequestMapping("/car-edit")
public String editCar(@RequestParam("carId") int id,Model model){
Park car = parkService.getById(id);
model.addAttribute("car",car);
return "car/car-edit";
}
@ResponseBody
@RequestMapping("/car-update")
public Map<String,String> saveMessage(@ModelAttribute("car") Park car){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(parkService.updateCar(car)) {
map.put("res", "0");
}
return map;
}
//删除
@ResponseBody
@RequestMapping("/delCar")
public Map<String,String> delCar(@RequestParam("carId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(parkService.delCar(id)) {
map.put("res", "0");
}
return map;
}
//跳转添加页
@RequestMapping("/car-add")
public String addCar(){
return "car/car-add";
}
//添加车次
@ResponseBody
@RequestMapping("/car-save")
public Map<String,String> carSave(@ModelAttribute("car") Park car){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(parkService.addCar(car)) {
map.put("res", "0");
}
return map;
}
//关于车位结束
//关于公告开始
//获取公告列表
@RequestMapping("/notice-list")
public String getAllNotice(Model model) {
List<Notice> noticeList = noticeService.getAll();
model.addAttribute("noticeList",noticeList);
model.addAttribute("noticeNum",noticeList.size());
return "notice/notice-list";
}
@RequestMapping("/findNoticeByTitle")
public String findNoticeByTitle(@RequestParam("titleTmp")String title,Model model) {
List<Notice> noticeList = noticeService.getByTitle(title);
model.addAttribute("noticeList",noticeList);
model.addAttribute("noticeNum",noticeList.size());
model.addAttribute("titleTmp",title);
return "notice/notice-list";
}
@RequestMapping("/notice-add")
public String addNotice(){
return "notice/notice-add";
}
@ResponseBody
@RequestMapping("/notice-save")
public Map<String,String> saveNotice(HttpSession session,@ModelAttribute("notice") Notice notice){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
Admin admin = (Admin)session.getAttribute("LogAdmin");
notice.setAdmin_id(admin.getId());
notice.setAdmin_name(admin.getName());
if(noticeService.addNotice(notice)) {
map.put("res", "0");
}
return map;
}
//删除
@ResponseBody
@RequestMapping("/delNotice")
public Map<String,String> delNotce(@RequestParam("noticeId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(noticeService.delNotice(id)) {
map.put("res", "0");
}
return map;
}
@RequestMapping("/notice-edit")
public String editNotice(@RequestParam("noticeId") int id,Model model){
Notice notice = noticeService.getById(id);
model.addAttribute("notice",notice);
return "notice/notice-edit";
}
//修改
@ResponseBody
@RequestMapping("/notice-update")
public Map<String,String> updateNotice(Notice notice){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(noticeService.updateNotice(notice)) {
map.put("res", "0");
}
return map;
}
///公告通知结束
///订单管理开始
//获取列表
@RequestMapping("/order-list")
public String getAllOrder(Model model) {
List<Order> orderList = orderService.getAll();
model.addAttribute("orderList",orderList);
model.addAttribute("orderNum",orderList.size());
return "order/order-list";
}
@RequestMapping("/findOrderByKey")
public String findOrderByKey(@RequestParam("keyTmp")String key,Model model) {
List<Order> orderList = orderService.getByKey(key);
model.addAttribute("orderList",orderList);
model.addAttribute("orderNum",orderList.size());
model.addAttribute("keyTmp",key);
return "order/order-list";
}
//删除
@ResponseBody
@RequestMapping("/delOrder")
public Map<String,String> delOrder(@RequestParam("orderId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(orderService.delOrder(id)) {
map.put("res", "0");
}
return map;
}
///订单管理结束
//积分管理开始
//后台获取积分列
@RequestMapping("/point-list")
public String getAllUserPoint(Model model) {
List<Users> pointList = userService.getAllPoint();
model.addAttribute("pointList",pointList);
model.addAttribute("pointNum",pointList.size());
return "point/point-list";
}
//后台获取积分列表模糊查
@RequestMapping("/findPointByName")
public String findPointByName(@RequestParam("nameTmp")String name,Model model) {
List<Users> pointList = userService.getPointByName(name);
model.addAttribute("pointList",pointList);
model.addAttribute("pointNum",pointList.size());
model.addAttribute("nameTmp",name);
return "point/point-list";
}
//积分管理结束
//用户管理开始
//后台模糊查询用户
@RequestMapping("/findUserByName")
public String findUserByName(@RequestParam("nameTmp")String name,Model model) {
List<Users> userList = userService.getByName(name);
model.addAttribute("userList",userList);
model.addAttribute("userNum",userList.size());
model.addAttribute("nameTmp",name);
return "user/user-list";
}
//后台获取用户列表
@RequestMapping("/user-list")
public String getAllUser(Model model) {
List<Users> userList = userService.getAll();
model.addAttribute("userList",userList);
model.addAttribute("userNum",userList.size());
return "user/user-list";
}
//停用用户账号用过Id
@ResponseBody
@RequestMapping("/stopUser")
public Map<String,String> stopAdmin(@RequestParam("userId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(userService.updateStautsById(id, 1)) {
map.put("res", "0");
}
return map;
}
//启用管理员账号用过Id
@ResponseBody
@RequestMapping("/startUser")
public Map<String,String> startAdmin(@RequestParam("userId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(userService.updateStautsById(id, 0)) {
map.put("res", "0");
}
return map;
}
用户管理结束
留言管理开始
//获取公告列表
@RequestMapping("/message-list")
public String getAllMessage(Model model) {
List<Message> messageList = messageService.getAll();
model.addAttribute("messageList",messageList);
model.addAttribute("messageNum",messageList.size());
return "message/message-list";
}
@RequestMapping("/findMessageByContent")
public String findMessageByContent(@RequestParam("contentTmp")String content,Model model) {
List<Message> messageList = messageService.getByContent(content);
model.addAttribute("messageList",messageList);
model.addAttribute("messageNum",messageList.size());
model.addAttribute("contentTmp",content);
return "message/message-list";
}
//管理员删除
@ResponseBody
@RequestMapping("/delMessage")
public Map<String,String> delMessage(@RequestParam("messageId") int id){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
if(messageService.delMessage(id)) {
map.put("res", "0");
}
return map;
}
//跳转留言回复页面
@RequestMapping("/answer-add")
public String addMessage(@RequestParam("messageId") int id,Model model){
model.addAttribute("messageId", id);
return "message/answer-add";
}
//回复留言
@ResponseBody
@RequestMapping("/answer-save")
public Map<String,String> answer(HttpSession session,@ModelAttribute("message") Message message){
Map<String,String> map = new HashMap<String,String>();
map.put("res", "1");
Admin admin = (Admin)session.getAttribute("LogAdmin");
message.setAdmin_id(admin.getId());
message.setAdmin_name(admin.getName());
if(messageService.updateMessage(message)) {
map.put("res", "0");
}
return map;
}
/留言管理结束
}
源码获取:俺的博客首页 "资源" 里下载!