微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

基于springboot的房屋租赁系统

博主主页猫头鹰源码

博主简介:Java领域优质创作者、CSDN博客专家、公司架构师、全网粉丝5万+、专注Java技术领域和毕业设计项目实战

主要内容:毕业设计(Javaweb项目|小程序等)、简历模板、学习资料、面试题库、技术咨询

文末联系获取

项目介绍: 

该系统创作于2022年5月,经过详细的数据库设计。基于springboot技术,数据层为MyBatis,MysqL数据库页面采用html,具有完整的业务逻辑,适合话题:房屋租赁、房屋、酒店、民宿等,项目具有租赁的完整流程。

项目功能

登录注册功能,分为三种用户权限(不能注册管理员)
租户、房东、管理员
租户页面:能够管理个人信息、查看房源(支持条件查找)、查看租房信息和租金信息(不用做出支付功能,有个表格就行)
房东页面:能够管理个人信息、发布房源、修改房源状态(“已签”、“洽谈中”、“已预订”)、管理租金(租客代缴租金、租客已缴租金)
租户和房东都有一个我要反馈功能,反馈给管理员(可做可不做)
管理员用户管理(修改用户账号信息和用户权限)、房源管理、查看反馈、简单的统计报表查看
可视界面不要求过分复杂,简洁明了即可

数据库表结构文档:

系统包含技术:

后端:springBoot、mybatis
前端:bootstrap、js、css等,html页面
开发工具:idea
数据库MysqL 5.7
JDK版本:jdk1.8

部分截图说明:

下面是用户首页,展示最新的房屋信息

下面是房屋列表,分页展示,也可以筛选

 房源详情,有详细的介绍

下面是后台登录管理员和房东可以登录

 管理员首页

管理员对房源的管理,不能添加,由房东添加房源

管理员对房东维护

管理员查看统计信息

房东新增房源信息,可以维护基本信息以及图片

部分代码

 /**进入列表页面*/
    @GetMapping("/Feedback")
    public String userIframe(){
        return "FeedbackList";
    }

    /**列表数据*/
    @GetMapping("/list")
    @ResponseBody
    public PageResultVo findFeedback(Feedback Feedback, Integer limit, Integer page, HttpSession session){
        String type = (String)session.getAttribute("type");
        if(type.equals("02")){
            Manage manage = (Manage)session.getAttribute("userInfo");
            Feedback.setType("01");
            Feedback.setHmid(String.valueOf(manage.getId()));
        }
        if(type.equals("03")){
            User user = (User)session.getAttribute("userInfo");
            Feedback.setType("02");
            Feedback.setHmid(String.valueOf(user.getId()));
        }
        pageHelper.startPage(page,limit);
        List<Feedback> FeedbackList = FeedbackService.selectByCondition(Feedback);
        for(int i=0;i<FeedbackList.size();i++){
            if(FeedbackList.get(i).getHmid()!=null){
                if(FeedbackList.get(i).getType().equals("01")){
                    Manage manage = manageService.selectById(FeedbackList.get(i).getHmid());
                    FeedbackList.get(i).setHmname(manage.getRealname());
                }else{
                    User user = userService.selectById(FeedbackList.get(i).getHmid());
                    FeedbackList.get(i).setHmname(user.getRealname());
                }
            }
        }
        PageInfo<Feedback> pages = new PageInfo<>(FeedbackList);
        return JsonData.table(FeedbackList,pages.getTotal());
    }


    /**编辑详情*/
    @GetMapping("/edit")
    @ResponseBody
    public Feedback edit(Model model, String id){
        return FeedbackService.selectById(id);
    }


    /**编辑*/
    @PostMapping("/edit")
    @ResponseBody
    public JsonData edit(Feedback Feedback){
        int a = FeedbackService.updateById(Feedback);
        if (a > 0) {
          return JsonData.success(null,"编辑成功!");
        } else {
          return JsonData.fail("编辑失败");
        }
    }


    /**删除*/
    @PostMapping("/del")
    @ResponseBody
    public JsonData del(String id){
        try{
          FeedbackService.deleteById(Integer.parseInt(id));
        }catch(Exception ex){
          JsonData.fail("出现错误");
        }
        return JsonData.success(null,"删除成功");
    }

    /**新增*/
    @PostMapping("/add")
    @ResponseBody
    public JsonData add(Feedback Feedback, HttpSession session){
        Date date = new Date();
        Feedback.setCreateTime(date);
        String type = (String)session.getAttribute("type");
        if(type.equals("02")){
            Manage manage = (Manage)session.getAttribute("userInfo");
            Feedback.setHmid(String.valueOf(manage.getId()));
            Feedback.setType("01");
        }
        if(type.equals("03")){
            User user = (User)session.getAttribute("userInfo");
            Feedback.setHmid(String.valueOf(user.getId()));
            Feedback.setType("02");
        }
        int num = FeedbackService.addByCondition(Feedback);
        if(num > 0){
          return JsonData.success(null,"添加成功");
        }else {
          return JsonData.fail("添加失败");
        }
    }

