SSM+Mysql实现的共享单车管理系统(功能包含分角色,登录、用户管理、服务点管理、单车管理、分类管理、学生信息管理、单车租赁、信息统计、系统设置等)

SSM+Mysql实现的共享单车管理系统

本系统一个学校共享单车管理的项目,通过线上系统化的管理,可以为后续的运营以及单车的项目运转提供极大的帮助。
(文末查看完整源码)

实现功能截图

用户登录在这里插入图片描述
用户管理‘
在这里插入图片描述
服务点管理
在这里插入图片描述
单车管理
在这里插入图片描述
分类管理
在这里插入图片描述
学生信息管理
在这里插入图片描述
单车租赁
在这里插入图片描述
信息统计汇总
在这里插入图片描述
更改密码
在这里插入图片描述

系统功能

本系统实现了以下功能:
1、登录
2、用户管理
3、服务点管理
4、单车管理
5、单车租赁
6、学生信息管理
7、分类管理
8、信息统计汇总
9、系统设置

使用技术

数据库:mysql
开发工具:Idea(Myeclispe、Eclipse也可以)
知识点:SSM

项目结构
在这里插入图片描述

代码

java端
实体类
Admin.java

package com.webike.pojo;

import java.util.Date;

public class Admin {
    private Integer aid;

    private Integer aPid;

    private Place place;

    private String aUsername;

    private String aPassword;

    private String aRealName;

    private String aPhone;

    private String aRole;

    private String aIcon;

    private Date aLoginTime;

    private Date aCreateTime;

    private Date aUpdateTime;

    private String aComment;

    public Place getPlace() {
        return place;
    }

    public void setPlace(Place place) {
        this.place = place;
    }

    public Integer getAid() {
        return aid;
    }

    public void setAid(Integer aid) {
        this.aid = aid;
    }

    public Integer getaPid() {
        return aPid;
    }

    public void setaPid(Integer aPid) {
        this.aPid = aPid;
    }

    public String getaUsername() {
        return aUsername;
    }

    public void setaUsername(String aUsername) {
        this.aUsername = aUsername == null ? null : aUsername.trim();
    }

    public String getaPassword() {
        return aPassword;
    }

    public void setaPassword(String aPassword) {
        this.aPassword = aPassword == null ? null : aPassword.trim();
    }

    public String getaRealName() {
        return aRealName;
    }

    public void setaRealName(String aRealName) {
        this.aRealName = aRealName == null ? null : aRealName.trim();
    }

    public String getaPhone() {
        return aPhone;
    }

    public void setaPhone(String aPhone) {
        this.aPhone = aPhone == null ? null : aPhone.trim();
    }

    public String getaRole() {
        return aRole;
    }

    public void setaRole(String aRole) {
        this.aRole = aRole == null ? null : aRole.trim();
    }

    public String getaIcon() {
        return aIcon;
    }

    public void setaIcon(String aIcon) {
        this.aIcon = aIcon == null ? null : aIcon.trim();
    }

    public Date getaLoginTime() {
        return aLoginTime;
    }

    public void setaLoginTime(Date aLoginTime) {
        this.aLoginTime = aLoginTime;
    }

    public Date getaCreateTime() {
        return aCreateTime;
    }

    public void setaCreateTime(Date aCreateTime) {
        this.aCreateTime = aCreateTime;
    }

    public Date getaUpdateTime() {
        return aUpdateTime;
    }

    public void setaUpdateTime(Date aUpdateTime) {
        this.aUpdateTime = aUpdateTime;
    }

    public String getaComment() {
        return aComment;
    }

    public void setaComment(String aComment) {
        this.aComment = aComment == null ? null : aComment.trim();
    }

    @Override
    public String toString() {
        return "Admin{" +
                "aid=" + aid +
                ", aPid=" + aPid +
                ", place=" + place +
                ", aUsername='" + aUsername + '\'' +
                ", aPassword='" + aPassword + '\'' +
                ", aRealName='" + aRealName + '\'' +
                ", aPhone='" + aPhone + '\'' +
                ", aRole='" + aRole + '\'' +
                ", aIcon='" + aIcon + '\'' +
                ", aLoginTime=" + aLoginTime +
                ", aCreateTime=" + aCreateTime +
                ", aUpdateTime=" + aUpdateTime +
                ", aComment='" + aComment + '\'' +
                '}';
    }
}

