基于springboot实现大学生租房系统演示附项目源码

Posted 大雄是个程序员

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于springboot实现大学生租房系统演示附项目源码相关的知识,希望对你有一定的参考价值。

基于springboot实现大学生租房系统演示

开发语言:Java
框架:springboot
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9

伴随着全球信息化发展,行行业业都与计算机技术相衔接,计算机技术普遍运用于各大行业,大学生租房系统便是其中一种。实施计算机系统来管理可以降低大学生租房管理的成本,使整个大学生租房的发展和服务水平有显著提升。

本论文主要面向大学生租房管理中出现的一些常见问题,将其与计算机管理系统结合起来。通过这个系统,用户登录大学生租房系统可以实现首页,房屋信息,房屋评价,公告资讯,个人中心,后台管理,意见反馈等进行相应操作,管理员可以更加方便的管理首页,个人中心,房主管理,用户管理,房屋类型管理,房屋信息管理,预约看房管理,定金留房管理,租赁订单管理,房屋评价管理等内容。计算机管理系统在大学生租房设计中的应用,可以很大程度上提高管理水平,使大学生租房管理获得更好的效果。

但是,这套系统实现的功能只是整个大学生租房管理中的一部分,系统中还存在一些不及之处,需要继续的创新,使其完美。

关键词:Java;大学生租房系统;mysql

研究目标与内容

本大学生租房系统使用简洁的框架结构,专门用于用户浏览首页,房屋信息,房屋评价,公告资讯,个人中心,后台管理,意见反馈等信息,对个人信息进行修改等,以及系统管理员对首页,个人中心,房主管理,用户管理,房屋类型管理,房屋信息管理,预约看房管理,定金留房管理,租赁订单管理,房屋评价管理等的操作。房主对首页,个人中心,房屋信息管理,预约看房管理,定金留房管理,租赁订单管理,房屋评价管理等的操作。系统具有方便性、灵活性、应用性。本大学生租房系统设计使用简洁的框架结构,让管理员,房主和用户登录后的进行相关的操作。

需求分析

本次的毕业设计主要就是在基于Java语言平台下设计并开发一个大学生租房系统软件。运用当前Google提供的Java来实现对大学生租房信息查询。当然使用的数据库是Mysql。尽管没有面向对象的数据库的作用强大,但是在Java开发上还是比较的灵活和方便的。系统功能主要介绍以下几点:

  1. 欢迎界面功能

欢迎界面是在运行该软件时的第一个要显示的界面,出现在菜单界面之前。主要就是显示欢迎使用大学生租房系统。只要用户开启该软件,就会首先出来欢迎界面。

  1. 主界面菜单选项功能

主界面是该软件的第一个真正意义上的可操作界面,来响应用户的第一步的操作。主要就是让用户进行选择功能,即大学生租房信息查询的选择。界面的主要需求就是简单明了,在加上清新明目的背景图片,一定会给用户视觉上的快感。主界面这里拒绝那些繁琐的操作,给用户以方便。

系统页面展示

大学生租房系统,在系统首页可以查看首页,房屋信息,房屋评价,公告资讯,个人中心,后台管理,意见反馈等内容,并进行详细操作;如图5-1所示。

屋信息,在房屋信息页面可以查看房屋类型,地区,位置,朝向,楼层,楼号,房屋面积,房屋设施,房屋状态,房屋租金,房主账号,房主姓名等内容,并可以进行预约看房,定金留房等操作,如图5-3所示。

个人中心,在个人中心页面通过填写用户名,密码,姓名,性别,图片,手机,身份证等内容进行更新信息操作,还可以对我的收藏进行详细操作,如图5-4所示。

管理员登录系统后,可以对首页,个人中心,房主管理,用户管理,房屋类型管理,房屋信息管理,预约看房管理,定金留房管理,租赁订单管理,房屋评价管理等功能进行相应的操作,如图5-6所示。

房主管理,在房主管理页面可以对索引,房主账号,房主姓名,性别,照片,联系电话,身份证等内容进行详情,修改和删除等操作,如图5-7所示。

如需要可扫取文章下方二维码联系得源码

毕业设计-基于Springboot实现公租房申请管理系统

作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

文末获取源码 

项目编号:BS-XX-120

一,项目简介

本项目基于Springboot开发实现了一个公租房申请管理系统平台,系统分为管理员用户和公租房申请用户。管理员用户又分为三种:超级管理员,基础数据管理员,审核管理员。超级管理员主要用来管理管理员和普通用户信息,资讯信息等,基础数据管理员主要用来管理小区,房屋等相关信息,审核管理员主要用来审核用户的申请信息,给用户进行配租等。前端用户在前台界面可以查看公租房申请的相关政策信息,相关流程,实现在线注册和登陆,并可以在线申请公租房。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:springboot+mybatis

