源码获取:俺的博客首页 "资源" 里下载!
项目介绍
本项目分为前后台,角色分为:管理员、用户、中介三种角色
用户可访问网站前台,访问网站首页、新闻公告、房屋出售查看、房屋出租查看、注册、登录等;
用户登录后可查看我的订购、我的预约看房、在线留言、我的留言、修改资料等;
管理员登陆后,主要模块包括主页、房屋区域管理、出售房屋审核、出租房屋审核、留言管理、新闻公告管理、管理员管理、中介管理、用户管理等功能
中介登陆后,主要模块包括主页、购房订单管理、出售房屋管理、预约看房管理、租房信息管理、个人资料管理等功能
环境需要
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.是否Maven项目: 否;
6.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:JSP+CSS+JS+JQUERY+Bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/house/ 登录
用户账号:用户1 密码:123
中介账号:中介1 密码:1234
管理员账号:admin 密码:admin
首页页面展示:
房屋出租页面展示:
出售房屋页面展示:
用户信息展示:
后台管理展示页面:
留言列表展示:
后台所有模块展示:
新闻公告列表展示:
房屋信息列表展示:
用户列表展示:
用户管理控制层:
@Controller
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/login")
public String userList() throws Exception{
return "login";
}
@RequestMapping("/logincheck")
public String login(User user,Model model,HttpSession httpSession) throws Exception{
User user1=userService.login(user);
if(user1!=null){
httpSession.setAttribute("user", user1);
if(user1.getType().equals("zuke")){
return "zuke/main";
}
else{
return "admin/main1";
}
}else{
String error="error";
model.addAttribute("error", error);
return "login";
}
}
@RequestMapping("/toindex")
public String toindex(Model model) throws Exception{
return "admin/index";
}
}
房屋管理控制层:
@Controller
public class HoustlistController {
@Autowired
private HouselistService houselistService;
@RequestMapping("/houselist")
public String houselist(Model model ,@RequestParam(required=false,defaultValue="1") Integer page,
@RequestParam(required=false,defaultValue="6") Integer pageSize){
PageHelper.startPage(page, pageSize);
List<Houselist> houselist=houselistService.selectAll();
PageInfo<Houselist> p=new PageInfo<Houselist>(houselist);
model.addAttribute("p", p);
model.addAttribute("houselist",houselist);
model.addAttribute("mainPage","houselist.jsp");
return "zuke/main";
}
@RequestMapping("/ahouselist")
public String ahouselist(Model model ,@RequestParam(required=false,defaultValue="1") Integer page,
@RequestParam(required=false,defaultValue="6") Integer pageSize){
PageHelper.startPage(page, pageSize);
List<Houselist> houselist=houselistService.selectAll();
PageInfo<Houselist> p=new PageInfo<Houselist>(houselist);
model.addAttribute("p", p);
model.addAttribute("houselist",houselist);
model.addAttribute("mainPage","ahouselist.jsp");
return "admin/main1";
}
@RequestMapping("/addhouse")
public String addhouse(Model model ,Houselist houselist){
String houseid=houselist.getHouseid();
Houselist houselist1=houselistService.findhouseid(houseid);
if(houselist1!=null){
model.addAttribute("error","该房屋id已存在");
model.addAttribute("houselist",houselist);
model.addAttribute("mainPage","addhouse.jsp");
return "admin/main1";
}else{
model.addAttribute("error","添加成功");
houselistService.inserthouse(houselist);
model.addAttribute("houselist",houselist);
model.addAttribute("mainPage","addhouse.jsp");
return "admin/main1";
}
}
@RequestMapping("/toaddhouse")
public String toaddhoust(Model model){
model.addAttribute("mainPage","addhouse.jsp");
return "admin/main1";
}
@RequestMapping("/deletehouse")
public String deletehouse(Integer id){
houselistService.deletehouse(id);
return "redirect:ahouselist.action";
}
@RequestMapping("/toahouselist")
public String toahouselist(){
return "ahouselist.action";
}
@RequestMapping("/findid")
public String findid(Integer id,Model model){
Houselist list=houselistService.findid(id);
model.addAttribute("houselist",list);
model.addAttribute("mainPage", "changehouse.jsp");
return "admin/main1";
}
@RequestMapping("/findhouseidupdate")
public String findhouseidupdate(Houselist houselist,Model model){
Houselist list=houselistService.findhouseidupdate(houselist);
if(list!=null){
model.addAttribute("houselist",houselist);
model.addAttribute("mainPage", "changehouse.jsp");
model.addAttribute("error","该房屋id已存在");
return "admin/main1";
}
else{
houselistService.updatehouse(houselist);
model.addAttribute("houselist",houselist);
model.addAttribute("mainPage", "changehouse.jsp");
model.addAttribute("error","更新成功");
return "admin/main1";
}
}
}
合同管理控制层:
@Controller
@RequestMapping("/hetong")
public class HetongController {
@Autowired
private HetongService hetongService;
@Autowired
private HouselistService houselistService;
@Autowired
private ApplyService applyService;
@Autowired
private ZulistService zulistService;
@Autowired
private CheckoutService checkoutService;
//新增合同信息,修改房屋列表的状态,从申请列表中删除,增添到租赁列表当中
@RequestMapping("/inserthetong")
public String inserthetong(Model model,Hetong hetong){
//新增合同信息
hetongService.inserthetong(hetong);
Hetong hetong1=hetongService.findhetong(hetong.getHouse_id());
//修改房屋列表状态
Houselist houselist=houselistService.findhouseid(hetong1.getHouse_id());
houselist.setStatus("已租赁");
houselistService.updatehousestatus(houselist);
//添加到租赁列表当中
Zulist zulist=new Zulist();
Apply apply=applyService.findbyhouse_id(hetong.getHouse_id());
zulist.setHouse_id(hetong.getHouse_id());
zulist.setUserlist_id(apply.getUserlist_id());
zulist.setContract_id(hetong1.getId());
zulist.setPrice(apply.getPrice());
zulist.setAddress(apply.getAddress());
zulistService.insertzulist(zulist);
//从申请列表中删除
applyService.deletebyhouse_id(hetong1.getHouse_id());
model.addAttribute("error", "zusuccess");
return "redirect:/zulist/findzulist.action";
}
@RequestMapping("/seehetong")
public String seehetong(String house_id,Model model){
Hetong hetong=hetongService.findhetong(house_id);
model.addAttribute("hetong", hetong);
model.addAttribute("mainPage", "hetong.jsp");
return "admin/main1";
}
@RequestMapping("/updatehetong")
public String updatehetong(String house_id,Model model){
Hetong hetong=hetongService.findhetong(house_id);
model.addAttribute("hetong", hetong);
model.addAttribute("mainPage", "updatehetong.jsp");
return "admin/main1";
}
@RequestMapping("/changehetong")
public String changehetong(Hetong hetong){
hetongService.updatehetong(hetong);
return "redirect:/zulist/findzulist.action";
}
//终止合同操作:删除合同,插入已退租列表,删除在租列表,删除房屋列表
@RequestMapping("/deletehetong")
public String deletehetong(String house_id,Model model){
hetongService.deletehetong(house_id);
Zulist zulist=zulistService.findzulist(house_id);
Checkout checkout=new Checkout();
checkout.setHouse_id(house_id);
checkout.setAddress(zulist.getAddress());
checkout.setStatus("已退租");
checkout.setUserlist_id(zulist.getUserlist_id());
checkoutService.insertcheckout(checkout);
houselistService.deletehousebyhouseid(house_id);
zulistService.deletezulist(house_id);
model.addAttribute("error", "checkoutsuccess");
return "redirect:/zulist/findzulist.action";
}
@RequestMapping("/zukeseehetong")
public String zukeseehetong(String house_id,Model model){
Hetong hetong=hetongService.findhetong(house_id);
model.addAttribute("hetong", hetong);
model.addAttribute("mainPage", "showhetong.jsp");
return "zuke/main";
}
}
源码获取:俺的博客首页 "资源" 里下载!