基于javaweb+jsp的房屋租赁管理系统(java+SSM+Layui+Maven+Mysql+Jsp)
一、项目简述
功能包括:
房屋租赁管理系统是一款方便快捷,易操作的租房和各种物业收费的管理系统,该系统官网包含着用户和管理员分类登录,减少了为使用管理员系统的开支,用户分别支持手机网上或电脑网页快捷的查找可出租的房子,并在网上在线支付,并还包含有故障报修,缴租提醒,极大符合现代人们不想出门又快捷办事的需求,管理员也只需在网上提醒用户缴费即可,并有着查看用户信息,查看报障,租金信息,合同信息,日常提醒,添加删除或修改房屋的功能。
二、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
*/@RequestMapping("/tzshenqing")public ModelAndView tzshenqing(@RequestParam int pn) {ModelAndView mav = new ModelAndView("housedel");// 设置分页传输PageHelper.startPage(pn, 10);// 查询所有数据List<checkoutapplication> list = checkoutapplicationService.selectCoaState1();// 使用PageInFo封装查询结果PageInfo<checkoutapplication> pageInfo = new PageInfo<checkoutapplication>(list, 5);// 放入转发参数mav.addObject("cs", pageInfo);return mav;}/*** 删除退房记录*/
for (fault temp : faultdone) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");String date = sdf.format(temp.getFdate());temp.setFdatetemp(date);}PageInfo<fault> page = new PageInfo<fault>(faultdone, 3);model.addAttribute("p", page);model.addAttribute("vo", vo);return "repairdone";}/**
new DocumentConversion().PdfGeneration(arraytemp[7]);filetemp = new File("C://Users/Rain/Desktop/ssm_leaseOfHouses/WebContent/contract/pdf/" + temp);}String pdf = filetemp.getName();// 放入转发参数mav.addObject("pdftemp", pdf);return mav;}}房屋信息控制器:/*** 房屋信息控制器* @author yy**/@Controller@RequestMapping("/leaseinformationmvc")public class LeaseinformationController {@Autowired
userlistService.updatepwd(userlist);return "login";}return userpwd;}/*** 注销*/@RequestMapping("/cancellation")public String cancellation(HttpServletRequest request) {
leaseinformationService.deleteByPrimaryKey(houseid);leaseimgService.deleteByPrimaryKey(id);}return "redirect:pagingselecthouse.do";}/** 推荐房屋列表*/@RequestMapping("/recommendlist")public String recommendlist(Model model, @RequestParam(value = "pn", defaultValue = "1") Integer pn,@RequestParam(required = false, defaultValue = "6") Integer pageSize) {PageHelper.startPage(pn, 10);List<leaseinformation> leaseinformation = leaseinformationService.selectAllLeasable();PageInfo<leaseinformation> p = new PageInfo<leaseinformation>(leaseinformation, 3);model.addAttribute("p", p);return "recommendhouse";}/*** 修改推荐信息*/@RequestMapping("/updaterecommend")public String updatehouse(Integer houseid) {
ModelAndView mav = new ModelAndView("rentingdel");rentwithdrawnService.deleteByPrimaryKey(id);return mav;}@RequestMapping("/rentinglist")public ModelAndView listHouseState(@RequestParam int pn) {ModelAndView mav = new ModelAndView("rentinglist");// 设置分页传输PageHelper.startPage(pn, 10);// 查询所有数据List<leaseinformation> list = leaseinformationService.selecthousteaseWith("出租中");// 使用PageInFo封装查询结果PageInfo<leaseinformation> pageInfo = new PageInfo<leaseinformation>(list, 5);// 放入转发参数mav.addObject("cs", pageInfo);return mav;}@RequestMapping("/delectcontract")public ModelAndView delectcontract(@RequestParam int id) {ModelAndView mav = new ModelAndView("rentinglist");leaseinformationService.updacontract(id);return mav;}
headportraitimg headportraitimg = headPortraitImgService.selectheadportrait(tempstr);if (headportraitimg.getHeadportraitimgaddress() != null) {session.setAttribute("headportraitimg", headportraitimg.getHeadportraitimgaddress());}return "official";}} catch (NullPointerException e) {if (tempstr == null) {request.setAttribute("erorr", "输入账号密码有误!");return "login";} else {return "official";}}}if (identity[0].equals("admin")) {adminlist temp = new adminlist();temp.setAdminname(username);temp.setAdminpwd(pwd);adminlist adminlist = adminListService.findAllAdminPwd(temp);try {tempstr = adminlist.getAdminname();
* 看房申请列表*/@RequestMapping("/houseapply")public ModelAndView kanfansqing(@RequestParam int pn) {ModelAndView mav = new ModelAndView("houseapply");// 设置分页传输PageHelper.startPage(pn, 10);// 查询所有数据List<checkoutapplication> list = checkoutapplicationService.selectCoaState();// 使用PageInFo封装查询结果PageInfo<checkoutapplication> pageInfo = new PageInfo<checkoutapplication>(list, 5);// 放入转发参数mav.addObject("cs", pageInfo);return mav;}/*** 预约看房申请*/@RequestMapping("/tonyizp")public ModelAndView tonyizp(@RequestParam int id, String housecall, String name) throws ParseException {ModelAndView mav = new ModelAndView("houseapply");checkoutapplicationService.xgaiCoaState("已同意", id);
rentcollectionService.insert(rentcollection);return "redirect:/admin/adminrentshou.do";}/*** 代缴租金*/@RequestMapping("/adminrentwait")public String rentwait(String rcstate, @RequestParam(value = "pn", defaultValue = "1") Integer pn, Model model) {rcstate = "未缴纳";// 引用PageHelper分页插件PageHelper.startPage(pn, 10);
@RequestMapping("/Adminselectrepairdone")public String selectrepairdone(String state, @RequestParam(value = "pn", defaultValue = "1") Integer pn,Model model) {state = "已处理";// 引用PageHelper分页插件PageHelper.startPage(pn, 10);List<fault> faultdone = faultService.AdminSelectStateAll(state);PageInfo<fault> page = new PageInfo<fault>(faultdone, 3);model.addAttribute("p", page);return "repairdone";}/**
// 查询所有数据userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));if (user.getUsername() == null) {// 判断真实姓名是否为空mav.addObject("apply", "请绑定真实姓名后再租赁房屋!");return mav;} else {checkoutapplication coa = new checkoutapplication();coa.setCoausername(user.getUsername());coa.setCoauserid(user.getUserid());coa.setCoauserphone(user.getUserphone());coa.setCoahouseid(housecall);coa.setCoahouseaddress(houseaddress);coa.setCoahouseprice(Double.parseDouble(housemoney));coa.setCoahousesize(Double.parseDouble(housesize));coa.setCoastate("看房申请中");String temp=checkoutapplicationService.insertApply(coa);mav.addObject("apply", temp);
public String adminselectPaidAll(QueryVo vo, @RequestParam(value = "pn", defaultValue = "1") Integer pn,Model model) {// 引用PageHelper分页插件PageHelper.startPage(pn, 10);List<rentcollection> rentlists = rentcollectionService.selectPaidAll(vo);for (rentcollection temp : rentlists) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");String date = sdf.format(temp.getRcdate());temp.setRcdatetemp(date);if(temp.getRcpaiddate()!=null) {String Rcpaiddate = sdf.format(temp.getRcpaiddate());
}/** 推荐房屋列表*/@RequestMapping("/recommendlist")public String recommendlist(Model model, @RequestParam(value = "pn", defaultValue = "1") Integer pn,@RequestParam(required = false, defaultValue = "6") Integer pageSize) {PageHelper.startPage(pn, 10);List<leaseinformation> leaseinformation = leaseinformationService.selectAllLeasable();PageInfo<leaseinformation> p = new PageInfo<leaseinformation>(leaseinformation, 3);model.addAttribute("p", p);return "recommendhouse";
userlistService.deleteByPrimaryKey(id);return "redirect:pagingselectuser.do";}/*** 添加房源* * @throws IOException* @throws IllegalStateException*/@RequestMapping("/addhouse")public String addhouse(String housecall, String address, String area, String rent, String housetype, String[] state,@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request)throws IllegalStateException, IOException {if (housecall.equals("") || address.equals("") || area.equals("") || rent.equals("") || state.equals("")
ModelAndView mav = new ModelAndView("housedel");System.out.println(checkoutapplicationService.updateState("已拒绝", id));return mav;}/*** 分页查找所有用户*/@RequestMapping("/pagingselectuser")public String pagingselectuser(Model model, @RequestParam(value = "pn", defaultValue = "1") Integer pn,@RequestParam(required = false, defaultValue = "6") Integer pageSize) {PageHelper.startPage(pn, 10);
* 报障状态修改*/@RequestMapping("/adminrepairwait")public String updaterepairwait(Integer id) {fault fault = faultService.selectByPrimaryKey(id);String fhouseid = fault.getFhouseid();String fhouseaddress = fault.getFhouseaddress();Double fprice = fault.getFprice();Date fdate = fault.getFdate();String fcontent = fault.getFcontent();String fusername = fault.getFusername();String fuserid = fault.getFuserid();String fuserphone = fault.getFuserphone();String fstate = "已处理";fault f = new fault(fhouseid, fhouseaddress, fprice, fdate, fcontent, fusername, fuserid, fuserphone, fstate,id);faultService.updateByPrimaryKey(f);return "redirect:/admin/Adminselectrepairwait.do";}/*** 报障删除*/@RequestMapping("/adminrepairdone")
*/@RequestMapping("/updatemydailylife")public String mydailylifeupdate1(Integer id, HttpServletRequest request) {mydailylife mydailylife = mydailylifeService.selectByPrimaryKey(id);request.setAttribute("mydailylife", mydailylife);return "scheduleupdate";}@RequestMapping("/toupdate")public String mydailylifeupdate2(mydailylife mydailylife) {mydailylifeService.updateByPrimaryKey(mydailylife);return "redirect:/admin/schedulelist.do";}/*** 删除日程*/
*/@Controller@RequestMapping("/leaseinformationmvc")public class LeaseinformationController {@AutowiredLeaseinformationService leaseinformationService;@RequestMapping("/details")public ModelAndView listCategory(@RequestParam int id){ModelAndView mav = new ModelAndView("details");List<leaseinformation> cs= leaseinformationService.allANDimg1(id);for (leaseinformation leaseinformation : cs) {System.out.println(leaseinformation.getLeaseimg().getImgroute());}// 放入转发参数
} catch (NullPointerException e) {if (tempstr == null) {request.setAttribute("erorr", "输入账号密码有误!");return "login";} else {return "official";}}}if (identity[0].equals("admin")) {adminlist temp = new adminlist();temp.setAdminname(username);temp.setAdminpwd(pwd);adminlist adminlist = adminListService.findAllAdminPwd(temp);try {tempstr = adminlist.getAdminname();if (tempstr != null) {session.setAttribute("admin", tempstr);return "BackgroundHome";}} catch (NullPointerException e) {request.setAttribute("erorr", "输入账号密码有误!");return "login";
headportraitimg headportraitimg = headPortraitImgService.selectheadportrait(tempstr);if (headportraitimg.getHeadportraitimgaddress() != null) {session.setAttribute("headportraitimg", headportraitimg.getHeadportraitimgaddress());}return "official";}} catch (NullPointerException e) {if (tempstr == null) {request.setAttribute("erorr", "输入账号密码有误!");return "login";} else {return "official";}}}if (identity[0].equals("admin")) {adminlist temp = new adminlist();temp.setAdminname(username);temp.setAdminpwd(pwd);adminlist adminlist = adminListService.findAllAdminPwd(temp);try {tempstr = adminlist.getAdminname();if (tempstr != null) {
// 获得文件类型(可以判断如果不是图片,禁止上传)String contentType = file.getContentType();// 获得文件后缀名称String imageName = contentType.substring(contentType.indexOf("/") + 1);path = "C://Users/Rain/Desktop/ssm_leaseOfHouses/WebContent/leaseimg/" + uuid + "." + imageName;file.transferTo(new File(path));imgname = uuid + "." + imageName;}leaseimg img = new leaseimg();img.setImgname(address);img.setImgroute(imgname);
}} catch (NullPointerException e) {request.setAttribute("erorr", "选择登录方式!");e.printStackTrace();return "login";}return "login";}/*** 注册*/@RequestMapping("/register")
/***退房申请*/@RequestMapping("/tzshenqing")public ModelAndView tzshenqing(@RequestParam int pn) {ModelAndView mav = new ModelAndView("housedel");// 设置分页传输PageHelper.startPage(pn, 10);// 查询所有数据List<checkoutapplication> list = checkoutapplicationService.selectCoaState1();// 使用PageInFo封装查询结果
//令牌验证if(!new Koken().kokenid(request, session)) {return mav;}mav.addObject("news", "official");if ((String) session.getAttribute("user") == null) {mav.addObject("apply", "请先登录!");return mav;}// 查询所有数据userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));if (user.getUsername() == null) {// 判断真实姓名是否为空
if (tempstr != null) {session.setAttribute("admin", tempstr);return "BackgroundHome";}} catch (NullPointerException e) {request.setAttribute("erorr", "输入账号密码有误!");return "login";}}} catch (NullPointerException e) {request.setAttribute("erorr", "选择登录方式!");e.printStackTrace();return "login";}return "login";}/*** 注册*/
if (headportraitimg.getHeadportraitimgaddress() != null) {session.setAttribute("headportraitimg", headportraitimg.getHeadportraitimgaddress());}return "official";}} catch (NullPointerException e) {if (tempstr == null) {request.setAttribute("erorr", "输入账号密码有误!");return "login";} else {return "official";}}}if (identity[0].equals("admin")) {adminlist temp = new adminlist();temp.setAdminname(username);temp.setAdminpwd(pwd);adminlist adminlist = adminListService.findAllAdminPwd(temp);try {tempstr = adminlist.getAdminname();if (tempstr != null) {session.setAttribute("admin", tempstr);return "BackgroundHome";
ModelAndView mav = new ModelAndView("rentinglist");// 设置分页传输PageHelper.startPage(pn, 10);// 查询所有数据List<leaseinformation> list = leaseinformationService.selecthousteaseWith("出租中");// 使用PageInFo封装查询结果PageInfo<leaseinformation> pageInfo = new PageInfo<leaseinformation>(list, 5);// 放入转发参数mav.addObject("cs", pageInfo);return mav;}@RequestMapping("/delectcontract")public ModelAndView delectcontract(@RequestParam int id) {ModelAndView mav = new ModelAndView("rentinglist");
userlistService.insert(user);headportraitimg userimg = new headportraitimg();userimg.setHeadportraitimgusername(usercall);headPortraitImgService.insertuserimg(userimg);return "login";}/*** 获取手机验证码**/@RequestMapping("/getcode")public void getcode(String userphone, HttpServletResponse response, HttpServletRequest request) {response.setCharacterEncoding("UTF-8");try {HttpSession session = request.getSession();String code = "123456";//String code = Code.getNum(userphone);System.out.println(code);session.setAttribute("code", code);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}
// 生成uuid作为文件名称String uuid = UUID.randomUUID().toString().replaceAll("-", "");// 获得文件类型(可以判断如果不是图片,禁止上传)String contentType = file.getContentType();// 获得文件后缀名称String imageName = contentType.substring(contentType.indexOf("/") + 1);path = "C://Users/Rain/Desktop/ssm_leaseOfHouses/WebContent/leaseimg/" + uuid + "." + imageName;file.transferTo(new File(path));imgname = uuid + "." + imageName;}leaseimg img = new leaseimg();img.setImgname(address);img.setImgroute(imgname);leaseimgService.insert(img);int id = leaseimgService.selectAll().get(leaseimgService.selectAll().size() - 1).getId();leaseinformation house = new leaseinformation();house.setHouseaddress(address);house.setHousesize(Double.valueOf(area));house.setHousemoney(rent);house.setHousestate(state[0]);house.setHousecall(housecall);//获取当前时间和一个月后的时间
// 使用PageInFo封装查询结果PageInfo<checkoutapplication> pageInfo = new PageInfo<checkoutapplication>(list, 5);// 放入转发参数mav.addObject("cs", pageInfo);return mav;}/*** 预约看房申请*/@RequestMapping("/tonyizp")public ModelAndView tonyizp(@RequestParam int id, String housecall, String name) throws ParseException {ModelAndView mav = new ModelAndView("houseapply");checkoutapplicationService.xgaiCoaState("已同意", id);leaseinformation house = leaseinformationService.selectHouseCall(housecall).get(0);SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
// 引用PageHelper分页插件PageHelper.startPage(pn, 10);List<rentcollection> rentlists = rentcollectionService.selectPaidStateAll(rcstate);PageInfo<rentcollection> page = new PageInfo<rentcollection>(rentlists, 3);model.addAttribute("rent", page);return "rentwait";}/*** 删除租金缴纳记录*/@RequestMapping("/admindelrent")public String delrent(Integer id) {rentcollectionService.deleteByPrimaryKey(id);return "redirect:/admin/adminselectPaidAll.do";}/*** 搜索查询*/@RequestMapping("/adminselectPaidAll")public String adminselectPaidAll(QueryVo vo, @RequestParam(value = "pn", defaultValue = "1") Integer pn,