项目介绍
本项目分为前后台,前台为普通用户登录,后台为管理员登录;
管理员角色包含以下功能:
管理员登录,修改管理员信息,用户信息管理,管理新闻公告,汽车品牌信息管理,城市信息管理,租赁点信息管理,共享汽车信息管理,汽车订单信息管理,汽车评价信息管理等功能。
用户角色包含以下功能:
查看首页,查看网站公告,查看可用共享汽车,查看租赁点,查看汽车详情,加入租赁单,提交订单,查看我的订单,修改个人信息等功能。
环境需要
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项目:否;
技术栈
- 后端:Spring+SpringMVC+Mybatis
- 前端:JSP+CSS+JavaScript+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
- 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; - 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
- 运行项目,在浏览器中输入http://localhost:8080/ 登录
用户账号/密码: user/123456
管理员账号/密码:admin/admin
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
@RestController
@RequestMapping("role")
public class RoleController {
@Autowired
private RoleService roleService;
/*
* 加载角色列表返回DataGridView
*/
@RequestMapping("loadAllRole")
public DataGridView loadAllmeenu(RoleVo roleVo) {
return this.roleService.queryAllRole(roleVo);
}
/*
}
}
/*
* 批量删除用户
*/
@RequestMapping("deleteBatchUser")
public ResultObj deleteBatchUser(UserVo userVo) {
try {
this.userService.deleteBatchUser(userVo.getIds());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/*
* 重置用户密码
*/
@RequestMapping("resetUserPwd")
public ResultObj resetUserPwd(UserVo userVo) {
@Autowired
private UserService userService;
@Autowired
private LogInfoService logInfoService;
/*
* 跳转到登录页面
*/
@RequestMapping("toLogin")
public String tologin() {
return "system/main/login";
}
/*
* 登录方法
*/
@RequestMapping("login")
public String login(UserVo userVo, Model model) {
// 记录登录日志 向sys_login_log插入数据
LogInfoVo logInfoVo = new LogInfoVo();
logInfoVo.setLoginname(user.getRealname() + "-" + user.getLoginname());
logInfoVo.setLogintime(new Date());
// 外网Ip:WebUtils.getHttpServletRequest().getRemoteAddr()
// 内网ip:
InetAddress addr;
try {
addr = (InetAddress) InetAddress.getLocalHost();
logInfoVo.setLoginip(addr.getHostAddress().toString());// 获取Id地址
} catch (UnknownHostException e) {
e.printStackTrace();
}
// 添加
logInfoService.addLogInfo(logInfoVo);
return "system/main/index";
} else {
model.addAttribute("error", SysConstast.USER_LOGIN_ERROR_MSG);
return "system/main/login";
}
// } else {
// model.addAttribute("error", SysConstast.USER_LOGIN_CODE_ERROR_MSG);
// return "system/main/login";
// }
} else {
return "system/main/login";
}
if (null != userVo.getLoginname()) {
// String code = WebUtils.getHttpSession().getAttribute("code").toString();
// if (userVo.getCode().toLowerCase().equals(code)) {
User user = this.userService.login(userVo);
if (null != user) {
// 放入session
WebUtils.getHttpSession().setAttribute("user", user);
WebUtils.getHttpSession().setMaxInactiveInterval(240 * 60);
// 记录登录日志 向sys_login_log插入数据
LogInfoVo logInfoVo = new LogInfoVo();
logInfoVo.setLoginname(user.getRealname() + "-" + user.getLoginname());
logInfoVo.setLogintime(new Date());
// 外网Ip:WebUtils.getHttpServletRequest().getRemoteAddr()
// 内网ip:
InetAddress addr;
try {
addr = (InetAddress) InetAddress.getLocalHost();
logInfoVo.setLoginip(addr.getHostAddress().toString());// 获取Id地址
} catch (UnknownHostException e) {
e.printStackTrace();
}
// 添加
logInfoService.addLogInfo(logInfoVo);
return "system/main/index";
} else {
* 添加角色
*/
@RequestMapping("addRole")
public ResultObj addRole(RoleVo roleVo) {
try {
this.roleService.addRole(roleVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
/*
* 修改角色
*/
@RequestMapping("updateRole")
public ResultObj updateRole(RoleVo roleVo) {
try {
this.roleService.updateRole(roleVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/*
* 删除角色
this.userService.addUser(userVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
/*
* 修改用户
*/
@RequestMapping("updateUser")
public ResultObj updateUser(UserVo userVo) {
try {
this.userService.updateUser(userVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
@RequestMapping("getCode")
public void getCode(HttpServletResponse response, HttpSession session) throws IOException {
// 定义图形验证码的长和宽
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36, 4, 50);
Console.log(lineCaptcha.getCode());
session.setAttribute("code", lineCaptcha.getCode());
ServletOutputStream outputStream = response.getOutputStream();
ImageIO.write(lineCaptcha.getImage(), "JPEG", outputStream);
}
}
用户管理控制器:
/**
* 用户管理控制器
*
*/
this.roleService.deleteRole(roleVo.getRoleid());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/*
* 批量删除角色
*/
@RequestMapping("deleteBatchRole")
public ResultObj deleteBatchRole(RoleVo roleVo) {
try {
this.roleService.deleteBatchRole(roleVo.getIds());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/*
* 加载角色管理分配菜单的JSON
*/
@RequestMapping("initRoleMenuTreeJson")
public DataGridView initRoleMenuTreeJson(Integer roleid) {
System.out.println(roleid);
return ResultObj.DELETE_ERROR;
}
}
/*
* 批量删除用户
*/
@RequestMapping("deleteBatchUser")
public ResultObj deleteBatchUser(UserVo userVo) {
try {
this.userService.deleteBatchUser(userVo.getIds());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
/*
* 重置用户密码
*/
@RequestMapping("resetUserPwd")
public ResultObj resetUserPwd(UserVo userVo) {
try {