Bike,java

package com.webike.pojo;

import java.util.Date;

public class Bike {
    private Integer bid;

    private String bName;

    private String bIcon;

    private Integer bCid;

    private String bInTime;

    private String bState;

    private Date bCreateTime;

    private Date bUpdateTime;

    private String bComment;

    public Integer getBid() {
        return bid;
    }

    public void setBid(Integer bid) {
        this.bid = bid;
    }

    public String getbName() {
        return bName;
    }

    public void setbName(String bName) {
        this.bName = bName == null ? null : bName.trim();
    }

    public String getbIcon() {
        return bIcon;
    }

    public void setbIcon(String bIcon) {
        this.bIcon = bIcon == null ? null : bIcon.trim();
    }

    public Integer getbCid() {
        return bCid;
    }

    public void setbCid(Integer bCid) {
        this.bCid = bCid;
    }

    public String getbInTime() {
        return bInTime;
    }

    public void setbInTime(String bInTime) {
        this.bInTime = bInTime == null ? null : bInTime.trim();
    }

    public String getbState() {
        return bState;
    }

    public void setbState(String bState) {
        this.bState = bState == null ? null : bState.trim();
    }

    public Date getbCreateTime() {
        return bCreateTime;
    }

    public void setbCreateTime(Date bCreateTime) {
        this.bCreateTime = bCreateTime;
    }

    public Date getbUpdateTime() {
        return bUpdateTime;
    }

    public void setbUpdateTime(Date bUpdateTime) {
        this.bUpdateTime = bUpdateTime;
    }

    public String getbComment() {
        return bComment;
    }

    public void setbComment(String bComment) {
        this.bComment = bComment == null ? null : bComment.trim();
    }
}

service层
AdminServiceImpl.java

package com.webike.service.impl;

import com.webike.dao.AdminMapper;
import com.webike.dao.PlaceMapper;
import com.webike.dto.JsonResult;
import com.webike.dto.Page;
import com.webike.enums.ResultEnum;
import com.webike.enums.RoleEnum;
import com.webike.pojo.*;
import com.webike.service.AdminService;
import com.webike.utils.FileUtil;
import com.webike.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Date;
import java.util.List;

/**
 * Created by Ming on 2018/2/9.
 */