前台开发技术:layui+jquery

特点技术:短信发送,GoEasy通信技术等

三,系统展示

前端用户功能展示

用户注册

用户登陆

首页

申请指南

新闻动态

审核结果公示

在线申请

申请结果查询

管理员功能展示

超级管理员登陆

后台主界面

管理员管理:可以停用和删除

前台用户管理

资讯管理

审核人员管理功能

办公地点管理

公告管理

审核结果发布

基础数据管理员

房屋管理

给通过人员配租

四,核心代码展示

package org.wy.gzf_boot.controller;



import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.wy.gzf_boot.model.Admin;
import org.wy.gzf_boot.model.Community;
import org.wy.gzf_boot.service.AdminService;
import org.wy.gzf_boot.service.ApartmentService;
import org.wy.gzf_boot.service.CommunityService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @since 2020-03-08
 */
@Controller
@RequestMapping("/admin")
public class AdminController 

    @Resource
    private AdminService adminService;
    @Resource
    private CommunityService communityService;
    @Resource
    private ApartmentService apartmentService;

    @RequestMapping("/toWelcome")
    public String toWelcome()
        return "xianadmin/welcome";
    

    /**
     * 登录页面入口
     * @return
     */
    @RequestMapping("/toLogin")
    public String toLogin()
        return "xianadmin/login";
    

    /**
     * 管理员登录验证账号密码
     */
    @ResponseBody
    @RequestMapping("/toCheck")
    public Map toCheck(Admin admin,HttpSession session)
        Map map=new HashMap();
        Admin a=adminService.login(admin);
        if(a!=null)
            session.setAttribute("admin",a);
            map.put("admin",a);
        
        return map;
    

    @RequestMapping("/toIndex")
    public String toIndex(int adminState)
        if(adminState==0)
            return "superadmin/index";
        else if (adminState==1)
            return "xianadmin/index";
        else
            return "shiadmin/index";
        
    

    @RequestMapping("/toRole")
    public String toRole()
        return "superadmin/admin-role";
    

    @RequestMapping("/toAdminList")
    public String toAdminList()
        return "superadmin/admin-list";
    

    @RequestMapping("/toCommunityList")
    public String toCommunityList()
        return "superadmin/community-list";
    

    @RequestMapping("/toAddCommunity")
    public String toAddCommunity()
        return "superadmin/community-add";
    

    @RequestMapping("/toApartmentList")
    public ModelAndView toApartmentList(ModelAndView mv)
        List<Community> allCommunity=communityService.getCommunityList();
        mv.addObject("allCommunity",allCommunity);
        mv.setViewName("superadmin/apartment-list");
        return mv;
    

    @RequestMapping("/toAddApartment")
    public ModelAndView toAddApartment(ModelAndView mv)
        List<Community> allCommunity=communityService.getCommunityList();
        mv.addObject("allCommunity",allCommunity);
        mv.setViewName("superadmin/apartment-add");
        return mv;
    

    @RequestMapping("/toApplicant")
    public String toApplicant()
        return "xianadmin/applicant-list";
    


    @RequestMapping("/toAddApplicant")
    public String toAddApplicant()
        return "xianadmin/applicant-add";
    

    @RequestMapping("/toApplyCheck")
    public String toApplyCheck()
        return "shiadmin/shi-apply-list";
    

    @RequestMapping("/toNotice")
    public String toNotice()
        return "superadmin/notice-write";
    

    @ResponseBody
    @RequestMapping("/adminExit")
    public ModelAndView adminExit(HttpSession session,ModelAndView mv)
     session.invalidate();
     mv.setViewName("xianadmin/login");
     return mv;
    

    @RequestMapping("/toNoticeBox")
    public ModelAndView toNoticeBox(ModelAndView mv)
        mv.setViewName("shiadmin/notice-box");
        return mv;
    

    @RequestMapping("/toAdmin")
    public String toAdmin()
        return "superadmin/admin-list";
    

    @ResponseBody
    @RequestMapping("/getAdminList")
    public Map toAdminList(Admin admin)
        Map map=new HashMap();
        List adminList=adminService.getAdminList(admin);
        int adminCount=adminService.getAdminCount(admin);
        map.put("adminList",adminList);
        map.put("adminCount",adminCount);
        return map;
    

    @ResponseBody
    @RequestMapping("/addAdmin")
    public int addAdmin(Admin admin)
        return adminService.addAdmin(admin);
    

    @RequestMapping("/toAddAdmin")
    public String toAddAdmin()
        return "superadmin/admin-add";
    

    @ResponseBody
    @RequestMapping("/banAdminById")
    public int banAdminById(Admin admin)
        return adminService.banAdminById(admin);
    
    @ResponseBody
    @RequestMapping("delAdmin")
    public int delAdmin(Admin admin)
        return adminService.delAdmin(admin);
    

    @RequestMapping("/toApplyHelp")
    public String toApplyHelp()
        return "user/apply-help";
    