下面是文件上传的核心代码

 /**
     * 文件上传
     * @param dropFile
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/avatar", method = RequestMethod.POST)
    public Map<String, Object> acticleAvatar(multipartfile dropFile, HttpServletRequest request) throws IOException {
        Map<String, Object> result = new HashMap<>();
        //获取文件后缀
        String fileName = dropFile.getoriginalFilename();
        String fileSuffix = fileName.substring(fileName.lastIndexOf('.'));
        //文件存放路径
        String fileDirPath = new String(uploadDir);
        File fileDir = new File(fileDirPath);
        //判断文件是否存在
        if (!fileDir.exists()){
            fileDir.mkdirs();
        }
        File file = new File(fileDir.getAbsolutePath()+ File.separator+ UUID.randomUUID() + fileSuffix);
        try {
            dropFile.transferTo(file);
        } catch (IOException e) {
            e.printstacktrace();
        }
        //传到前端
        result.put("fileName", "http://localhost:"+port+"/upload/"+file.getName());
        return result;
    }


    /**
     * 后台内容图片上传
     * @param dropFile
     * @param request
     * @return
     */
    @RequestMapping(value = "/ContentUpload", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> hotelContentUpload(multipartfile dropFile, HttpServletRequest request) {
        Map<String, Object> result = new HashMap<>();
        //获取文件后缀
        String fileName = dropFile.getoriginalFilename();
        String fileSuffix = fileName.substring(fileName.lastIndexOf('.'));
        //文件存放路径
        String fileDirPath = new String(uploadDir);
        File fileDir = new File(fileDirPath);
        //判断文件是否存在
        if (!fileDir.exists()){
            fileDir.mkdirs();
        }
        File file = new File(fileDir.getAbsolutePath()+ File.separator+ UUID.randomUUID() + fileSuffix);
        try {
            dropFile.transferTo(file);
        } catch (IOException e) {
            e.printstacktrace();
        }
        //传到前端
        result.put("errno",0);
        result.put("data",new String[] {"http://localhost:"+port+"/upload/" + file.getName()});
        return result;
    }

用户登录功能

/**
	 * 登录
	 * 将提交数据(username,password)写入Admin对象
	 */
	@RequestMapping(value = "/login")
	@ResponseBody
	public String login(String username, String password, String type, Model model, HttpSession session) {
		Map mp = new HashMap();
		if(username.equals("") || password.equals("")){
			return "202";
		}
		if(type.equals("01")){
			mp.put("username",username);
			mp.put("password",password);
			List<Admin> admins = adminService.queryFilter(mp);
			if(admins!=null && admins.size()==1){
				session.setAttribute("userInfo", admins.get(0));
				session.setAttribute("type", "01");
			}else{
				return "201";
			}
		}else if(type.equals("02")){
			mp.put("phone",username);
			mp.put("password",password);
			mp.put("type","01");
			List<Manage> manages = manageService.queryFilter(mp);
			if(manages!=null && manages.size()==1){
				session.setAttribute("userInfo", manages.get(0));
				session.setAttribute("type", "02");
			}else{
				return "201";
			}
		}else{
			mp.put("phone",username);
			mp.put("password",password);
			mp.put("type","02");
			List<User> users = userService.queryFilter(mp);
			if(users!=null && users.size()==1){
				session.setAttribute("userInfo", users.get(0));
				session.setAttribute("type", "03");
				return "203";
			}else{
				return "201";
			}
		}
		return "200";
	}

以上就是部分功能展示,从整体上来看,本系统功能是十分完整的,界面设计简洁大方,交互友好,数据库设计也很合理,规模适中,代码工整,清晰,适合学习使用。

好了,今天就到这儿吧,小伙伴们点赞、收藏、评论,一键三连走起呀,下期见~~

原文地址:https://www.jb51.cc/wenti/3280187.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