Java项目:150SpringBoot的房屋租赁系统(含论文)

发布时间:2023年12月28日
?作者主页:夜未央5788

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

文末获取源码

项目介绍

基于springboot房屋出租系统 有前台和后台


登陆角色:用户+房东+管理员

前台功能模块:登陆+注册+整租+合租+租房+新闻资讯+用户反馈+搜索+忘记密码+联系房东等

后台功能模块: 用户端:订单管理+个人信息+我的家+我的收藏+密码修改+我的反馈 管理员端:房子管理+订单管理+新闻资讯管理+反馈管理+用户管理+个人信息+我的收藏+密码修改 房东端:房子管理+订单管理+个人信息+我的收藏+密码修改+我的反馈

使用人群:
正在做毕设的学生,或者需要项目实战练习的Java学习者

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;?
4.数据库:MySql 5.7/8.0版本均可;

5.是否Maven项目:是;

技术栈

后端:SpringBot(Spring+SpringMVC+Mybatis)

前端: JSP、 css 、JavaScript、JQuery、Ajax

使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入地址:http://localhost:9999/
管理员账号、密码:admin/123456
房东账号、密码:fangdong/123456
用户账号、密码:zuke/123456

运行截图

论文

前台界面

后管界面

相关代码

IndexController

package com.irental.houserent.controller.front;


import com.irental.houserent.common.base.BaseController;
import com.irental.houserent.common.constant.Constant;
import com.irental.houserent.common.enums.HouseRentTypeEnum;
import com.irental.houserent.service.HouseService;
import com.irental.houserent.service.OrderService;
import com.irental.houserent.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import static com.irental.houserent.common.util.getLocation.getlocation;

//前端首页控制器
@Controller
public class IndexController extends BaseController {
    @Autowired
    private OrderService orderService;

    @Autowired
    private HouseService houseService;

    @Autowired
    private UserService userService;

    /*
     * 前端首页*/
    @RequestMapping(value = "/")
    @CrossOrigin(origins = "*")
    public String index(Model model) {
        //获取用户现在的位置(以省级为单位)
        String location = getlocation();
        //最新的整租
        model.addAttribute("recentWholeHouseList", houseService.findTopList(HouseRentTypeEnum.WHOLE.getValue(), Constant.INDEX_HOUSE_NUM));
        //最新的合租
        model.addAttribute("recentShareHouseList", houseService.findTopList(HouseRentTypeEnum.SHARE.getValue(), Constant.INDEX_HOUSE_NUM));
        //获取三条用户当前位置的民宿
        model.addAttribute("locationHouseList", houseService.findByLocation(location, Constant.INDEX_HOUSE_LOCATION_NUM));
        //增加地理位置信息
        model.addAttribute("userLocation", location);

        return "front/index";
    }


}

HouseController

package com.irental.houserent.controller.front;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.irental.houserent.common.base.BaseController;
import com.irental.houserent.common.enums.HouseRentTypeEnum;
import com.irental.houserent.common.util.PageUtil;
import com.irental.houserent.common.vo.HouseSearchVO;
import com.irental.houserent.entity.House;
import com.irental.houserent.entity.Order;
import com.irental.houserent.entity.User;
import com.irental.houserent.service.HouseService;
import com.irental.houserent.service.OrderService;
import com.irental.houserent.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/*
 * 前端房屋信息控制器
 * */
@Controller("frontHouseController")
public class HouseController extends BaseController {
    @Autowired
    private HouseService houseService;

    @Autowired
    private OrderService orderService;

    @Autowired
    private UserService userService;

    /*
     * 房屋详情
     * */
    @RequestMapping("/house/detail/{id}")
    public String houseDetail(@PathVariable("id") Long id, Model model) {
        //根据ID查询房屋
        House house = houseService.get(id);
        if (house == null) {
            return renderNotFound();
        }
        //处理轮播图URL
        List<String> slideList = JSON.parseArray(house.getSlideUrl(), String.class); // to list
        house.setSlideImgList(slideList);

        //如果是合租房屋,查询合租房屋。
        List<House> shareHouseList = houseService.findByUserIdAndCertificateNoAndRentType(house.getUserId(), house.getCertificateNo(), HouseRentTypeEnum.SHARE.getValue());
        //从订单里查找到租户ID,把租户放到每个房子里
        if (shareHouseList != null && shareHouseList.size() > 0) {
            for (House houseTemp : shareHouseList) {
                Order currentOrder = orderService.getCurrentEffectiveOrder(houseTemp.getId());
                if (currentOrder != null) {
                    User customerUser = userService.get(currentOrder.getCustomerUserId());
                    currentOrder.setCustomerUser(customerUser);
                    houseTemp.setCurrentOrder(currentOrder);
                }
            }
        }
        house.setShareHouseList(shareHouseList);
        model.addAttribute("house", house);
        return "front/house-detail";
    }

    /*
     * 房屋地图页面
     * */
    @RequestMapping("/house/map")
    public String map(@RequestParam("id") Long id, Model model) {
        //根据ID查询房屋
        House house = houseService.get(id);
        if (house == null) {
            return renderNotFound();
        }
        String longitudeLatitude = house.getLongitudeLatitude();
        String[] arr = longitudeLatitude.split(",");
        model.addAttribute("longitude", arr[0]);
        model.addAttribute("latitude", arr[1]);
        model.addAttribute("address", house.getAddress());
        return "front/house-map";
    }

    /*
     * 房屋列表
     * */
    @RequestMapping("/house")
    public String houseList(HouseSearchVO houseSearchVO, Model model) {
        Page page = PageUtil.initMpPage(houseSearchVO.getPage(), houseSearchVO.getSize());
        Page<House> housePage = houseService.getHousePage(houseSearchVO, page);
        model.addAttribute("pageInfo", housePage);
        model.addAttribute("houseSearchVO", houseSearchVO);
        model.addAttribute("pagePrefix", houseSearchVO.getPagePrefix());
        return "front/house-list";
    }
}

MarkController

package com.irental.houserent.controller.front;

import com.irental.houserent.common.base.BaseController;
import com.irental.houserent.common.dto.JsonResult;
import com.irental.houserent.entity.Mark;
import com.irental.houserent.entity.User;
import com.irental.houserent.service.MarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/*
 * 收藏控制器
 * */
@Controller
public class MarkController extends BaseController {
    @Autowired
    private MarkService markService;
    /*
     * 收藏提交
     * */

    @RequestMapping(value = "/mark/submit", method = RequestMethod.POST)
    @ResponseBody
    public JsonResult submit(@RequestParam("houseId") Long houseId) {
        //判断用户是否已登录
        User loginUser = getLoginUser();
        if (loginUser == null) {
            return JsonResult.error("请先登录");
        }
        //判断是否已经收藏过
        List<Mark> markList = markService.findByUserIdAndHouseId(loginUser.getId(), houseId);
        if (markList != null && markList.size() > 0) {
            return JsonResult.error("您已收藏过了。");
        }
        Mark mark = new Mark();
        mark.setCreateTime(new Date());
        mark.setUserId(loginUser.getId());
        mark.setHouseId(houseId);
        markService.insert(mark);
        return JsonResult.success("收藏成功!");
    }
}

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

文章来源:https://blog.csdn.net/hanyunlong1989/article/details/135258049
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。