package org.wy.gzf_boot.controller;




import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.wy.gzf_boot.mapper.ApartmentMapper;
import org.wy.gzf_boot.model.Apartment;

import org.wy.gzf_boot.model.Community;
import org.wy.gzf_boot.service.ApartmentService;
import org.wy.gzf_boot.service.CommunityService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 房源表 前端控制器
 * </p>
 *

 * @since 2020-03-08
 */
@Controller
@RequestMapping("/apartment")
public class ApartmentController 

    @Resource
    private ApartmentService apartmentService;

    @Resource
    private CommunityService communityService;

    //获取符合条件的所有房源
    @ResponseBody
    @RequestMapping("/getApartmentList")
    public Map getApartmentList(Community community, Apartment apartment,int pageNum, int pageSize)
        apartment.setCommunity(community);
        System.out.println("单元号:"+apartment.getUnitId());
        Map map=new HashMap();
        map.put("apartment",apartment);
        int apartmentCount=apartmentService.getApartmentCount(map);
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        PageInfo page=apartmentService.getApartmentList(map);
        map.put("apartmentCount",apartmentCount);
        map.put("page",page);

        return map;
    

    //获取符合条件的所有空闲房源
    @ResponseBody
    @RequestMapping("/getFreeApartmentList")
    public Map getFreeApartmentList(Community community, Apartment apartment,int pageNum, int pageSize)
        apartment.setCommunity(community);
        System.out.println("单元号:"+apartment.getUnitId());
        Map map=new HashMap();
        map.put("apartment",apartment);
        int apartmentCount=apartmentService.getFreeApartmentCount(map);
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        PageInfo page=apartmentService.getFreeApartmentList(map);
        map.put("apartmentCount",apartmentCount);
        map.put("page",page);
        return map;
    
    /**
     * 添加房源
     * @param apartment
     * @return
     */
    @ResponseBody
    @RequestMapping("/addApartment")
    public int addApartment(Apartment apartment,Community community)
        apartment.setCommunity(community);
        int result=apartmentService.addApartment(apartment);
        return result;
    

    @ResponseBody
    @RequestMapping("/delApartment")
    public int delApartment(int apartmentId)
        return apartmentService.delApartment(apartmentId);
    

    @RequestMapping("/toApartmentEdit")
    public ModelAndView toEditApartment(Apartment apartment, ModelAndView mv)
        Apartment apartment1=apartmentService.getApartmentById(apartment);
        mv.addObject("apartment",apartment1);
        mv.setViewName("superadmin/apartment-edit");
        return mv;
    

    @ResponseBody
    @RequestMapping("/editApartment")
    public int editApartment(Apartment apartment)
        return apartmentService.editApartment(apartment);
    

    /**
     * excel导出
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/apartment_excel_down")
    public void exportPermMatrix(HttpServletRequest request, HttpServletResponse response) throws Exception 
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("xxx信息表");

        List<Apartment> apartmentList = apartmentService.getAllApartment();
        //此处添加数据
        HSSFRow headerRow1 = sheet.createRow(0);
        headerRow1.createCell(0).setCellValue("位置");
        headerRow1.createCell(1).setCellValue("房源");
        headerRow1.createCell(2).setCellValue("房源面积");
        headerRow1.createCell(3).setCellValue("计租面积");
        headerRow1.createCell(4).setCellValue("户型");
        headerRow1.createCell(5).setCellValue("建筑结构");
        headerRow1.createCell(6).setCellValue("状态");
        //headerRow1.createCell(6).setCellValue("总层数");
        for (int i = 0; i < apartmentList.size(); i++) 
            HSSFRow headerRow = sheet.createRow(i + 1);
            headerRow.createCell(0).setCellValue(apartmentList.get(i).getCommunity().getLocation());
            headerRow.createCell(1).setCellValue(apartmentList.get(i).getCommunity().getCommunityName()+apartmentList.get(i).getUnitId()+"号楼"+apartmentList.get(i).getFloorId()+"-"+apartmentList.get(i).getRoomId());
            headerRow.createCell(2).setCellValue(apartmentList.get(i).getRoomArea()+"㎡");
            headerRow.createCell(3).setCellValue(apartmentList.get(i).getRentArea()+"㎡");
            headerRow.createCell(4).setCellValue(apartmentList.get(i).getHouseType());
            headerRow.createCell(5).setCellValue(apartmentList.get(i).getCommunity().getStructure());
            headerRow.createCell(6).setCellValue(apartmentList.get(i).getRoomState());
        

        //清空response
        response.reset();
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment; filename=" + new String("房源信息列表".getBytes(), "iso8859-1") + ".xls");
        OutputStream os = new BufferedOutputStream(response.getOutputStream());
        workbook.write(os);
        os.flush();
        os.close();
        //workbook.close();
    

    /**
     * excel导入数据
     */
    @ResponseBody
    @RequestMapping("/apartment_input_excel")
    @Transactional(rollbackFor = Exception.class)
    public Map importWatchExcel(@RequestParam("file") MultipartFile xlsFile) 
        Map result = new HashMap<>();
        // contentType
        // String contentType = file.getContentType();
        // excel文件名
        // String fileName = file.getOriginalFilename();
        if (xlsFile.isEmpty()) 
            result.put("code", 500);
            result.put("message", "导入文件为空!");
            return result;
        
        // 根据不同excel创建不同对象,Excel2003版本-->HSSFWorkbook,Excel2007版本-->XSSFWorkbook
        Workbook wb = null;
        InputStream im = null;
        try 
            im = xlsFile.getInputStream();
            wb = WorkbookFactory.create(im);
            // 根据页面index 获取sheet页
            Sheet sheet = wb.getSheetAt(0);
            Row row = null;
            // 循环sheet页中数据从第x行开始,例:第3行开始为导入数据
            for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) 

               Apartment apartment=new Apartment();

                // 获取每一行数据
                row = sheet.getRow(i);
                // 输出表格内容,此处可替换为数据插入操作
                String communityName=row.getCell(1).getStringCellValue();
                List communityList=communityService.getCommunityByName(communityName);
                Community community= (Community) communityList.get(0);

                apartment.setCommunity(community);

                if (null != row.getCell(2) && "" != row.getCell(2).toString()) 
                    row.getCell(2).setCellType(CellType.STRING);
                    apartment.setUnitId(Integer.parseInt(row.getCell(2).getStringCellValue()));
                
                if (null != row.getCell(3) && "" != row.getCell(3).toString()) 
                    row.getCell(3).setCellType(CellType.STRING);
                   apartment.setFloorId(Integer.parseInt(row.getCell(3).getStringCellValue()));
                
                if (null != row.getCell(4) && "" != row.getCell(4).toString()) 
                    row.getCell(4).setCellType(CellType.STRING);
                    apartment.setRoomId(Integer.parseInt(row.getCell(4).getStringCellValue()));
                
                if (null != row.getCell(5) && "" != row.getCell(5).toString()) 
                    String roomArea=row.getCell(5).getStringCellValue();
                    apartment.setRoomArea(Float.parseFloat(roomArea));
                
                if (null != row.getCell(6) && "" != row.getCell(6).toString()) 
                    String rentArea=row.getCell(6).getStringCellValue();
                    apartment.setRentArea(Float.parseFloat(rentArea));
                
                if (null != row.getCell(7) && "" != row.getCell(7).toString()) 
                    apartment.setHouseType(row.getCell(7).getStringCellValue());
                
                if (null != row.getCell(9) && "" != row.getCell(9).toString()) 
                    apartment.setRoomState(row.getCell(9).getStringCellValue());
                

                apartmentService.addApartment(apartment);
            
            result.put("code", 200);
            result.put("message", "导入成功!");
         catch (Exception e1) 
            // 回滚数据
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e1.printStackTrace();
         finally 
            try 
                im.close();
                wb.close();
             catch (IOException e2) 
                e2.printStackTrace();
            
        
        return result;
    

    @RequestMapping("/toSelectExcel")
    public String toSelectExcel()
        return "superadmin/apartment-excel-select";
    

    @ResponseBody
    @RequestMapping("/getAllApartment")
    public List getAllApartment()
        return apartmentService.getAllApartment();
    