@Service
    public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Autowired
    private PlaceMapper placeMapper;
    @Override
    public String checkUserPwd(Admin admin) {
//        String password = MD5Util.getMD5(admin.getaPassword());
        String password = admin.getaPassword();
        Admin realAdmin = findByUsername(admin.getaUsername());
        if(realAdmin != null ){
            if(password.equals(realAdmin.getaPassword())){
                return "成功";
            }
            return "密码错误~";
        }
        return "没有此账号~";
    }

    @Override
    public boolean upDate(Admin admin) {
        AdminExample adminExample = new AdminExample();
        adminExample.createCriteria().andAUsernameEqualTo(admin.getaUsername());
        int i = adminMapper.updateByExampleSelective(admin, adminExample);
        return i > 0 ? true : false;
    }

    @Override
    public Admin findByUsername(String username) {
        AdminExample adminExample = new AdminExample();
        adminExample.createCriteria().andAUsernameEqualTo(username);
        List<Admin> admins = adminMapper.selectByExample(adminExample);
        if(admins != null && admins.size() > 0){
            Admin admin = admins.get(0);
            //pid不为空设置站点对象
            if(admin.getaPid() != null) {
                admin.setPlace(placeMapper.selectByPrimaryKey(admin.getaPid()));
            }
            return admin;
        }
        return null;
    }

    @Override
    public Page<Admin> findAllToPage(Integer page, Integer rows) {

        Page<Admin> aPage = new Page<>();
        List<Admin> lists = adminMapper.findToPage((page-1)*rows,rows);
        aPage.setRows(lists);
        aPage.setTotal(adminMapper.countByExample(new AdminExample()));
        return aPage;
    }

    @Override
    public JsonResult deleteById(Integer aid) {
        if (aid == null) return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        int i = adminMapper.deleteByPrimaryKey(aid);
        return i > 0 ? new JsonResult(true, ResultEnum.DELETE_SUCCESS)
                : new JsonResult(false, ResultEnum.DELETE_FAIL);
    }

    @Override
    public List<Place> loadPlace() {
        List<Place> places = placeMapper.selectByExample(new PlaceExample());
        return places;
    }

    @Override
    public JsonResult add(MultipartFile adminIcon, Admin admin, HttpServletRequest request) {
        if(!adminIcon.isEmpty()){
            String path = FileUtil.uploadImage(adminIcon, "adminIcon", request);
            if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
            admin.setaIcon(path);
        }
        if(admin.getaRole() == null) admin.setaRole(RoleEnum.MANAGER.getMassage());
        admin.setaPassword(MD5Util.getMD5(admin.getaPassword()));
        admin.setaCreateTime(new Date());
        admin.setaUpdateTime(new Date());
        try{
            int  row = adminMapper.insertSelective(admin);
            return row > 0 ? new JsonResult(true, ResultEnum.ADD_SUCCESS)
                    : new JsonResult(false, ResultEnum.ADD_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.REPEAT_ERROR);
        }
    }

    @Override
    public JsonResult update(MultipartFile adminIcon, Admin admin, HttpServletRequest request) {
        try{
            if(!adminIcon.isEmpty()){
                //更新首先要先删除原来的文件
                if(admin.getaIcon() != null){
                    File file = new File(request.getServletContext().getRealPath("/" + admin.getaIcon()));
                    if(file != null) file.delete();
                }
                String path = FileUtil.uploadImage(adminIcon, "adminIcon", request);
                if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
                admin.setaIcon(path);
            }
            admin.setaUpdateTime(new Date());
            int i = adminMapper.updateByPrimaryKeySelective(admin);
            return i > 0 ? new JsonResult(false, ResultEnum.UPDATE_SUCCESS)
                    : new JsonResult(false, ResultEnum.UPDATE_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        }
    }


}

BikeControllerImpl.java

package com.webike.service.impl;

import com.webike.dao.BikeMapper;
import com.webike.dto.JsonResult;
import com.webike.dto.Page;
import com.webike.enums.BikeStateEnum;
import com.webike.enums.ResultEnum;
import com.webike.pojo.Bike;
import com.webike.pojo.BikeExample;
import com.webike.service.BikeService;
import com.webike.service.CategoryService;
import com.webike.utils.ArithmeticUtil;
import com.webike.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.*;

/**
 * Created by Ming on 2018/2/10.
 */
@Service
public class BikeControllerImpl implements BikeService {
    @Autowired
    private BikeMapper bikeMapper;

    @Autowired
    private CategoryService categoryService;

    //事务控制 该单车分类剩余量+1
    @Transactional
    @Override
    public JsonResult add(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount) {
        if(!bikeIcon.isEmpty()){
            String path = FileUtil.uploadImage(bikeIcon, "bikeIcon", request);
            if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
            bike.setbIcon(path);
        }
        bike.setbState(BikeStateEnum.AVAILABLE.getState());
        bike.setbCreateTime(new Date());
        bike.setbUpdateTime(new Date());
        try{
            int row = 0;
            for (int i = 0; i < bCount; i++) {
                row += bikeMapper.insertSelective(bike);
            }
            if(row == bCount){
                return categoryService.updateRemainById(bike.getbCid(),bCount) ?
                        new JsonResult(true, ResultEnum.ADD_SUCCESS):new JsonResult(false, ResultEnum.ADD_FAIL);
            }else{
                throw new RuntimeException();
            }
        }catch (Exception e){
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return new JsonResult(false,ResultEnum.SYSTEM_ERROR);
        }

    }

