基于SpringBoot的共享单车管理系统

news2025/7/14 20:19:27

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SpringBoot
前端:采用HTML和Vue技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统功能

三、系统项目截图

3.1前台首页

3.2后台管理

四、核心代码

4.1登录相关

4.2文件上传

4.3封装


一、项目简介

随着科学技术的飞速发展,各行各业都在努力与现代先进技术接轨,通过科技手段提高自身的优势;对于共享单车管理系统当然也不能排除在外,随着网络技术的不断成熟,带动了共享单车管理系统,它彻底改变了过去传统的管理方式,不仅使服务管理难度变低了,还提升了管理的灵活性。这种个性化的平台特别注重交互协调与管理的相互配合,激发了管理人员的创造性与主动性,对共享单车管理系统而言非常有利。

本系统采用的数据库是Mysql,使用SpringBoot技术开发,在设计过程中,充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。


二、系统功能

共享单车管理系统主要包括三大功能模块,即用户模块、操作员模块和管理员模块。

(1)管理员模块:首页、个人中心、用户管理、操作员管理、停车点管理、共享单车管理、车辆类型管理、租赁单车管理、归还单车管理、维修信息管理、系统简介管理、站内新闻管理、系统管理。 

(2)操作员:首页、个人中心、停车点管理、共享单车管理、租赁单车管理、归还单车管理、维修信息管理。

(3)用户:首页、个人中心、停车点、共享单车、系统简介。



三、系统项目截图

3.1前台首页

共享单车管理系统,在系统首页可以查看首页、停车点共享单车系统简介、个人中心、后台管理等内容 

用户登录、用户注册, 通过输入用户账号、密码、用户姓名、性别、手机号码等信息进行登录、注册

 共享单车,在共享单车进行查看停车点、账号、姓名、车辆类型、小时价格、状态、实施时间、点击次数等信息

 停车点停车点页面可以查看编号、地址、点击次数等内容

 

3.2后台管理

管理员登录,通过填写用户名、密码、角色等信息,输入完成后选择登录即可进入共享单车管理系统

管理员登录进入共享单车管理系统可以查看首页、个人中心、用户管理、操作人员管理、停车点管理、车辆类型管理、共享单车管理、租赁单车管理、维修信息管理、归还单车管理、系统简介管理、系统管理等内容用户管理,在用户管理页面可以查看用户账号、密码、用户姓名、性别、年龄、头像、用户手机信息,并可根据需要对用户管理进行详情,修改,删除或查看详细内容等操作操作人员管理,在操作人员管理页面可以查看人员账号、人员姓名、性别、年龄、照片、联系方式等信息,并可根据需要对操作人员管理进行详情,修改、删除或查看详细内容等操作停车点管理,在停车点管理页面可以查看编号、名称、地址、账号、姓名、封面等信息,并可根据需要对停车点管理进行详情,修改、删除或查看详细内容操作


  

四、核心代码

4.1登录相关


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

4.2文件上传

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

4.3封装

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/17737.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一款轻量级的NuGet服务器

一、简介 BaGet (发音为“baguette”) 是一个轻量级的 NuGet、Symbol 服务器。它是开源的、跨平台的和云化的&#xff0c;可以运行再自己得电脑、Docker、Azure、AWS、Google Cloud 、Alibaba Cloud (Aliyun) 等。支持 MySQL、SQLite:、SqlServer、PostgreSQL、Azure Table St…

XSS-labs靶场实战(七)——第16-18关

今天继续给大家介绍渗透测试相关知识&#xff0c;本文主要内容是XSS-labs靶场实战第16-18关。 免责声明&#xff1a; 本文所介绍的内容仅做学习交流使用&#xff0c;严禁利用文中技术进行非法行为&#xff0c;否则造成一切严重后果自负&#xff01; 再次强调&#xff1a;严禁对…

Windows系统封装初始化工具sysprep

Windows系统封装初始化工具sysprep Sysprep简介 Sysprep程序是微软公司用来配置Microsoft Windows全新安装的一个工具&#xff0c;是为方便企业用户部署系统而设计的。 Sysprep&#xff08;系统准备&#xff09;可以准备 Windows 客户端或 Windows Server 安装以生成映像。 Sys…

7.2 Verilog 文件操作

Verilog提供了很多可以对文件进行操作的系统任务。经常使用的系统任务主要包括&#xff1a; 文件开、闭&#xff1a;$fopen, $fclose, $ferror文件写入&#xff1a;$fdisplay, $fwrite, $fstrobe, $fmonitor字符串写入&#xff1a;$sformat, $swrite文件读取&#xff1a;$fget…

计算机毕业设计ssm+vue+elementUI 校园短期闲置资源置换平台

项目介绍 随着互联网时代的到来&#xff0c;人们的生活结构发生了很大的变化&#xff0c;网上交易占据了人们日常交易的很大一部分&#xff0c;这个比例还会继续增长。社会在飞速发展同时伴随着问题的出现&#xff0c;生活节奏的加快&#xff0c;使闲置物品处理成了一个突出问…

VFP发送XML与MSSQL的互操作, 解决一个传大表查询的大大大问题

瓜哥有个需求场景&#xff0c;比如要按订单号查一批订单&#xff0c;数量2w个&#xff0c;如果用in拼接要写好长的语句&#xff0c;用string_split又限制长度8000。所以想想有什么什么好招。 瓜哥就是MYFLL作者木瓜大侠 那就可以传入XML&#xff0c;让MSSQL把XML解析成表&#…

【实验十二】决策树判断你是否可学python

