源码获取:博客首页 "资源" 里下载!
springboot停车位管理系统。本系统分为前台和后台两部分:
主要功能说明:
前台用户角色包含以下功能:
修改密码,查看个人订单,查看公告,查看留言,查看车位,查看车位详细情况,用户主页,用户注册登录;
管理员角色包含以下功能:
公告管理,用户管理,留言列表,积分管理,管理员登录,管理员管理,订单管理,车位管理;
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
1. 后端:SpringBoot+thymeleaf
2. 前端:html+bootstrap+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中resources/application.yml配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,前台浏览地址:http://localhost:8085/index
后台浏览地址:http://localhost:8085/admin/login
/**
* 控制器层
* @author yy
*
*/
@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private HttpServletRequest request;
@Autowired
BCryptPasswordEncoder encoder;
/**
* 查询全部数据
*
* @return
*/
@RequestMapping(value = "userList",method = RequestMethod.GET)
public Result findAll() {
List all = userService.findAll();
return new Result(true, StatusCode.OK, "查询成功",all,all.size());
}
/**
* 根据ID查询
*
* @param id ID
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Result findById(@PathVariable Long id) {
return new Result(true, StatusCode.OK, "查询成功", userService.findById(id));
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page pageList = userService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) );
}
/**
* 根据条件查询
* @param searchMap
* @return
*/
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",userService.findSearch(searchMap));
}
/**
* 增加
* @param user
*/
@RequestMapping(method=RequestMethod.POST)
public Result add(@RequestBody User user ){
userService.add(user);
return new Result(true,StatusCode.OK,"增加成功");
}
/**
* 修改
* @param user
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
public Result update(User user, @PathVariable Long id ){
User oldUser=userService.findById(id);
user.setId(id);
user.setPassword(oldUser.getPassword());
userService.update(user);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 修改
* @param user
*/
@RequestMapping(value="/change",method= RequestMethod.POST,consumes = "application/json")
public Result update(@RequestBody User user, HttpSession session){
User us= (User) session.getAttribute("user");
user.setId(us.getId());
user.setPassword(us.getPassword());
userService.update(user);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 删除
* @param id
*/
@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
public Result delete(@PathVariable String id ){
userService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
}
/**
* 用户注册
* @param code
* @param user
* @return
*/
@ResponseBody
@RequestMapping(value = "/register/",method = RequestMethod.POST)
public Result regist(@RequestParam(name = "code") String code,User user,HttpServletRequest request){
String sCode = (String) request.getSession().getAttribute("user_register_email_code");
if(!sCode.equalsIgnoreCase(code)){
return new Result(false,StatusCode.ERROR,"验证码错误!");
}
userService.add(user);
return new Result(true,StatusCode.OK,"注册成功");
}
/**
*判断账号是否存在
* @param user
* @return
*/
@RequestMapping(value = "/checkPhone",method = RequestMethod.POST)
@ResponseBody
public Result checkPhone(User user){
String phone = user.getMobile();
if(!StringUtil.isMobile(phone)){
return new Result(false,StatusCode.ERROR,"请填写正确的手机号!");
}
User userphone= userService.findByMobile(phone);
if (userphone == null){
return new Result(true,StatusCode.OK,"该手机号可以注册");
}
return new Result(false,StatusCode.ERROR,"该手机号已经被注册");
}
/**
* 邮箱验证
* @param user
* @return
*/
@RequestMapping(value = "/email",method = RequestMethod.POST)
@ResponseBody
public Result findemail(User user){
String email = user.getEmail();
if(!StringUtil.emailFormat(email)){
return new Result(true,StatusCode.ERROR,"请填写正确的邮箱格式");
}
User useremail= userService.findByEmail(email);
if (useremail == null){
return new Result(true,StatusCode.OK,"该邮箱可以注册");
}
return new Result(false,StatusCode.ERROR,"该邮箱已经被注册");
}
/**
* 用户登录
* @param loginMap
* @return
*/
@ResponseBody
@RequestMapping(value="/login",method=RequestMethod.POST)
public Result login(@RequestParam Map loginMap,HttpServletRequest request){
String mobile = loginMap.get("login");
if (StringUtil.isMobile(mobile)){
User user = userService.findByMobileAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
return new Result(true,StatusCode.OK,"登陆成功");
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}else {
User user = userService.findByNameAndPassword(loginMap.get("login"),loginMap.get("password"));
if(user!=null){
request.getSession().setAttribute("user",user);
Map map=new HashMap();
map.put("name",user.getName());//姓名
return new Result(true,StatusCode.OK,"登陆成功",map);
}else{
return new Result(false,StatusCode.LOGINERROR,"用户名或密码错误");
}
}
}
/**
* 用户注销
* @param request
* @param response
* @throws IOException
*/
@RequestMapping(value="/logout",method=RequestMethod.GET)
public void logout(HttpServletRequest request,HttpServletResponse response) throws IOException {
request.getSession().setAttribute("user", null);
response.sendRedirect(request.getContextPath() + "/dist/view");
}
}
/**
* 控制器层
* @author yy
*
*/
@Controller
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
BCryptPasswordEncoder encoder;
/**
* 查询全部数据
* @return
*/
@ResponseBody
@RequestMapping(method= RequestMethod.GET)
public Result findAll(){
return new Result(true, StatusCode.OK,"查询成功",adminService.findAll());
}
/**
* 根据ID查询
* @param id ID
* @return
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,"查询成功",adminService.findById(id));
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@ResponseBody
@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page pageList = adminService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) );
}
/**
* 根据条件查询
* @param searchMap
* @return
*/
@ResponseBody
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",adminService.findSearch(searchMap));
}
/**
* 增加
* @param admin
*/
@ResponseBody
@RequestMapping(method=RequestMethod.POST)
public Result add(@RequestBody Admin admin ){
adminService.add(admin);
return new Result(true,StatusCode.OK,"增加成功");
}
/**
* 修改
* @param admin
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
public Result update(@RequestBody Admin admin, @PathVariable Long id ){
admin.setId(id);
adminService.update(admin);
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 删除
* @param id
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
public Result delete(@PathVariable String id ){
adminService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
}
/**
* 管理员跳转
* @return
*/
@RequestMapping(value = "/adminlogin")
public String adminlogin()
{
return "admin/login/login";
}
/**
* admin登录
* @param loginMap
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value="/login",method= RequestMethod.POST)
public Result login(@RequestParam Map loginMap,HttpServletRequest request){
Admin admin = adminService.finbyNameAndPassword(loginMap.get("name"),loginMap.get("password"));
if (admin!=null){
request.getSession().setAttribute("admin",admin);
Map map=new HashMap();
map.put("name",admin.getName());
return new Result(true,StatusCode.OK,"登录成功");
}else {
return new Result(false,StatusCode.ERROR,"账号密码错误");
}
}
/**
* 管理员登录成功
* @return
*/
@RequestMapping(value = "/index")
public String success(){
return "admin/index";
}
/**
* 用户列表
* @return
*/
@RequestMapping(value = "/userList")
public String user(){
return "admin/usermanage/userList";
}
@RequestMapping(value = "/echars")
public String analysis(){
return "admin/echars/console";
}
/**
* 管理员退出登录
* @return
*/
@RequestMapping(value = "/logout")
public String logout(HttpSession session){
session.removeAttribute("admin");
return "admin/login/login";
}
/**
* 管理员修改密码
* @return
*/
@ResponseBody
@RequestMapping(value = "/passwd")
public Result passwd(HttpSession session,String passwd,String oldpad){
Admin admindmin= (Admin) session.getAttribute("admin");
Admin admins=adminService.findById(admindmin.getId());
boolean old=encoder.matches(oldpad,admins.getPassword());
if (old){
String newPassd=encoder.encode(passwd);
admins.setPassword(newPassd);
adminService.update(admins);
return new Result(true,StatusCode.OK,"成功");
}else {
return new Result(false,StatusCode.ERROR,"更新失败");
}
}
}
/**
* 轮播内容控制器层
* @author yy
*
*/
@Controller
@CrossOrigin
@RequestMapping("/carousel")
public class CarouselController {
@Autowired
private CarouselService carouselService;
/**
* 查询全部数据
* @return
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List all = carouselService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
}
/**
* 根据ID查询
* @param id ID
* @return
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,"查询成功",carouselService.findById(id));
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@ResponseBody
@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page pageList = carouselService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) );
}
/**
* 根据条件查询
* @param searchMap
* @return
*/
@ResponseBody
@RequestMapping(value="/search",method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,"查询成功",carouselService.findSearch(searchMap));
}
/**
* 轮播内容添加
* @param carousel
*/
@ResponseBody
@RequestMapping(value = "/add",method=RequestMethod.POST)
public Result add(Carousel carousel){
if(StringUtils.isEmpty(carousel.getTitle())){
return new Result(false,StatusCode.ERROR,"请填写第一行内容");
}
if(StringUtils.isEmpty(carousel.getScenictime())){
return new Result(false,StatusCode.ERROR,"请填写第二行内容");
}
if(StringUtils.isEmpty(carousel.getComment())){
return new Result(false,StatusCode.ERROR,"请填写第三行内容");
}
if(carouselService.add(carousel)==null){
return new Result(false,StatusCode.ERROR,"轮播信息添加失败");
}
return new Result(true,StatusCode.OK,"添加成功");
}
/**
* 轮播内容修改
* @param carousel
*/
@ResponseBody
@RequestMapping(value="/edit",method= RequestMethod.PUT)
public Result update(Carousel carousel){
if(StringUtils.isEmpty(carousel.getTitle())){
return new Result(false,StatusCode.ERROR,"请填写第一行内容");
}
if(StringUtils.isEmpty(carousel.getScenictime())){
return new Result(false,StatusCode.ERROR,"请填写第二行内容");
}
if(StringUtils.isEmpty(carousel.getComment())){
return new Result(false,StatusCode.ERROR,"请填写第三行内容");
}
if(carouselService.update(carousel)==null){
return new Result(false,StatusCode.ERROR,"轮播信息修改成功!");
}
return new Result(true,StatusCode.OK,"修改成功");
}
/**
* 删除
* @param id
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
public Result delete(@PathVariable Long id ){
try{
carouselService.deleteById(id);
}catch (Exception e){
e.printStackTrace();
new Result(false,StatusCode.ERROR,"删除失败");
}
return new Result(true,StatusCode.OK,"删除成功");
}
/**
* 后台轮播列表
* @return
*/
@RequestMapping(value = "/carouselList")
public String carouselList(){
return "admin/carouselmanage/carouselList";
}
}
源码获取:博客首页 "资源" 里下载!