    @Override
    public JsonResult update(MultipartFile bikeIcon, Bike bike, HttpServletRequest request) {
        try{
            if(!bikeIcon.isEmpty()){
                //更新首先要先删除原来的文件
                if(bike.getbIcon() != null){
                    File file = new File(request.getServletContext().getRealPath("/" + bike.getbIcon()));
                    if(file != null) file.delete();
                }
                String path = FileUtil.uploadImage(bikeIcon, "bikeIcon", request);
                if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
                bike.setbIcon(path);
            }
            bike.setbUpdateTime(new Date());
            int i = bikeMapper.updateByPrimaryKeySelective(bike);
            return i > 0 ? new JsonResult(false, ResultEnum.UPDATE_SUCCESS)
                    : new JsonResult(false, ResultEnum.UPDATE_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        }
    }

    @Override
    public Page<Bike> findAllToPage(Integer page, Integer rows) {
        Page<Bike> bPage = new Page<>();
        List<Bike> lists = bikeMapper.findToPage((page-1)*rows,rows);
        bPage.setRows(lists);
        bPage.setTotal(bikeMapper.countByExample(new BikeExample()));
        return bPage;
    }
    //事务控制 该单车的分类剩余量减size
    @Transactional
    @Override
    public JsonResult deleteById(String bids,String cids) {
        try{
            String[] bidList = bids.split(",");
            String[] cidList = cids.split(",");

            int row = 0;
            for (int i = 0; i < bidList.length; i++) {
                row += bikeMapper.deleteByPrimaryKey(Integer.parseInt(bidList[i]));
            }
            if(row == bidList.length){ //更新分类表的剩余数量
                HashMap<String, Integer> cidMap = ArithmeticUtil.getElementForTimes(cidList);
                Set<Map.Entry<String, Integer>> entries = cidMap.entrySet();
                for (Map.Entry<String, Integer> entry : entries) {
                    boolean isSuccess = categoryService.updateRemainById(Integer.parseInt(entry.getKey()), - entry.getValue());
                    if(!isSuccess) throw new RuntimeException();
                }
                return new JsonResult(true, ResultEnum.DELETE_SUCCESS);
            }else{
                throw new RuntimeException();
            }
        }catch (Exception e){
            e.printStackTrace();
//            throw new RuntimeException(e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return new JsonResult(false,ResultEnum.SYSTEM_ERROR);
        }
    }

    @Override
    public Bike findById(Integer bid) {
        return bikeMapper.selectByPrimaryKey(bid);
    }



}

controller层
AdminController.java

package com.webike.web;

import com.webike.dto.JsonResult;
import com.webike.dto.Page;
import com.webike.enums.ResultEnum;
import com.webike.pojo.Admin;
import com.webike.pojo.Place;
import com.webike.service.AdminService;
import com.webike.utils.MD5Util;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**管理员controller
 * Created by Ming on 2018/2/8.
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    //跳转到首页
    @RequestMapping("/index")
    public String index(){
        return "index";
    }