一、实验目的 1.熟练安装scikit-learn扩展库(本库有许多依赖库&#xff0c;如该库建立在NumPy&#xff0c;SciPy和matplotlib之上&#xff0c;一般要先安装这些扩展库后&#xff0c;再安装。当然在线安装的话也会一次性将依依赖库安装完&#xff0c;前提是这些库的网站能连上)…

(杂谈)世界上本没什么prompt,有的只是加权平均——关于NLP中embedding的一点思考

&#xff08;杂谈&#xff09;世界上本没什么prompt&#xff0c;有的只是加权平均——关于NLP中embedding的一点思考0. 写在前面1. 问题的提出2. 备受嫌弃的NSP&#xff0c;为什么效果不佳2. 比句子更小的片段——Span Bert3. 更加纯粹的表示方法——PURE4. 风光无限的prompt&a…

编写bat脚本调用hexview进行软件签名

上一篇《编写Bat脚本调用Vecotr工具软件HexView》介绍了如何使用bat脚本编写Bat脚本调用Vecotr工具软件HexView进行文件合并、填充、AES加密、SHA256哈希校验等基本操作&#xff0c;这篇介绍一下编写bat脚本调用hexview进行软件签名的具体用法&#xff0c;在编程过程中体会代码…

Linux--shell脚本详解

目录 一、shell脚本的类型 二、read命令 三、数组 3.1 定义数组 3.2 赋值数组元素 3.3 取得元素个数 3.4 取得单个元素长度 3.5 取消或删除数组中的元素 四、赋值时使用引号的作用 五、位置参数 5.1 $* 和 $的区别 六、预定义变量 七、变量的算术运算 7.1 双小括…

[一篇读懂]C语言三讲:选择、循环

[一篇读懂]C语言三讲&#xff1a;选择、循环1. 选择if-else讲解1 关系表达式与逻辑表达式计算表达式的过程2 if-else语句【例】判断输入值是否大于02. 循环while&#xff0c;for讲解&#xff0c;continue&#xff0c;break讲解1 while循环【例】计算1到100之间所有整数之和2 fo…

【MySQL进阶】B+树索引的使用

【MySQL进阶】B树索引的使用 文章目录【MySQL进阶】B树索引的使用一、索引的代价二、B树索引适用的条件1、全值匹配2、匹配左边的列3、匹配列前缀4、匹配范围值5、精确匹配某一列并范围匹配另外一列6、用于排序7、用于分组三、回表的代价1、回表的代价2、覆盖索引四、如何挑选索…

论文管理系统(登录功能)

目录 一、后端部分 1.1 实体类 1.2 UserMapper类 1.3 Service层 接口 实现类 1.4 controller层 1.5 拦截器 二、前端部分 效果图 源码如下 代码讲解 准备工作和数据库都已经准备好了,接下来我们来写登录功能,登录功能我们通过mybatisplus来码写,所以不需要在UserMapper.…

台灯到底对眼睛好不好?2022精选眼科医生推荐护眼灯

台灯是我们最常见的照明工具了&#xff0c;台灯对眼睛会有一定的伤害的&#xff0c;光对人的视觉会产生一些影响的&#xff0c;选择质量过关的护眼台灯&#xff0c;对人的眼睛伤害是比较小的&#xff0c;基本上在光照进行优化&#xff0c;做到无可视频闪、无眩光等&#xff0c;…

巯基化PEG试剂——N3-PEG-SH,Azide-PEG-Thiol,叠氮-聚乙二醇-巯基

巯基化PEG化学试剂叠氮-聚乙二醇-巯基&#xff0c;其英文名为Azide-PEG-Thiol&#xff08;N3-PEG-SH&#xff09;&#xff0c;它所属分类为Azide PEG Thiol PEG。 此peg试剂的分子量均可定制&#xff0c;有&#xff1a;5k N3-PEG-SH、20k 叠氮-聚乙二醇-巯基、10k N3-PEG-SH、…

[11]重绘与回流

在看今天的分享之前&#xff0c;希望大家先关注一下&#xff0c;因为你可以免费获取一枚前端路上的陪跑师。 什么是回流 回流&#xff1a;英文是reflow 当render tree中的一部分(或全部)&#xff0c;因为元素的规模尺寸、布局、隐藏等改变 而需要重新构建&#xff0c;这就是回流…

基于web在线餐饮网站的设计与实现——蛋糕甜品店铺(HTML+CSS+JavaScript)

&#x1f468;‍&#x1f393;静态网站的编写主要是用HTML DIVCSS JS等来完成页面的排版设计&#x1f469;‍&#x1f393;,常用的网页设计软件有Dreamweaver、EditPlus、HBuilderX、VScode 、Webstorm、Animate等等&#xff0c;用的最多的还是DW&#xff0c;当然不同软件写出的…

你的新进程是如何被内核调度执行到的?(上)

所谓的运行队列到底长什么样子、新进程是如何被加入进来的、调度是如何选择一个新进程的、新进程又如何被切换到 CPU 上运行的&#xff0c;这些细节咱们都没提到。今天就来展开看看这些进程运行背后的原理。 通过今天的文章&#xff0c;你将对以下两个问题有个更深入的理解。 …

mysql高手进阶优化篇

​MySql理论 逻辑架构 连接层-->服务层-->引擎层-->存储层 存储引擎 查看方式 1.查看mysql现在提供的搜索引擎--->show engines 2.查看mysql当前默认存储引擎show variables like storageenginestorage_enginestorageengine 存储引擎对比 MyISAM: BTree叶节…

Vue快速入门二:Vue绑定事件、Vue中的this指向、增加class选择器、动态创建标签

Vue定义点击事件&#xff1a; <body><div id"box"><button click"handleChange()">change</button></div><script>var vm new Vue({el:"#box",//定义方法methods:{//handleChange:function(){}//简写法&a…