• Java项目:SSM校园共享自行车出租管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    管理员角色包含以下功能:
    管理员登录,用户管理,服务点管理,共享单车管理,车辆分类管理,学生管理,自行车租赁管理,统计信息,密码修改等功能。

    居民角色包含以下功能:
    居民登录,基本信息查看等功能。

    环境需要

    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. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+EasyUI+BootStrap+jQuery

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入localhost:8080/ 登录

    运行截图

     

     

     

     

     

     

     

    相关代码

     管理员控制器

    1. package com.webike.web;
    2. import com.webike.dto.JsonResult;
    3. import com.webike.dto.Page;
    4. import com.webike.enums.ResultEnum;
    5. import com.webike.pojo.Admin;
    6. import com.webike.pojo.Place;
    7. import com.webike.service.AdminService;
    8. import com.webike.utils.MD5Util;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.ui.Model;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.RequestMethod;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import org.springframework.web.multipart.MultipartFile;
    16. import javax.servlet.http.HttpServletRequest;
    17. import javax.servlet.http.HttpSession;
    18. import java.util.Date;
    19. import java.util.List;
    20. /**管理员controller
    21. * Created by Ming on 2018/2/8.
    22. */
    23. @Controller
    24. @RequestMapping("/admin")
    25. public class AdminController {
    26. @Autowired
    27. private AdminService adminService;
    28. //跳转到首页
    29. @RequestMapping("/index")
    30. public String index(){
    31. return "index";
    32. }
    33. //验证登陆
    34. @RequestMapping(value = "/login",method = RequestMethod.POST)
    35. public String login(Admin admin, Model model, HttpSession session){
    36. String message = adminService.checkUserPwd(admin);
    37. if("成功".equals(message)) {
    38. //注入Session
    39. Admin realAdmin = adminService.findByUsername(admin.getaUsername());
    40. session.setAttribute("admin",realAdmin);
    41. //更新登陆的时间
    42. admin.setaLoginTime(new Date());
    43. admin.setaUpdateTime(new Date());
    44. admin.setaPassword(null);
    45. adminService.upDate(admin);
    46. return "redirect:index";
    47. }
    48. model.addAttribute("msg",message);
    49. return "forward:/login.jsp";
    50. }
    51. //退出登陆
    52. @RequestMapping("/logout")
    53. public String logout(HttpSession session){
    54. session.invalidate();
    55. return "redirect:/login.jsp";
    56. }
    57. //跳转到修改密码的页面
    58. @RequestMapping("/rePassword")
    59. public String rePassword(){
    60. return "rePassword";
    61. }
    62. //修改提交的密码
    63. @RequestMapping("/submitResetPwd")
    64. @ResponseBody
    65. public JsonResult submitResetPwd(String password, String newPassword,HttpSession httpSession){
    66. Admin admin = (Admin) httpSession.getAttribute("admin");
    67. if(!admin.getaPassword().equals(MD5Util.getMD5(password)))
    68. return new JsonResult(false,ResultEnum.OLD_PASSWORD_ERROR);
    69. admin.setaPassword(MD5Util.getMD5(newPassword));
    70. admin.setaUpdateTime(new Date());
    71. boolean isSuccess = adminService.upDate(admin);
    72. if(isSuccess) return new JsonResult(isSuccess, ResultEnum.UPDATE_SUCCESS);
    73. return new JsonResult(isSuccess, ResultEnum.UPDATE_FAIL);
    74. }
    75. //跳转到用户管理页面
    76. @RequestMapping("/adminManage")
    77. public String adminMange(){
    78. return "admin";
    79. }
    80. //显示用户页面
    81. @RequestMapping("/showAll")
    82. @ResponseBody
    83. public Page showAll(Integer page, Integer rows){
    84. return adminService.findAllToPage(page,rows);
    85. }
    86. //删除用户
    87. @RequestMapping("/remove")
    88. @ResponseBody
    89. public JsonResult remove(Integer aid){
    90. return adminService.deleteById(aid);
    91. }
    92. // 加载服务点到表单下拉框 loadPlace
    93. @RequestMapping("/loadPlace")
    94. @ResponseBody
    95. public List loadPlace(){
    96. return adminService.loadPlace();
    97. }
    98. //回显用户表单
    99. @RequestMapping("/loadForm")
    100. @ResponseBody
    101. public Admin loadForm(String username){
    102. Admin admin = adminService.findByUsername(username);
    103. return admin;
    104. }
    105. //addOrUpdate
    106. @RequestMapping("/addOrUpdate")
    107. @ResponseBody
    108. public JsonResult addOrUpdate(MultipartFile adminIcon, Admin admin, HttpServletRequest request){
    109. if(admin.getAid() == null) return adminService.add(adminIcon,admin,request);
    110. return adminService.update(adminIcon,admin,request);
    111. }
    112. }

    自行车控制器

    1. package com.webike.web;
    2. import com.webike.dto.JsonResult;
    3. import com.webike.dto.Page;
    4. import com.webike.pojo.Bike;
    5. import com.webike.pojo.Category;
    6. import com.webike.pojo.Student;
    7. import com.webike.service.BikeService;
    8. import com.webike.service.CategoryService;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.web.bind.annotation.RequestBody;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.RequestMethod;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import org.springframework.web.multipart.MultipartFile;
    16. import javax.servlet.http.HttpServletRequest;
    17. import java.util.*;
    18. /**
    19. * Created by Ming on 2018/2/10.
    20. */
    21. @Controller
    22. @RequestMapping("/bike")
    23. public class BikeController {
    24. @Autowired
    25. private BikeService bikeService;
    26. @Autowired
    27. private CategoryService categoryService;
    28. //跳转到 bike管理页面
    29. @RequestMapping("/bikeManage")
    30. public String bikeManage(){
    31. return "bike";
    32. }
    33. //添加或更新bike
    34. @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    35. @ResponseBody
    36. public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
    37. if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
    38. return bikeService.update(bikeIcon,bike,request);
    39. }
    40. //showAll bike
    41. @RequestMapping("/showAll")
    42. @ResponseBody
    43. public Page show(Integer page, Integer rows){
    44. return bikeService.findAllToPage(page,rows);
    45. }
    46. //删除单车和更新单车的分类
    47. @RequestMapping(value = "/remove",method = RequestMethod.POST)
    48. @ResponseBody
    49. public JsonResult remove(String bids,String cids){
    50. return bikeService.deleteById(bids,cids);
    51. }
    52. //点击修改回显bike弹出表单
    53. @RequestMapping("/loadForm")
    54. @ResponseBody
    55. public Bike loadForm(Integer bid){
    56. return bikeService.findById(bid);
    57. }
    58. //回显bike分类
    59. @RequestMapping(value = "/loadCategory",method = RequestMethod.POST)
    60. @ResponseBody
    61. public List loadCategory(){
    62. return categoryService.findAll();
    63. }
    64. }

    分类控制器

    1. package com.webike.web;
    2. import com.webike.dto.JsonResult;
    3. import com.webike.enums.ResultEnum;
    4. import com.webike.pojo.Category;
    5. import com.webike.service.CategoryService;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.RequestMethod;
    10. import org.springframework.web.bind.annotation.ResponseBody;
    11. import java.util.List;
    12. /**
    13. * Created by Ming on 2018/2/11.
    14. */
    15. @Controller
    16. @RequestMapping("/category")
    17. public class CategoryController {
    18. @Autowired
    19. private CategoryService categoryService;
    20. //跳转到category页面
    21. @RequestMapping("/categoryManage")
    22. public String categoryMange(){
    23. return "category";
    24. }
    25. //显示所有分类
    26. @RequestMapping("/showAll")
    27. @ResponseBody
    28. public List showAll(){
    29. return categoryService.findAll();
    30. }
    31. //添加或更新分类 addOrUpdate
    32. @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    33. @ResponseBody
    34. public JsonResult addOrUpdate(Category category){
    35. if(category == null) return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
    36. if(category.getCid() == null ) return categoryService.add(category);
    37. return categoryService.update(category);
    38. }
    39. //删除分类
    40. @RequestMapping(value = "/remove",method = RequestMethod.POST)
    41. @ResponseBody
    42. public JsonResult remove(Integer cid){
    43. return categoryService.deleteById(cid);
    44. }
    45. //回显分类的表单数据
    46. @RequestMapping("/loadForm")
    47. @ResponseBody
    48. public Category loadForm(Integer cid){
    49. return categoryService.findById(cid);
    50. }
    51. }

    订单控制器

    1. package com.webike.web;
    2. import com.webike.dto.JsonResult;
    3. import com.webike.dto.Page;
    4. import com.webike.pojo.Orders;
    5. import com.webike.pojo.Student;
    6. import com.webike.service.OrdersService;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.ResponseBody;
    11. /**
    12. * Created by Ming on 2018/2/13.
    13. */
    14. @Controller
    15. @RequestMapping("/orders")
    16. public class OrdersController {
    17. @Autowired
    18. OrdersService ordersService;
    19. //跳转到租赁管理页面
    20. @RequestMapping("/ordersManage")
    21. public String ordersMange(){
    22. return "orders";
    23. }
    24. //添加或修改订单
    25. @RequestMapping("/addOrUpdate")
    26. @ResponseBody
    27. public JsonResult addOrUpdate(Orders orders){
    28. if(orders.getOid() == null) return ordersService.add(orders);
    29. return ordersService.update(orders);
    30. }
    31. //点击修改按钮,加载订单表单
    32. @RequestMapping("/loadForm")
    33. @ResponseBody
    34. public Orders loadForm(Integer oid){
    35. return ordersService.findById(oid);
    36. }
    37. //显示所有的订单
    38. @RequestMapping("/showAll")
    39. @ResponseBody
    40. public Page show(Integer page, Integer rows){
    41. return ordersService.findAllToPage(page,rows);
    42. }
    43. //删除订单
    44. @RequestMapping("/remove")
    45. @ResponseBody
    46. public JsonResult remove(Integer oid,Integer oBid,String oState){
    47. return ordersService.deleteById(oid,oBid,oState);
    48. }
    49. }

    学生控制器

    1. package com.webike.web;
    2. import com.webike.dto.JsonResult;
    3. import com.webike.dto.Page;
    4. import com.webike.pojo.Student;
    5. import com.webike.service.StudentService;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.web.bind.annotation.RequestBody;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.RequestMethod;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import org.springframework.web.multipart.MultipartFile;
    13. import javax.servlet.http.HttpServletRequest;
    14. /**
    15. * Created by Ming on 2018/2/9.
    16. */
    17. @Controller
    18. @RequestMapping("/student")
    19. public class StudentController {
    20. @Autowired
    21. private StudentService studentService;
    22. //跳转到student管理 jsp页面
    23. @RequestMapping("/studentManage")
    24. public String studentManage(){
    25. return "student";
    26. }
    27. //添加或更新一个学生
    28. @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    29. @ResponseBody
    30. public JsonResult add(MultipartFile studentIcon, Student student, HttpServletRequest request){
    31. if(student.getSid() == null || "".equals(student.getSid()))
    32. return studentService.add(studentIcon,student,request);
    33. return studentService.update(studentIcon,student,request);
    34. }
    35. //显示所有的学生
    36. @RequestMapping("/showAll")
    37. @ResponseBody
    38. public Page show(Integer page,Integer rows){
    39. return studentService.findAllToPage(page,rows);
    40. }
    41. //删除一个学生
    42. @RequestMapping(value = "/remove",method = RequestMethod.POST)
    43. @ResponseBody
    44. public JsonResult remove( Integer sid){
    45. return studentService.removeById(sid);
    46. }
    47. //回显 指定一个student数据到student页面的弹出框表单中
    48. @RequestMapping("/loadForm")
    49. @ResponseBody
    50. public Student loadForm(Integer sid){
    51. return studentService.findById(sid);
    52. }
    53. }

    如果也想学习本系统,下面领取。关注并回复:170ssm 

  • 相关阅读:
    【C语言基础】Chap. 2. 基本概念
    浮点数计算精度问题decimal.js
    算法实战:亲自写红黑树之二 完整代码
    开发 Java 用小而美的框架,Solon v1.9.4 发布
    教务(选课)管理系统
    软件设计师:03-数据库系统
    第6讲:SQL语句之DQL类型的数据查询语言
    python基础语法(五)
    2022.11.10 vs每次都需要重新配置环境解决方案
    CH单库数据迁移到读写分离模式
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126435667