日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發布時間:2023/12/20 数据库 34 豆豆

博客目錄

  • 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();}@Overridepublic 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.*/ @Servicepublic class AdminServiceImpl implements AdminService {@Autowiredprivate AdminMapper adminMapper;@Autowiredprivate PlaceMapper placeMapper;@Overridepublic 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 "沒有此賬號~";}@Overridepublic boolean upDate(Admin admin) {AdminExample adminExample = new AdminExample();adminExample.createCriteria().andAUsernameEqualTo(admin.getaUsername());int i = adminMapper.updateByExampleSelective(admin, adminExample);return i > 0 ? true : false;}@Overridepublic 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;}@Overridepublic 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;}@Overridepublic 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);}@Overridepublic List<Place> loadPlace() {List<Place> places = placeMapper.selectByExample(new PlaceExample());return places;}@Overridepublic 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);}}@Overridepublic 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 {@Autowiredprivate BikeMapper bikeMapper;@Autowiredprivate CategoryService categoryService;//事務控制 該單車分類剩余量+1@Transactional@Overridepublic 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);}}@Overridepublic 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);}}@Overridepublic 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@Overridepublic 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);}}@Overridepublic 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 {@Autowiredprivate 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)) {//注入SessionAdmin 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")@ResponseBodypublic 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")@ResponseBodypublic Page<Admin> showAll(Integer page, Integer rows){return adminService.findAllToPage(page,rows);}//刪除用戶@RequestMapping("/remove")@ResponseBodypublic JsonResult remove(Integer aid){return adminService.deleteById(aid);}// 加載服務點到表單下拉框 loadPlace@RequestMapping("/loadPlace")@ResponseBodypublic List<Place> loadPlace(){return adminService.loadPlace();}//回顯用戶表單@RequestMapping("/loadForm")@ResponseBodypublic Admin loadForm(String username){Admin admin = adminService.findByUsername(username);return admin;}//addOrUpdate@RequestMapping("/addOrUpdate")@ResponseBodypublic 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 {@Autowiredprivate BikeService bikeService;@Autowiredprivate CategoryService categoryService;//跳轉到 bike管理頁面@RequestMapping("/bikeManage")public String bikeManage(){return "bike";}//添加或更新bike@RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)@ResponseBodypublic 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")@ResponseBodypublic Page<Bike> show(Integer page, Integer rows){return bikeService.findAllToPage(page,rows);}//刪除單車和更新單車的分類@RequestMapping(value = "/remove",method = RequestMethod.POST)@ResponseBodypublic JsonResult remove(String bids,String cids){return bikeService.deleteById(bids,cids);}//點擊修改回顯bike彈出表單@RequestMapping("/loadForm")@ResponseBodypublic Bike loadForm(Integer bid){return bikeService.findById(bid);}//回顯bike分類@RequestMapping(value = "/loadCategory",method = RequestMethod.POST)@ResponseBodypublic List<Category> loadCategory(){return categoryService.findAll();}}

完整源碼

覺得有用,記得一鍵三連哦!

總結

以上是生活随笔為你收集整理的SSM+Mysql实现的共享单车管理系统(功能包含分角色,登录、用户管理、服务点管理、单车管理、分类管理、学生信息管理、单车租赁、信息统计、系统设置等)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。