    //验证登陆
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String login(Admin admin, Model model, HttpSession session){
        String message = adminService.checkUserPwd(admin);
        if("成功".equals(message)) {
            //注入Session
            Admin realAdmin = adminService.findByUsername(admin.getaUsername());

            session.setAttribute("admin",realAdmin);
            //更新登陆的时间
            admin.setaLoginTime(new Date());
            admin.setaUpdateTime(new Date());
            admin.setaPassword(null);
            adminService.upDate(admin);
            return "redirect:index";
        }

        model.addAttribute("msg",message);
        return "forward:/login.jsp";
    }
    //退出登陆
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:/login.jsp";
    }

    //跳转到修改密码的页面
    @RequestMapping("/rePassword")
    public String rePassword(){
        return "rePassword";
    }
    //修改提交的密码
    @RequestMapping("/submitResetPwd")
    @ResponseBody
    public JsonResult submitResetPwd(String password, String newPassword,HttpSession httpSession){
        Admin admin = (Admin) httpSession.getAttribute("admin");
        if(!admin.getaPassword().equals(password))
            return new JsonResult(false,ResultEnum.OLD_PASSWORD_ERROR);
        admin.setaPassword(MD5Util.getMD5(newPassword));
        admin.setaUpdateTime(new Date());
        boolean isSuccess = adminService.upDate(admin);
        if(isSuccess) return new JsonResult(isSuccess, ResultEnum.UPDATE_SUCCESS);
        return new JsonResult(isSuccess, ResultEnum.UPDATE_FAIL);
    }

    //跳转到用户管理页面

    @RequestMapping("/adminManage")
    public String adminMange(){
        return "admin";
    }


    //显示用户页面
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Admin> showAll(Integer page, Integer rows){
        return adminService.findAllToPage(page,rows);
    }

    //删除用户
    @RequestMapping("/remove")
    @ResponseBody
    public JsonResult remove(Integer aid){
        return adminService.deleteById(aid);
    }

    // 加载服务点到表单下拉框 loadPlace
    @RequestMapping("/loadPlace")
    @ResponseBody
    public List<Place> loadPlace(){
        return adminService.loadPlace();
    }


    //回显用户表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Admin loadForm(String username){
        Admin admin = adminService.findByUsername(username);
        return admin;
    }


    //addOrUpdate
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile adminIcon, Admin admin, HttpServletRequest request){
        if(admin.getAid() == null) return adminService.add(adminIcon,admin,request);
        return adminService.update(adminIcon,admin,request);

    }
















}

BikeController.java

package com.webike.web;

import com.webike.dto.JsonResult;
import com.webike.dto.Page;
import com.webike.pojo.Bike;
import com.webike.pojo.Category;
import com.webike.pojo.Student;
import com.webike.service.BikeService;
import com.webike.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * Created by Ming on 2018/2/10.
 */
@Controller
@RequestMapping("/bike")
    public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;



    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
        if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
            return bikeService.update(bikeIcon,bike,request);
    }

    //showAll bike
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Bike> show(Integer page, Integer rows){
        return bikeService.findAllToPage(page,rows);
    }

    //删除单车和更新单车的分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(String bids,String cids){
        return bikeService.deleteById(bids,cids);
    }
    //点击修改回显bike弹出表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Bike loadForm(Integer bid){
        return bikeService.findById(bid);
    }

    //回显bike分类
    @RequestMapping(value = "/loadCategory",method = RequestMethod.POST)
    @ResponseBody
    public List<Category> loadCategory(){
        return categoryService.findAll();
    }



}

完整源码

觉得有用,记得一键三连哦!

  • 10
    点赞
  • 92
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
JSP是Java服务器页面的缩写,SSM是Spring+SpringMVC+MyBatis的缩写,MySQL是一种关系型数据库管理系统。进销存管理系统是一种管理企业库存、销售和采购等流程的系统。 JSP是一种在服务器上生成动态网页的技术,它可以与后端的Java代码进行交互,将数据库中的数据显示在网页上,而SSM是一种基于Java的开发框架,可用于快速开发Web应用程序。 MySQL是一种常用的关系型数据库管理系统,可以用来存储和管理系统中所需的数据。 JSP和SSMMySQL的结合可以实现进销存管理系统的开发和运行。通过JSP,开发者可以创建用户界面和表单,从而与系统进行交互。通过SSM框架,开发者可以更方便地编写和管理后端业务逻辑代码,并实现数据库的交互。通过MySQL,可以安全地存储和管理系统中的各类数据。 进销存管理系统可以实现以下功能: 1. 商品管理:包括录入商品信息、修改商品信息和删除商品信息等操作。 2. 采购管理:包括录入采购单、查询采购单和审核采购单等操作。 3. 销售管理:包括录入销售订单、查询销售订单和生成销售报表等操作。 4. 库存管理:包括库存盘、库存调整和库存预警等操作。 5. 统计析:包括销售额统计、库存量统计和利润析等操作。 通过JSP、SSMMySQL的组合,可以实现上述功能,并且具有良好的扩展性和可维护性。开发者可以根据实际需求添加更多功能,并对系统进行灵活的配置和定制。同时,MySQL作为后台数据库,可以保证系统的数据安全性和稳定性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

anmu4200

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值