package org.wy.gzf_boot.controller;


import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.wy.gzf_boot.model.*;
import org.wy.gzf_boot.service.ApplicantService;
import org.wy.gzf_boot.service.SecondTrialService;
import org.wy.gzf_boot.service.UserInformService;
import org.wy.gzf_boot.util.FileUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;

/**
 * <p>
 * 申请人表 前端控制器
 * </p>
 *
 * @since 2020-03-08
 */
@Controller
@RequestMapping("/applicant")
public class ApplicantController 

    @Resource
    private ApplicantService applicantService;

    @Resource
    private SecondTrialService secondTrialService;

    @Resource
    private UserInformService userInformService;

    @Value("$uploadPath")
    private String uploadPath;
    @ResponseBody
    @RequestMapping("/getApplicantList")
    public Map getApplicantList(int pageSize, int pageNum, String applicantName, String adminState) 
        Map map = new HashMap();

        map.put("adminState", adminState);
        int applicantCount = applicantService.getApplicantCount(map);
        map.put("applicantCount", applicantCount);
        System.out.println("申请人总条数:" + applicantCount);
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);
        map.put("applicantName", applicantName);
        PageInfo page = applicantService.getApplicantList(map);

        map.put("page", page);

        return map;
    

    /**
     * 申请人信息提交,多文件上传
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/addApplicant")
    public int addApply(HttpServletRequest request) 
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        List<MultipartFile> file1 = multipartRequest.getFiles("file1");
        List<MultipartFile> file2 = multipartRequest.getFiles("file2");
        List<MultipartFile> file3 = multipartRequest.getFiles("file3");
        List<MultipartFile> file4 = multipartRequest.getFiles("file4");
        List<MultipartFile> file5 = multipartRequest.getFiles("file5");

        Applicant applicant = new Applicant();
        User user = new User();
        user.setUserId(Integer.parseInt(multipartRequest.getParameter("userId")));
        applicant.setUser(user);
        applicant.setApplicantName(multipartRequest.getParameter("applicantName"));
        applicant.setSex(Integer.parseInt(multipartRequest.getParameter("sex")));
        applicant.setIdNumber(multipartRequest.getParameter("idNumber"));
        applicant.setBirthday(multipartRequest.getParameter("birthday"));
        applicant.setEducation(multipartRequest.getParameter("education"));
        applicant.setWorkUnit(multipartRequest.getParameter("workUnit"));
        applicant.setPhone(multipartRequest.getParameter("phone"));
        applicant.setAddress(multipartRequest.getParameter("address"));
        Community community = new Community();
        community.setCommunityId(Integer.parseInt(multipartRequest.getParameter("communityId")));
        applicant.setCommunity(community);
        applicant.setDemandArea(Integer.parseInt(multipartRequest.getParameter("demandArea")));
        applicant.setDemandFloor(Integer.parseInt(multipartRequest.getParameter("demandFloor")));
        applicant.setDemandRoom(multipartRequest.getParameter("demandRoom"));


        List<MultipartFile> allFiles = new ArrayList<>();
        allFiles.add(file1.get(0));
        allFiles.add(file2.get(0));
        allFiles.add(file3.get(0));
        allFiles.add(file4.get(0));
        allFiles.add(file5.get(0));
        for (int i = 0; i < allFiles.size(); i++) 
            String fileName = allFiles.get(i).getOriginalFilename();
            if (!"".equals(fileName)) 
                String suffixName = fileName.substring(fileName.lastIndexOf("."));
                fileName = UUID.randomUUID() + suffixName;  //新文件名
                if (i == 0) 
                    applicant.setIdentityCard(fileName);
                 else if (i == 1) 
                    applicant.setMarriageProof(fileName);
                 else if (i == 2) 
                    applicant.setHouseProof(fileName);
                 else if (i == 3) 
                    applicant.setWorkProof(fileName);
                 else if (i == 4) 
                    applicant.setApplyDoc(fileName);
                
            
            String path = uploadPath;
            FileUtils.upload(allFiles.get(i), path, fileName);
        
        int result = applicantService.addApplicant(applicant);
        if (result > 0) 
            UserInform userInform = new UserInform();
            userInform.setTitle("申请提交通知");
            userInform.setContent(applicant.getApplicantName() + "(先生/女士),您的公租房申请材料已经提交,请您耐心等待。您可在首页的查询办理进度,也可等待审核公告发布");
            userInform.setUser(user);
            userInformService.addUserInform(userInform);
            return result;
        
        return 0;
    

    @RequestMapping("/getApplicantById")
    public ModelAndView getApplicantById(int applicantId, ModelAndView mv) 
        Applicant applicant = applicantService.getApplicantById(applicantId);
        mv.addObject("applicant", applicant);
        mv.setViewName("xianadmin/applicant-edit");
        return mv;
    

    @ResponseBody
    @RequestMapping("/editApplicant")
    public int editApplicant(Applicant applicant) 
        return applicantService.editApplicant(applicant);
    

    @RequestMapping("/getIdentityCard")
    public ModelAndView getIdentityCard(int applicantId, ModelAndView mv) 
        Applicant applicant = applicantService.getIdentityCard(applicantId);
        mv.setViewName("xianadmin/identitycard-img");
        mv.addObject("applicant", applicant);
        return mv;
    

    @ResponseBody
    @RequestMapping("/editIdentityCard")
    public int editIdentityCard(@RequestParam("file") MultipartFile file, Applicant applicant) 
        String fileName = file.getOriginalFilename();
        if (!"".equals(fileName)) 
            String suffixName = fileName.substring(fileName.lastIndexOf("."));
            fileName = UUID.randomUUID() + suffixName;  //新文件名
        
        String path = "D:\\\\gzf_boot\\\\src\\\\main\\\\resources\\\\static\\\\upload";
        FileUtils.upload(file, path, fileName);
        applicant.setIdentityCard(fileName);
        int result = applicantService.editIdentityCard(applicant);

        return result;
    

    @RequestMapping("/shiCheckApplicant")
    public ModelAndView shiCheckApplicant(int applicantId, ModelAndView mv) 
        Applicant applicant = applicantService.getApplicantById(applicantId);
        mv.addObject("applicant", applicant);
        mv.setViewName("shiadmin/shi-apply-details");
        return mv;
    

    @RequestMapping("/xianCheckApplicant")
    public ModelAndView xianCheckApplicant(int applicantId, ModelAndView mv) 
        Applicant applicant = applicantService.getApplicantById(applicantId);
        mv.addObject("applicant", applicant);
        mv.setViewName("xianadmin/xian-apply-details");
        return mv;
    

    @RequestMapping("/checkIdentityCard")
    public ModelAndView checkIdentityCard(int applicantId, ModelAndView mv) 
        Applicant applicant = applicantService.getIdentityCard(applicantId);
        mv.setViewName("shiadmin/identitycard-check");
        mv.addObject("applicant", applicant);
        return mv;
    

    @RequestMapping("/checkMarriageProof")
    public ModelAndView checkMarriageProof(Applicant applicant, ModelAndView mv) 
        mv.setViewName("shiadmin/marriageProof-check");
        mv.addObject("applicant", applicant);
        return mv;
    

    @RequestMapping("/checkWorkProof")
    public ModelAndView checkWorkProof(Applicant applicant, ModelAndView mv) 
        mv.setViewName("shiadmin/workProof-check");
        mv.addObject("applicant", applicant);
        return mv;
    

    @RequestMapping("/checkHouseProof")
    public ModelAndView checkHouseProof(Applicant applicant, ModelAndView mv) 
        mv.setViewName("shiadmin/houseProof-check");
        mv.addObject("applicant", applicant);
        return mv;
    

    @RequestMapping("/checkApplyDoc")
    public ModelAndView checkApplyDoc(Applicant applicant, ModelAndView mv) 
        mv.setViewName("shiadmin/applyDoc-check");
        mv.addObject("applicant", applicant);
        return mv;
    

    @ResponseBody
    @RequestMapping("/checkSuccess")
    public int checkSuccess(int applicantId) 
        Applicant applicant = new Applicant();
        applicant.setShiState(1);
        applicant.setApplicantId(applicantId);
        int result = applicantService.checkApply(applicant);
        SecondTrial secondTrial = new SecondTrial();
        secondTrial.setApplicant(applicant);
        int result2 = secondTrialService.addTrial(secondTrial);
        if (result > 0 && result2 > 0) 
            return 1;
         else 
            return 0;
        
    


    @RequestMapping("/toWriteRefuse")
    public ModelAndView toWriteRefuse(int applicantId, int userId, ModelAndView mv) 
        mv.setViewName("shiadmin/refuse-write");
        mv.addObject("applicantId", applicantId);
        mv.addObject("userId", userId);
        return mv;
    

    /**
     * 下载小区信息    导出 excel 使用我们的模板导出
     * /excel_down
     */
    @RequestMapping("/applicant_excel_down")
    public void exportPermMatrix(int shiState, HttpServletRequest request, HttpServletResponse response) throws Exception 
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("xxx信息表");
        List<Applicant> list = new ArrayList<>();
        System.out.println("________________" + shiState + "_________________________");
        if (shiState == 0) 
            list = applicantService.getAllApplicant();
         else 
            list = applicantService.getOkApplicant();
        

        //此处添加数据
        HSSFRow headerRow1 = sheet.createRow(0);
        headerRow1.createCell(0).setCellValue("申请人姓名");
        headerRow1.createCell(1).setCellValue("性别");
        headerRow1.createCell(2).setCellValue("身份证号");
        headerRow1.createCell(3).setCellValue("出生日期");
        headerRow1.createCell(4).setCellValue("学历");
        headerRow1.createCell(5).setCellValue("工作单位");
        headerRow1.createCell(6).setCellValue("联系电话");
        headerRow1.createCell(7).setCellValue("联系地址");
        headerRow1.createCell(8).setCellValue("需求面积");
        headerRow1.createCell(9).setCellValue("需求楼层");
        headerRow1.createCell(10).setCellValue("需求房型");
        headerRow1.createCell(11).setCellValue("状态");

        for (int i = 0; i < list.size(); i++) 
            HSSFRow headerRow = sheet.createRow(i + 1);
            headerRow.createCell(0).setCellValue(list.get(i).getApplicantName());
            if (list.get(i).getSex() == 0) 
                headerRow.createCell(1).setCellValue("男");
             else 
                headerRow.createCell(1).setCellValue("女");
            
            headerRow.createCell(2).setCellValue(list.get(i).getIdNumber());
            headerRow.createCell(3).setCellValue(list.get(i).getBirthday());
            headerRow.createCell(4).setCellValue(list.get(i).getEducation());
            headerRow.createCell(5).setCellValue(list.get(i).getWorkUnit());
            headerRow.createCell(6).setCellValue(list.get(i).getPhone());
            headerRow.createCell(7).setCellValue(list.get(i).getAddress());
            headerRow.createCell(8).setCellValue(list.get(i).getDemandArea() + "㎡");
            headerRow.createCell(9).setCellValue(list.get(i).getDemandFloor() + "层");
            headerRow.createCell(10).setCellValue(list.get(i).getDemandRoom());
            if (list.get(i).getShiState() == 0) 
                headerRow.createCell(11).setCellValue("未审核");
             else if (list.get(i).getShiState() == 1) 
                headerRow.createCell(11).setCellValue("审核通过");
             else 
                headerRow.createCell(11).setCellValue("审核未通过");
            
        

        //清空response
        response.reset();
        response.setContentType("multipart/form-data");
        if (shiState == 0) 
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("申请人信息列表(全部)".getBytes(), "iso8859-1") + ".xls");
         else 
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("申请人信息列表(已通过)".getBytes(), "iso8859-1") + ".xls");
        

        OutputStream os = new BufferedOutputStream(response.getOutputStream());
        workbook.write(os);
        os.flush();
        os.close();
        workbook.close();
    

    /**
     * excel导入数据
     */
    @ResponseBody
    @RequestMapping("applicant_input_excel")
    @Transactional(rollbackFor = Exception.class)
    public Map importWatchExcel(@RequestParam("file") MultipartFile xlsFile) 
        Map result = new HashMap<>();
        // contentType
        // String contentType = file.getContentType();
        // excel文件名
        // String fileName = file.getOriginalFilename();
        if (xlsFile.isEmpty()) 
            result.put("code", 500);
            result.put("message", "导入文件为空!");
            return result;
        
        // 根据不同excel创建不同对象,Excel2003版本-->HSSFWorkbook,Excel2007版本-->XSSFWorkbook
        Workbook wb = null;
        InputStream im = null;
        try 
            im = xlsFile.getInputStream();
            wb = WorkbookFactory.create(im);
            // 根据页面index 获取sheet页
            Sheet sheet = wb.getSheetAt(0);
            Row row = null;
            // 循环sheet页中数据从第x行开始,例:第2行开始为导入数据
            for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) 

                Applicant applicant = new Applicant();

                // 获取每一行数据
                row = sheet.getRow(i);
                // 输出表格内容,此处可替换为数据插入操作
                if (null != row.getCell(0) && "" != row.getCell(0).toString()) 
                    applicant.setApplicantName(row.getCell(0).getStringCellValue());
                
                // 内容,表格数字格式为常规
                if (null != row.getCell(1) && "" != row.getCell(1).toString()) 
                    String sex = row.getCell(1).getStringCellValue();
                    if ("男".equals(sex)) 
                        applicant.setSex(0);
                     else 
                        applicant.setSex(1);
                    
                
                if (null != row.getCell(2) && "" != row.getCell(2).toString()) 
                    applicant.setIdNumber(row.getCell(2).getStringCellValue());
                
                if (null != row.getCell(3) && "" != row.getCell(3).toString()) 
                    applicant.setBirthday(row.getCell(3).getStringCellValue());
                
                if (null != row.getCell(4) && "" != row.getCell(4).toString()) 
                    applicant.setEducation(row.getCell(4).getStringCellValue());
                
                if (null != row.getCell(5) && "" != row.getCell(5).toString()) 
                    applicant.setWorkUnit(row.getCell(5).getStringCellValue());
                
                if (null != row.getCell(6) && "" != row.getCell(6).toString()) 
                    applicant.setPhone(row.getCell(6).getStringCellValue());
                
                if (null != row.getCell(7) && "" != row.getCell(7).toString()) 
                    applicant.setAddress(row.getCell(7).getStringCellValue());
                
                if (null != row.getCell(8) && "" != row.getCell(8).toString()) 
                    row.getCell(8).setCellType(CellType.STRING);
                    applicant.setDemandArea(Integer.parseInt(row.getCell(8).getStringCellValue()));
                
                if (null != row.getCell(9) && "" != row.getCell(9).toString()) 
                    row.getCell(9).setCellType(CellType.STRING);
                    applicant.setDemandFloor(Integer.parseInt(row.getCell(9).getStringCellValue()));
                
                if (null != row.getCell(10) && "" != row.getCell(10).toString()) 
                    applicant.setDemandRoom(row.getCell(10).getStringCellValue());
                
                if (null != row.getCell(11) && "" != row.getCell(11).toString()) 
                    String state = row.getCell(11).getStringCellValue();
                    if ("未审核".equals(state)) 
                        applicant.setShiState(0);
                     else if ("审核通过".equals(state)) 
                        applicant.setShiState(1);
                     else 
                        applicant.setShiState(2);
                    
                

                applicantService.addApplicant(applicant);
            
            result.put("code", 200);
            result.put("message", "导入成功!");
         catch (Exception e1) 
            // 回滚数据
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e1.printStackTrace();
         finally 
            try 
                im.close();
                wb.close();
             catch (IOException e2) 
                e2.printStackTrace();
            
        
        return result;
    

    @RequestMapping("/toSelectExcel")
    public String toSelectExcel() 
        return "xianadmin/applicant-excel-select";
    

    @ResponseBody
    @RequestMapping("/toCheckApply")
    public Map toCheckApply(String applicantName, String idNumber) 
        Map map = new HashMap();
        map.put("applicantName", applicantName);
        map.put("idNumber", idNumber);
        Applicant applicant = applicantService.toCheckApply(map);
        map.put("applicant", applicant);
        return map;
    

    @ResponseBody
    @RequestMapping("/getApplicantListByTime")
    public Map getApplicantListByTime(String startDate, String endDate, int pageNum, int pageSize) 
        Map map = new HashMap();
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        int applicantCount = applicantService.getApplicantListByTimeCount(map);
        map.put("applicantCount", applicantCount);
        System.out.println("申请人总条数:" + applicantCount);
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);
        PageInfo page = applicantService.getApplicantListByTime(map);
        map.put("page", page);
        return map;
    

    @ResponseBody
    @RequestMapping("/getApplicantForUser")
    public Map getApplicantForUser(String startDate, String endDate, int times, int pageNum, int pageSize) 
        Map map = new HashMap();
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        map.put("times", times);
        if (times == 1) 
            int applicantCount = applicantService.getApplicantListByTimeCount(map);
            map.put("applicantCount", applicantCount);
            map.put("pageNum", pageNum);
            map.put("pageSize", pageSize);
            PageInfo page = applicantService.getApplicantListByTime(map);
            map.put("applicantPage", page);
         else 
            int trialCount = secondTrialService.getAllTrialCount(map);
            map.put("trialCount", trialCount);
            map.put("pageNum", pageNum);
            map.put("pageSize", pageSize);
            PageInfo page = secondTrialService.getAllTrial(map);
            map.put("trialPage", page);
        
        return map;
    


五,项目总结

本项目基于springboot框架来进行开发实现,符合现在开发的主流趋势,项目结构清晰明了,层次分明,采用MVC设计模式和三层架构来进行整体设计。界面布局简洁大方,操作符合用户使用习惯,人机交互处理的比较人性化,适合做毕业设计使用,也可以做课程设计或期未作业使用。

以上是关于基于springboot实现大学生租房系统演示附项目源码的主要内容,如果未能解决你的问题,请参考以下文章

毕业设计-基于Springboot实现公租房申请管理系统

毕业设计-基于Springboot实现公租房申请管理系统

基于springboot实现高校学生健康档案管理系统

毕业设计-springboot+vue公租房租赁管理系统

毕业设计-springboot+vue公租房租赁管理系统

基于springboot的租房网站