基于javaweb和mysql的ssm公寓房屋出租系统(java+ssm+jsp+easyui+echarts+mysql)
·
基于javaweb和mysql的ssm公寓房屋出租系统(java+ssm+jsp+easyui+echarts+mysql)
私信源码获取及调试交流
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM公寓房屋出租系统(java+ssm+jsp+easyui+echarts+mysql)
项目介绍
该项目分为前后台,分为普通用户与管理员两种角色。 前台主要功能包括: 普通用户的注册、登录,房屋列表展示,租房,我的订单、用户中心等功能模块;
后台主要功能包括: 系统设置:菜单管理、角色管理、修改密码; 用户管理:用户列表; 系统日志:日志列表; 房屋管理:房屋列表; 租赁管理:租赁列表;
环境需要
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 2. 前端:JSP+EasyUI+Echarts+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080即可
return model;
}
@RequestMapping(value="/edit_password",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> editPasswordAct(String newpassword,String oldpassword,HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>();
if(StringUtils.isEmpty(newpassword)){
ret.put("type", "error");
ret.put("msg", "请填写新密码!");
return ret;
}
User user = (User)request.getSession().getAttribute("admin");
if(!user.getPassword().equals(oldpassword)){
ret.put("type", "error");
ret.put("msg", "原密码错误!");
return ret;
}
user.setPassword(newpassword);
if(userService.editPassword(user) <= 0){
ret.put("type", "error");
ret.put("msg", "密码修改失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "密码修改成功!");
logService.add("用户名为{"+user.getUsername()+"},的用户成功修改密码!");
return ret;
}
/**
* 本系统所有的验证码均采用此方法
* @param vcodeLen
* @param width
* @param height
* @param cpachaType:用来区别验证码的类型,传入字符串
* @param request
* @param response
*/
@RequestMapping(value="/get_cpacha",method=RequestMethod.GET)
public void generateCpacha(
@RequestParam(name="vl",required=false,defaultValue="4") Integer vcodeLen,
@RequestParam(name="w",required=false,defaultValue="100") Integer width,
@RequestParam(name="h",required=false,defaultValue="30") Integer height,
@RequestParam(name="type",required=true,defaultValue="loginCpacha") String cpachaType,
HttpServletRequest request,
public void afterCompletion(HttpServletRequest arg0,
HttpServletResponse arg1, Object arg2, Exception arg3)
throws Exception {
// TODO Auto-generated method stub
}
@Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1,
Object arg2, ModelAndView arg3) throws Exception {
// TODO Auto-generated method stub
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object arg2) throws Exception {
// TODO Auto-generated method stub
String requestURI = request.getRequestURI();
Object admin = request.getSession().getAttribute("admin");
if(admin == null){
//表示未登录或者登录失效
System.out.println("链接"+requestURI+"进入拦截器!");
String header = request.getHeader("X-Requested-With");
//判断是否是ajax请求
if("XMLHttpRequest".equals(header)){
//表示是ajax请求
Map<String, String> ret = new HashMap<String, String>();
ret.put("type", "error");
ret.put("msg", "登录会话超时或还未登录,请重新登录!");
response.getWriter().write(JSONObject.fromObject(ret).toString());
return false;
}
//表示是普通链接跳转,直接重定向到登录页面
response.sendRedirect(request.getServletContext().getContextPath() + "/system/login");
return false;
}
//获取菜单id
String mid = request.getParameter("_mid");
if(!StringUtils.isEmpty(mid)){
List<Menu> allThirdMenu = MenuUtil.getAllThirdMenu((List<Menu>)request.getSession().getAttribute("userMenus"), Long.valueOf(mid));
request.setAttribute("thirdMenuList", allThirdMenu);
}
return true;
}
}
return model;
}
/**
* 注册页面
* @param model
* @return
*/
@RequestMapping(value="/reg",method=RequestMethod.GET)
public ModelAndView reg(ModelAndView model
){
model.setViewName("home/index/reg");
return model;
}
/**
* 登录信息提交
* @param account
* @return
*/
@RequestMapping(value="/login",method=RequestMethod.POST)
@ResponseBody
public Map<String,String> loginAct(Account account,String vcode,HttpServletRequest request){
Map<String,String> retMap = new HashMap<String, String>();
if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!");
return retMap;
}
if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!");
return retMap;
}
if(StringUtils.isEmpty(account.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码不能为空!");
return retMap;
}
if(StringUtils.isEmpty(vcode)){
retMap.put("type", "error");
retMap.put("msg", "验证码不能为空!");
return retMap;
}
Object attribute = request.getSession().getAttribute("accountLoginCpacha");
if(attribute == null){
retMap.put("type", "error");
/**
* 前台首页控制器
*
*/
@RequestMapping("/home")
@Controller
public class HomeController {
@Autowired
private RoomTypeService roomTypeService;
@Autowired
private AccountService accountService;
/**
* 前台首页
* @param model
* @param name
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping(value="/index",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model,
@RequestParam(name="name",defaultValue="") String names,HttpServletRequest request
) throws UnsupportedEncodingException{
request.setCharacterEncoding("UTF-8");
System.out.println("--前台首页--");
System.out.println("name:"+names);
// String name=new String(names.getBytes("ISO-8859-1"),"UTF-8");
Map<String,Object> queryMap = new HashMap<String, Object>();
queryMap.put("name", names);
queryMap.put("offset", 0);
queryMap.put("pageSize", 999);
model.addObject("roomTypeList", roomTypeService.findList(queryMap));
model.setViewName("home/index/index");
// model.setViewName("home/index/home");
model.addObject("kw", names);
return model;
}
/**
* 登录页面
* @param model
/**
* 房屋类型信息添加操作
* @param roomType
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> add(RoomType roomType){
Map<String, String> ret = new HashMap<String, String>();
if(roomType == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的房屋类型信息!");
return ret;
}
if(StringUtils.isEmpty(roomType.getName())){
ret.put("type", "error");
ret.put("msg", "房屋类型名称不能为空!");
return ret;
}
roomType.setAvilableNum(roomType.getRoomNum());//默认房屋数等于可用房屋数
roomType.setBookNum(0);//设置预定数0
roomType.setLivedNum(0);//设置已入住数0
if(roomTypeService.add(roomType) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}
/**
* 房屋类型信息编辑操作
* @param roomType
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> edit(RoomType roomType){
Map<String, String> ret = new HashMap<String, String>();
if(roomType == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的房屋类型信息!");
return ret;
}
}
/**
* 用户信息添加操作
* @param account
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> add(Account account){
Map<String, String> ret = new HashMap<String, String>();
if(account == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的用户信息!");
return ret;
}
if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "用户名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "用户密码不能为空!");
return ret;
}
if(isExist(account.getName(), 0l)){
ret.put("type", "error");
ret.put("msg", "该用户名已经存在!");
return ret;
}
if(accountService.add(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}
/**
* 用户信息编辑操作
* @param account
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> edit(Account account){
Map<String, String> ret = new HashMap<String, String>();
if(account == null){
ret.put("type", "error");
*/
@RequestMapping(value="/book_order",method=RequestMethod.GET)
public ModelAndView bookOrder(ModelAndView model,Long roomTypeId
){
model.addObject("roomType", roomTypeService.find(roomTypeId));
model.setViewName("home/account/book_order");
return model;
}
/**
* 出租信息提交
* @param account
* @return
*/
@RequestMapping(value="/book_order",method=RequestMethod.POST)
@ResponseBody
public Map<String,String> bookOrderAct(BookOrder bookOrder,HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>();
if(bookOrder == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的出租订单信息!");
return ret;
}
Account account = (Account)request.getSession().getAttribute("account");
if(account == null){
ret.put("type", "error");
ret.put("msg", "客户不能为空!");
return ret;
}
bookOrder.setAccountId(account.getId());
if(bookOrder.getRoomTypeId() == null){
ret.put("type", "error");
ret.put("msg", "房型不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getName())){
ret.put("type", "error");
ret.put("msg", "出租订单联系人名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getMobile())){
ret.put("type", "error");
ret.put("msg", "出租订单联系人手机号不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getIdCard())){
ret.put("type", "error");
ret.put("msg", "联系人身份证号不能为空!");
return ret;
}
// if(StringUtils.isEmpty(bookOrder.getArriveDate())){
// ret.put("type", "error");
// ret.put("msg", "到达时间不能为空!");
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.setViewName("log/list");
return model;
}
/**
* 获取日志列表
* @param page
* @param content
* @param roleId
* @param sex
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getList(Page page,
@RequestParam(name="content",required=false,defaultValue="") String content
){
Map<String, Object> ret = new HashMap<String, Object>();
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("content", content);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", logService.findList(queryMap));
ret.put("total", logService.getTotal(queryMap));
return ret;
}
/**
* 添加日志
* @param user
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> add(Log log){
Map<String, String> ret = new HashMap<String, String>();
if(log == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的日志信息!");
return ret;
}
if(StringUtils.isEmpty(menu.getIcon())){
ret.put("type", "error");
ret.put("msg", "请填写菜单图标类!");
return ret;
}
if(menu.getParentId() == null){
menu.setParentId(0l);
}
if(menuService.add(menu) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}
/**
* 菜单修改
* @param menu
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> edit(Menu menu){
Map<String, String> ret = new HashMap<String, String>();
if(menu == null){
ret.put("type", "error");
ret.put("msg", "请选择正确的菜单信息!");
return ret;
}
if(StringUtils.isEmpty(menu.getName())){
ret.put("type", "error");
ret.put("msg", "请填写菜单名称!");
return ret;
}
if(StringUtils.isEmpty(menu.getIcon())){
ret.put("type", "error");
ret.put("msg", "请填写菜单图标类!");
return ret;
}
if(menu.getParentId() == null){
menu.setParentId(0l);
*
*/
@RequestMapping("/admin/user")
@Controller
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
/**
* 用户列表页面
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
Map<String, Object> queryMap = new HashMap<String, Object>();
model.addObject("roleList", roleService.findList(queryMap));
model.setViewName("user/list");
return model;
}
/**
* 获取用户列表
* @param page
* @param username
* @param roleId
* @param sex
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getList(Page page,
@RequestParam(name="username",required=false,defaultValue="") String username,
@RequestParam(name="roleId",required=false) Long roleId,
@RequestParam(name="sex",required=false) Integer sex
){
Map<String, Object> ret = new HashMap<String, Object>();
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("username", username);
queryMap.put("roleId", roleId);
queryMap.put("sex", sex);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
for(File f:listFiles){
if(f!= null && f.getName().contains("png")){
icons.add("icon-" + f.getName().substring(0, f.getName().indexOf(".")).replace("_", "-"));
}
}
ret.put("type", "success");
ret.put("content", icons);
return ret;
}
/**
* 菜单添加
* @param menu
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> add(Menu menu){
Map<String, String> ret = new HashMap<String, String>();
if(menu == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的菜单信息!");
return ret;
}
if(StringUtils.isEmpty(menu.getName())){
ret.put("type", "error");
ret.put("msg", "请填写菜单名称!");
return ret;
}
if(StringUtils.isEmpty(menu.getIcon())){
ret.put("type", "error");
ret.put("msg", "请填写菜单图标类!");
return ret;
}
if(menu.getParentId() == null){
menu.setParentId(0l);
}
if(menuService.add(menu) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
* @param account
* @return
*/
@RequestMapping(value="/reg",method=RequestMethod.POST)
@ResponseBody
public Map<String,String> regAct(Account account){
Map<String,String> retMap = new HashMap<String, String>();
if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!");
return retMap;
}
if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!");
return retMap;
}
if(StringUtils.isEmpty(account.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码不能为空!");
return retMap;
}
if(StringUtils.isEmpty(account.getMobile())){
retMap.put("type", "error");
retMap.put("msg", "手机号不能为空!");
return retMap;
}
if(isExist(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "该用户名已经存在!");
return retMap;
}
if(accountService.add(account) <= 0){
retMap.put("type", "error");
retMap.put("msg", "注册失败,请联系管理员!");
return retMap;
}
retMap.put("type", "success");
retMap.put("msg", "注册成功!");
return retMap;
}
/**
* 退出登录
* @param request
* @return
*/
@RequestMapping(value="/logout",method=RequestMethod.GET)
public String logout(HttpServletRequest request){
/**
* 用户管理控制器
*
*/
@RequestMapping("/admin/user")
@Controller
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
/**
* 用户列表页面
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
Map<String, Object> queryMap = new HashMap<String, Object>();
model.addObject("roleList", roleService.findList(queryMap));
model.setViewName("user/list");
return model;
}
/**
* 系统操作类控制器
*
*/
@Controller
@RequestMapping("/system")
public class SystemController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private AuthorityService authorityService;
@Autowired
private MenuService menuService;
@Autowired
private LogService logService;
/**
* 系统登录后的主页
* @param model
* @return
*/
@RequestMapping(value="/index",method=RequestMethod.GET)
public ModelAndView index(ModelAndView model,HttpServletRequest request){
List<Menu> userMenus = (List<Menu>)request.getSession().getAttribute("userMenus");
model.addObject("topMenuList", MenuUtil.getAllTopMenu(userMenus));
model.addObject("secondMenuList", MenuUtil.getAllSecondMenu(userMenus));
model.setViewName("system/index");
return model;//WEB-INF/views/+system/index+.jsp = WEB-INF/views/system/index.jsp
}
/**
* 系统登录后的欢迎页
* @param model
* @return
*/
@RequestMapping(value="/welcome",method=RequestMethod.GET)
public ModelAndView welcome(ModelAndView model){
model.setViewName("system/welcome");
return model;
}
/**
* 登陆页面
* @param model
* @return
*/
@RequestMapping(value="/login",method=RequestMethod.GET)
public ModelAndView login(ModelAndView model){
model.setViewName("system/login");
return model;
}
/**
* 登录表单提交处理控制器
*/
@RequestMapping("/admin/menu")
@Controller
public class MenuController {
@Autowired
private MenuService menuService;
/**
* 菜单管理列表页
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.addObject("topList", menuService.findTopList());
model.setViewName("menu/list");
return model;
}
/**
* 获取菜单列表
* @param page
* @param name
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getMenuList(Page page,
@RequestParam(name="name",required=false,defaultValue="") String name
){
Map<String, Object> ret = new HashMap<String, Object>();
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
queryMap.put("name", name);
List<Menu> findList = menuService.findList(queryMap);
ret.put("rows", findList);
ret.put("total", menuService.getTotal(queryMap));
return ret;
}
// }
// if(StringUtils.isEmpty(bookOrder.getLeaveDate())){
// ret.put("type", "error");
// ret.put("msg", "离店时间不能为空!");
// return ret;
// }
bookOrder.setCreateTime(new Date());
bookOrder.setStatus(0);
if(bookOrderService.add(bookOrder) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
RoomType roomType = roomTypeService.find(bookOrder.getRoomTypeId());
//出租成功后去修改该房型的出租数
if(roomType != null){
roomType.setBookNum(roomType.getBookNum() + 1);
roomType.setAvilableNum(roomType.getAvilableNum() - 1);
roomTypeService.updateNum(roomType);
//如果可用的房间数为0,则设置该房型状态已满
if(roomType.getAvilableNum() == 0){
roomType.setStatus(0);
roomTypeService.edit(roomType);
}
}
ret.put("type", "success");
ret.put("msg", "出租成功!");
return ret;
}
/**
* 修改个人信息提交
* @param account
* @return
*/
@RequestMapping(value="/update_info",method=RequestMethod.POST)
@ResponseBody
public Map<String,String> updateInfoAct(Account account,HttpServletRequest request){
Map<String,String> retMap = new HashMap<String, String>();
if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!");
return retMap;
}
public Map<String, String> add(Account account){
Map<String, String> ret = new HashMap<String, String>();
if(account == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的用户信息!");
return ret;
}
if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "用户名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "用户密码不能为空!");
return ret;
}
if(isExist(account.getName(), 0l)){
ret.put("type", "error");
ret.put("msg", "该用户名已经存在!");
return ret;
}
if(accountService.add(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}
/**
* 用户信息编辑操作
* @param account
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> edit(Account account){
Map<String, String> ret = new HashMap<String, String>();
if(account == null){
ret.put("type", "error");







更多推荐



所有评论(0)