• Java项目:ssm房屋租赁管理系统


    作者主页:源码空间站2022

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    本项目分为管理员与租户2种角色:
    管理员主要功能包括:
    登录、查看房源信息、添加房源、查看租赁情况、合同查看、看房申请、退租申请、报障、租金管理、日程管理、账户管理

    租户主要功能包括:
    登录、查看房源信息、我的租赁、看房申请、退租申请、租金管理、报障
     

    环境配置

    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项目: 否;

    技术栈

    1. 后端:spring+springmvc+mybatis
    2. 前端:JSP+css+javascript+jQuery+bootstrap

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
    4. 运行项目,输入http://localhost:8080/text2 登录 
    管理员账号密码:admin/123456
    租户账号密码:admin/123456

    运行截图

    相关代码 

    ApplyController

    1. package controller;
    2. import java.util.List;
    3. import javax.servlet.http.HttpSession;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.stereotype.Controller;
    6. import org.springframework.ui.Model;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import org.springframework.web.bind.annotation.RequestParam;
    9. import com.github.pagehelper.PageHelper;
    10. import com.github.pagehelper.PageInfo;
    11. import Pojo.Apply;
    12. import Pojo.Houselist;
    13. import Pojo.User;
    14. import Pojo.Userlist;
    15. import Pojo.Zulist;
    16. import service.ApplyService;
    17. import service.HouselistService;
    18. import service.UserlistService;
    19. @Controller
    20. public class ApplyController {
    21. @Autowired
    22. private UserlistService userlistService;
    23. @Autowired
    24. private HouselistService houselistService;
    25. @Autowired
    26. private ApplyService applyService;
    27. //申请看房
    28. @RequestMapping("/applycheckuserlist")
    29. public String applycheckuserlist(HttpSession httpSession,Model model,Integer id){
    30. User user1= (User) httpSession.getAttribute("user");
    31. Integer user_id=user1.getId();
    32. Userlist list=userlistService.findhasuserlist(user_id);
    33. if(list==null){
    34. model.addAttribute("error", "applycheck");
    35. return "redirect:houselist.action";
    36. }else{
    37. Houselist houselist=houselistService.findid(id);
    38. houselist.setStatus("已被申请");
    39. houselistService.updatehousestatus(houselist);
    40. Integer userlist_id=list.getId();
    41. Apply apply=new Apply();
    42. apply.setHouse_id(houselist.getHouseid());
    43. apply.setAddress(houselist.getAddress());
    44. apply.setPrice(houselist.getPrice());
    45. apply.setArea(houselist.getArea());
    46. apply.setStatus("申请中");
    47. apply.setUserlist_id(userlist_id);
    48. applyService.insertapply(apply);
    49. model.addAttribute("error", "applysuccess");
    50. return "redirect:houselist.action";
    51. }
    52. }
    53. //管理员查看申请看房列表
    54. @RequestMapping("/findapplylist")
    55. public String findapplylist(Model model,@RequestParam(required=false,defaultValue="1") Integer page,
    56. @RequestParam(required=false,defaultValue="2") Integer pageSize) throws Exception{
    57. PageHelper.startPage(page, pageSize);
    58. List applylist=applyService.findapplylist();
    59. PageInfo p=new PageInfo(applylist);
    60. model.addAttribute("applylist",applylist);
    61. model.addAttribute("p", p);
    62. model.addAttribute("mainPage","applylist.jsp");
    63. return "admin/main1";
    64. }
    65. @RequestMapping("/applychangehousestatus")
    66. public String applychangehousestatus(HttpSession httpSession,Model model,String house_id)throws Exception{
    67. User user1= (User) httpSession.getAttribute("user");
    68. Integer user_id=user1.getId();
    69. Userlist userlist=userlistService.findhasuserlist(user_id);
    70. Houselist houselist=houselistService.findhouseid(house_id);
    71. houselist.setStatus("已租赁");
    72. houselistService.updatehousestatus(houselist);
    73. Zulist zulist=new Zulist();
    74. zulist.setHouse_id(house_id);
    75. zulist.setPrice(houselist.getPrice());
    76. zulist.setAddress(houselist.getAddress());
    77. return "";
    78. }
    79. //管理员拒绝看房申请
    80. @RequestMapping("/refuseapply")
    81. public String refuseapply(String house_id,Model model){
    82. Houselist houselist=new Houselist();
    83. houselist.setHouseid(house_id);
    84. houselist.setStatus("未租赁");
    85. applyService.refuseapply(houselist);
    86. return "redirect:findapplylist.action";
    87. }
    88. //租客查看自己的 看房申请
    89. @RequestMapping("/getmyapply")
    90. public String getmyapply(Model model,HttpSession httpSession,@RequestParam(required=false,defaultValue="1") Integer page,
    91. @RequestParam(required=false,defaultValue="2") Integer pageSize){
    92. User user1= (User) httpSession.getAttribute("user");
    93. Userlist userlist=userlistService.findhasuserlist(user1.getId());
    94. PageHelper.startPage(page, pageSize);
    95. List list=userlistService.getmyapply(userlist.getId());
    96. PageInfo p=new PageInfo(list);
    97. model.addAttribute("userlist", list);
    98. model.addAttribute("p", p);
    99. model.addAttribute("mainPage", "myapply.jsp");
    100. return "zuke/main";
    101. }
    102. }

    HetongController

    1. package controller;
    2. import org.springframework.beans.factory.annotation.Autowired;
    3. import org.springframework.stereotype.Controller;
    4. import org.springframework.ui.Model;
    5. import org.springframework.web.bind.annotation.RequestMapping;
    6. import Pojo.Apply;
    7. import Pojo.Checkout;
    8. import Pojo.Hetong;
    9. import Pojo.Houselist;
    10. import Pojo.Zulist;
    11. import service.ApplyService;
    12. import service.CheckoutService;
    13. import service.HetongService;
    14. import service.HouselistService;
    15. import service.ZulistService;
    16. @Controller
    17. @RequestMapping("/hetong")
    18. public class HetongController {
    19. @Autowired
    20. private HetongService hetongService;
    21. @Autowired
    22. private HouselistService houselistService;
    23. @Autowired
    24. private ApplyService applyService;
    25. @Autowired
    26. private ZulistService zulistService;
    27. @Autowired
    28. private CheckoutService checkoutService;
    29. //新增合同信息,修改房屋列表的状态,从申请列表中删除,增添到租赁列表当中
    30. @RequestMapping("/inserthetong")
    31. public String inserthetong(Model model,Hetong hetong){
    32. //新增合同信息
    33. hetongService.inserthetong(hetong);
    34. Hetong hetong1=hetongService.findhetong(hetong.getHouse_id());
    35. //修改房屋列表状态
    36. Houselist houselist=houselistService.findhouseid(hetong1.getHouse_id());
    37. houselist.setStatus("已租赁");
    38. houselistService.updatehousestatus(houselist);
    39. //添加到租赁列表当中
    40. Zulist zulist=new Zulist();
    41. Apply apply=applyService.findbyhouse_id(hetong.getHouse_id());
    42. zulist.setHouse_id(hetong.getHouse_id());
    43. zulist.setUserlist_id(apply.getUserlist_id());
    44. zulist.setContract_id(hetong1.getId());
    45. zulist.setPrice(apply.getPrice());
    46. zulist.setAddress(apply.getAddress());
    47. zulistService.insertzulist(zulist);
    48. //从申请列表中删除
    49. applyService.deletebyhouse_id(hetong1.getHouse_id());
    50. model.addAttribute("error", "zusuccess");
    51. return "redirect:/zulist/findzulist.action";
    52. }
    53. @RequestMapping("/seehetong")
    54. public String seehetong(String house_id,Model model){
    55. Hetong hetong=hetongService.findhetong(house_id);
    56. model.addAttribute("hetong", hetong);
    57. model.addAttribute("mainPage", "hetong.jsp");
    58. return "admin/main1";
    59. }
    60. @RequestMapping("/updatehetong")
    61. public String updatehetong(String house_id,Model model){
    62. Hetong hetong=hetongService.findhetong(house_id);
    63. model.addAttribute("hetong", hetong);
    64. model.addAttribute("mainPage", "updatehetong.jsp");
    65. return "admin/main1";
    66. }
    67. @RequestMapping("/changehetong")
    68. public String changehetong(Hetong hetong){
    69. hetongService.updatehetong(hetong);
    70. return "redirect:/zulist/findzulist.action";
    71. }
    72. //终止合同操作:删除合同,插入已退租列表,删除在租列表,删除房屋列表
    73. @RequestMapping("/deletehetong")
    74. public String deletehetong(String house_id,Model model){
    75. hetongService.deletehetong(house_id);
    76. Zulist zulist=zulistService.findzulist(house_id);
    77. Checkout checkout=new Checkout();
    78. checkout.setHouse_id(house_id);
    79. checkout.setAddress(zulist.getAddress());
    80. checkout.setStatus("已退租");
    81. checkout.setUserlist_id(zulist.getUserlist_id());
    82. checkoutService.insertcheckout(checkout);
    83. houselistService.deletehousebyhouseid(house_id);
    84. zulistService.deletezulist(house_id);
    85. model.addAttribute("error", "checkoutsuccess");
    86. return "redirect:/zulist/findzulist.action";
    87. }
    88. @RequestMapping("/zukeseehetong")
    89. public String zukeseehetong(String house_id,Model model){
    90. Hetong hetong=hetongService.findhetong(house_id);
    91. model.addAttribute("hetong", hetong);
    92. model.addAttribute("mainPage", "showhetong.jsp");
    93. return "zuke/main";
    94. }
    95. }

    ZulistController

    1. package controller;
    2. import java.util.List;
    3. import javax.servlet.http.HttpSession;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.stereotype.Controller;
    6. import org.springframework.ui.Model;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import org.springframework.web.bind.annotation.RequestParam;
    9. import com.fasterxml.jackson.databind.util.JSONPObject;
    10. import com.github.pagehelper.PageHelper;
    11. import com.github.pagehelper.PageInfo;
    12. import Pojo.Apply;
    13. import Pojo.Hetong;
    14. import Pojo.User;
    15. import Pojo.Userlist;
    16. import Pojo.Zulist;
    17. import service.UserlistService;
    18. import service.ZulistService;
    19. @Controller
    20. @RequestMapping("/zulist")
    21. public class ZulistController {
    22. @Autowired
    23. private ZulistService zulistService;
    24. @Autowired
    25. private UserlistService userlistService;
    26. //跳到增添合同的页面
    27. @RequestMapping("/toaddhetong")
    28. public String toaddhetong(Model model,String house_id){
    29. Hetong hetong=new Hetong();
    30. hetong.setHouse_id(house_id);
    31. model.addAttribute("hetong", hetong);
    32. model.addAttribute("mainPage", "addhetong.jsp");
    33. return "admin/main1";
    34. }
    35. //管理员查看所有在租列表
    36. @RequestMapping("/findzulist")
    37. public String findzulist(Model model,@RequestParam(required=false,defaultValue="1") Integer page,
    38. @RequestParam(required=false,defaultValue="2") Integer pageSize) throws Exception{
    39. PageHelper.startPage(page, pageSize);
    40. List zulist=zulistService.findzuuserlist();
    41. PageInfo p=new PageInfo(zulist);
    42. model.addAttribute("p", p);
    43. model.addAttribute("zulist", zulist);
    44. model.addAttribute("mainPage", "zulist.jsp");
    45. return "admin/main1";
    46. }
    47. //查看我的在租列表
    48. @RequestMapping("/myzulist")
    49. public String myzulist(Model model,HttpSession httpSession,@RequestParam(required=false,defaultValue="1") Integer page,
    50. @RequestParam(required=false,defaultValue="2") Integer pageSize) throws Exception{
    51. User user1= (User) httpSession.getAttribute("user");
    52. Userlist userlist=userlistService.findhasuserlist(user1.getId());
    53. PageHelper.startPage(page, pageSize);
    54. List list=userlistService.getUserzuList(userlist.getId());
    55. PageInfo p=new PageInfo(list);
    56. model.addAttribute("userlistzu", list);
    57. model.addAttribute("p", p);
    58. model.addAttribute("mainPage", "myzulist.jsp");
    59. return "zuke/main";
    60. }
    61. }

    如果也想学习本系统,下面领取。关注并回复:024ssm 

  • 相关阅读:
    数模5—蒙特卡洛算法、灰色预测
    Node.js躬行记(28)——Cypress自动化测试实践
    django建站过程(1)
    传统机器学习总结
    centos7安装mysql8.0.31
    一次Django SSO简单实现
    Res2Net: 一种新的多尺度主干体系结构(Res2Net: A New Multi-scale Backbone Architecture )
    【 css动画 】—— 把你喜欢css动画嵌入到浏览器中
    angular:html2canvas对ion-avatar节点渲染不正确
    MobPush开发过程常见问题
  • 原文地址:https://blog.csdn.net/m0_74967853/article/details/128156223