Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

源码获取:博客首页 "资源" 里下载!

该系统有三个角色,分别是:普通用户、房屋中介、管理员普通用户的功能:浏览房屋信息、预约看房、和中介聊天、申请成为中介等等。房屋中介的功能:发布房屋信息、和用户聊天、回复预约信息等等。管理员的功能:管理所有用户信息、管理权限信息、管理所有房屋信息、管理所有预约信息等等。

应用技术:SpringBoot + Redis + MySQL + Vue + SpringSecurity + JWT + ElasticSearch + WebSocket + FreeMarker + MyBatis-Plus等等

运行环境:Eclipse/IntelliJ IDEA + MySQL5.7 + Maven3.6.3(项目压缩包中自带) + JDK1.8 + Redis5.0.5(项目压缩包中自带)+ ElasticSearch6.8.0

Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

 Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

 Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

 Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

 Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

 Java项目:在线淘房系统(租房、购房)(java+SpringBoot+Redis+MySQL+Vue+SpringSecurity+JWT+ElasticSearch+WebSocket)

 

个人中心控制器:

/**
 * 个人中心控制器
 * 
 * @author yy
 *
 */
@Controller
@RequestMapping("/personacentermvc")
public class PersonacenterController {

	@Resource
	private RentwithdrawnService rentwithdrawnService;

	@Resource
	private UserlistService userlistService;

	@Resource
	private LeaseinformationService leaseinformationService;

	@Resource
	private CheckoutapplicationService checkoutapplicationService;

	@Resource
	private RentcollectionService rentcollectionService;

	@Resource
	private FaultService faultService;

	@Resource
	private HeadPortraitImgService headPortraitImgService;

	/**
	 * 个人信息切换页面
	 */
	@RequestMapping("/personal_switch")
	public void temp(String txt, HttpServletResponse response) throws IOException {
		response.setCharacterEncoding("UTF-8");
		switch (txt) {
		case "租赁信息":
			response.getWriter().print("/jsp/personalInformation/information.jsp");
			break;
		case "我的申请":
			response.getWriter().print("/jsp/personalInformation/myapplication.jsp");
			break;
		case "代缴租金":
			response.getWriter().print("/jsp/personalInformation/rentpayment.jsp");
			break;
		case "报障模块":
			response.getWriter().print("/jsp/personalInformation/faultreportingmodule.jsp");
			break;
		case "其他操作":
			response.getWriter().print("/jsp/personalInformation/otheroperations.jsp");
			break;
		}
	}

	/**
	 * 我的租赁分页查询
	 */
	@RequestMapping("/myRentalList")
	@ResponseBody
	public Msg myRentalList(@RequestParam(value = "pn") Integer pn, HttpSession session) {
		// 查询所有数据
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		// 设置分页传输
		PageHelper.startPage(pn, 8);
		List<userlist> leaseuser = userlistService.selectUserNameWith(user.getUsername());
		// 使用PageInFo封装查询结果
		PageInfo<userlist> pageInfo = new PageInfo<userlist>(leaseuser, 3);

		return Msg.success().add("pageInfo", pageInfo);
	}

	/**
	 * 已退租赁记录分页查询
	 */
	@RequestMapping("/refundedLeaseList")
	@ResponseBody
	public Msg refundedLeaseList(@RequestParam(value = "pn") Integer pn, HttpSession session) {
		// 查询所有数据
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		// 设置分页传输
		PageHelper.startPage(pn, 8);
		List<rentwithdrawn> list = rentwithdrawnService.queryAllStateName("已退租", "", user.getUsername());

		// 使用PageInFo封装查询结果
		PageInfo<rentwithdrawn> pageInfo = new PageInfo<rentwithdrawn>(list, 3);

		return Msg.success().add("pageInfo", pageInfo);
	}

	/**
	 * 申请状态记录分页查询
	 */
	@RequestMapping("/applicationAtatusList")
	@ResponseBody
	public Msg applicationAtatusList(@RequestParam(value = "pn") Integer pn, boolean flag, HttpSession session) {
		List<checkoutapplication> list = null;
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		// 设置分页传输
		PageHelper.startPage(pn, 8);
		// 查询所有数据
		if (flag) {
			list = checkoutapplicationService.selectStateAll("看房申请中", "退房申请中", "", user.getUsername());
		} else {
			list = checkoutapplicationService.selectStateAll("已拒绝", "已同意", "已取消", user.getUsername());
		}

		// 使用PageInFo封装查询结果
		PageInfo<checkoutapplication> pageInfo = new PageInfo<checkoutapplication>(list, 3);

		return Msg.success().add("pageInfo", pageInfo);
	}

	/**
	 * 代缴租金分页查询
	 */
	@RequestMapping("/rentpaymentList")
	@ResponseBody
	public Msg rentpaymentList(@RequestParam(value = "pn") Integer pn, String state, HttpSession session) {
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		// 设置分页传输
		PageHelper.startPage(pn, 8);
		List<rentcollection> list = rentcollectionService.queryPaidStateAll(state, user.getUsername());
		// 使用PageInFo封装查询结果
		PageInfo<rentcollection> pageInfo = new PageInfo<rentcollection>(list, 3);

		return Msg.success().add("pageInfo", pageInfo);
	}

	/**
	 * 缴纳租金
	 */
	@RequestMapping("/payrentmvc")
	public ModelAndView payrentmvc(String rchousemoney,Integer rcid,String token,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		Warning news = rentcollectionService.updateState(rcid);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}
	
	/**
	 * 已缴纳租金删除记录
	 */
	@RequestMapping("/paidrent")
	public ModelAndView paidrent(Integer rcid,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		Warning news = rentcollectionService.deleteByPrimaryKey(rcid);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}

	/**
	 * 共缴费费用
	 */
	@RequestMapping("/copaymentfee")
	@ResponseBody
	public Msg copaymentfee(String state, HttpSession session) {
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		List<rentcollection> list = rentcollectionService.queryPaidStateAll(state, user.getUsername());
		int num = 0;
		for (rentcollection temp : list) {
			num += Float.parseFloat(temp.getRchousemoney());
		}
		return Msg.success().add("num", num);
	}

	/**
	 * 报障分页查询
	 */
	@RequestMapping("/repairList")
	@ResponseBody
	public Msg repairList(@RequestParam(value = "pn") Integer pn, String str, HttpSession session) {
		// 使用PageInFo封装查询结果
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		// 设置分页传输
		PageHelper.startPage(pn, 8);
		if (str.equals("我要报障")) {
			List<userlist> leaseuser = userlistService.selectUserNameWith(user.getUsername());
			PageInfo<userlist> pageInfo = new PageInfo<userlist>(leaseuser, 3);
			return Msg.success().add("pageInfo", pageInfo);
		}

		List<fault> list = faultService.queryAllState(str, user.getUsername());
		PageInfo<fault> pageInfo = new PageInfo<fault>(list, 3);

		return Msg.success().add("pageInfo", pageInfo);
	}

	/**
	 * 报障提交内容
	 * 
	 * @throws ParseException
	 */
	@RequestMapping("/contentofthereport")
	public ModelAndView contentofthereport(String date, String housecall, String contentofthe,String token,HttpServletRequest request,HttpSession session) throws ParseException {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		userlist user = userlistService.selectUserCallWith(housecall);
		fault fault = new fault();
		fault.setFhouseid(housecall);
		fault.setFhouseaddress(user.getLeaseinformation().getHouseaddress());
		fault.setFprice(Double.parseDouble(user.getLeaseinformation().getHousemoney()));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
		Date t1 = sdf.parse(date);
		fault.setFdate(t1);
		fault.setFdatetemp(date);
		fault.setFcontent(contentofthe);
		fault.setFusername(user.getUsername());
		fault.setFuserid(user.getUserid());
		fault.setFuserphone(user.getUserphone());
		fault.setFstate("未处理");
		Warning news = faultService.insert(fault);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}

	/**
	 * 报障删除记录
	 */
	@RequestMapping("/deleterepair")
	public ModelAndView deleterepair(Integer fid,String token,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		Warning news = faultService.deleteByPrimaryKey(fid);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}

	/**
	 * 头像上传 用户真实姓名,身份证号,手机号上传
	 * 
	 * @throws FileNotFoundException
	 */
	@RequestMapping("/file")
	public ModelAndView file(String username,String userid,String userphone,HttpServletRequest request,HttpSession session,@RequestParam MultipartFile file) throws Exception {
		System.out.println(username);
		
		ModelAndView mav = new ModelAndView("personacenter");
		userlist usere=userlistService.selectUserName(username);
		if (usere==null) {
			session.setAttribute("modifyerro",null);
			System.out.println("可修改");
		}else {
			Warning news=new Warning(2, "修改失败!该姓名用户已注册");
			mav.addObject("news", news);
			return mav;
		}
		
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		// 获取文件的名称
		String fName = file.getOriginalFilename();
		System.out.println(fName);
		if (!fName.equals("")) {
			// 保存图片的目录
			String path = "C://Users/Rain/Desktop/ssm_leaseOfHouses/WebContent/headPortraitImg";
			File filepath = new File(path);
			// 如果目录不存在,创建
			if (!filepath.exists()) {
				filepath.mkdir();
			}

			File f = new File(path, fName);

			// 更改用户头像
			headportraitimg headportraitimg = new headportraitimg();
			String user = (String) session.getAttribute("user");
			headportraitimg.setHeadportraitimgusername(user);
			headportraitimg.setHeadportraitimgaddress(fName);
			// 图片路径上传到数据库
			headPortraitImgService.updatauserimg(headportraitimg);
			// 更换头像
			session.setAttribute("headportraitimg", headportraitimg.getHeadportraitimgaddress());
			// 上传文件
			file.transferTo(f);
		}

		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		//暂时储存需要修改的真实姓名
		String rcusernametemp=user.getUsername();
		//判断,如有真实姓名联表修改,则添加
		if(user.getUsername()==null||"".equals(user.getUsername())) {
			// 上传真实姓名,身份证,手机号
			userlist userlist = new userlist();
			userlist.setUsercall((String) session.getAttribute("user"));
			userlist.setUsername(username);
			userlist.setUserid(userid);
			userlist.setUserphone(userphone);
			Warning news = userlistService.updateByPrimaryCall(userlist);
			System.out.println(news.getWarningContent());
			// 放入转发参数
			mav.addObject("news", news);
		}else {
			// 修改真实姓名,身份证,手机号
			userlist userlist = new userlist();
			userlist.setUsername(username);
			userlist.setUserid(userid);
			userlist.setUserphone(userphone);
			userlist.setUsernametemp(user.getUsername());
			Warning news = userlistService.updateJointTableName(userlist);
			//修改租金真实姓名
			System.out.println(rentcollectionService.updateUserName(username,rcusernametemp));
			System.out.println(news.getWarningContent());
			// 放入转发参数
			mav.addObject("news", news);
		}

		return mav;
	}

	/**
	 * 删除已退租记录
	 */
	@RequestMapping("/deleterentrefund")
	public ModelAndView deleterentrefund(Integer rwid,String token,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		Warning news = rentwithdrawnService.deleteByPrimaryKey(rwid);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}

	/**
	 * 查看合同
	 */
	@RequestMapping("/viewcontract")
	public ModelAndView viewcontract(String username, String userid, String houseaddress, String housestartingdatetemp,
			String houseclosingdatetemp, String housemoney, String userphone, String houseid,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		String arraytemp[] = { username, userid, houseaddress, housestartingdatetemp, houseclosingdatetemp, housemoney,
				userphone, houseid };
		String temp = (arraytemp[0]+arraytemp[7]) + "pdf.pdf";
		File filetemp = new File("C://Users/Rain/Desktop/ssm_leaseOfHouses/WebContent/contract/pdf/" + temp);
		if (!filetemp.exists()) {
//			System.out.println(new DocumentConversion().DocumentGeneration(arraytemp));
			new DocumentConversion().PdfGeneration((arraytemp[0]+arraytemp[7]));
			filetemp = new File("C://Users/Rain/Desktop/ssm_leaseOfHouses/WebContent/contract/pdf/" + temp);
		}
		
		String pdf = filetemp.getName();
		// 放入转发参数
		mav.addObject("pdftemp", pdf);

		return mav;
	}

	/**
	 * 终止合同
	 */
	@RequestMapping("/termination")
	public ModelAndView termination(String call,String token,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		userlist leaseuser = userlistService.selectUserCallWith(call);
		Warning news = checkoutapplicationService.insert(leaseuser);
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}

	/**
	 * 终止申请
	 */
	@RequestMapping("/stopapplying")
	public ModelAndView stopapplying(String call,String token,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		Warning news = checkoutapplicationService.updateCallState("已取消", call);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}

	/**
	 * 删除申请记录
	 */
	@RequestMapping("/deleterecord")
	public ModelAndView deleterecord(Integer coaid,String token,HttpServletRequest request,HttpSession session) {
		ModelAndView mav = new ModelAndView("personacenter");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		Warning news = checkoutapplicationService.deleteByPrimaryKey(coaid);
		System.out.println(news.getWarningContent());
		// 放入转发参数
		mav.addObject("news", news);
		return mav;
	}
}

房屋信息控制器:

/**
 * 房屋信息控制器
 * @author yy
 *
 */
 
@Controller
@RequestMapping("/leaseinformationmvc")
public class LeaseinformationController {
    @Autowired
    LeaseinformationService leaseinformationService;
        
    @RequestMapping("/details")
    public ModelAndView listCategory(@RequestParam int id){
        ModelAndView mav = new ModelAndView("details");
        List<leaseinformation> cs= leaseinformationService.allANDimg1(id);
        for (leaseinformation leaseinformation : cs) {
			System.out.println(leaseinformation.getLeaseimg().getImgroute());
		}
        // 放入转发参数
        mav.addObject("cs", cs);
        return mav;
    }
 
}

用户控制器:

/**
 * 用户控制器
 * 
 * @author yy
 *
 */
@Controller
@RequestMapping("/userlistmvc")
public class UserListController {

	private static final long serialVersionUID = -884689940866074733L;

	@Resource
	private UserlistService userlistService;

	@Resource
	private AdminListService adminListService;

	@Resource
	private HeadPortraitImgService headPortraitImgService;

	@Resource
	private CheckoutapplicationService checkoutapplicationService;

	/**
	 * 登录
	 */
	@RequestMapping("/userpwd")
	public String userpwd(String username, String pwd, String[] identity, HttpServletRequest request) {
		HttpSession session = request.getSession();
		if (username.equals("") || pwd.equals("")) {
			request.setAttribute("erorr", "输入账号密码不能为空!");
			return "login";
		}

		String tempstr = null;

		try {
			if (identity[0].equals("user")) {
				userlist temp = new userlist();
				temp.setUsercall(username);
				temp.setUserpwd(pwd);
				userlist userlist = userlistService.queryAllUserPwd(temp);
				try {
					tempstr = userlist.getUsercall();
					if (tempstr != null) {
						session.setAttribute("user", tempstr);
						headportraitimg headportraitimg = headPortraitImgService.selectheadportrait(tempstr);
						if (headportraitimg.getHeadportraitimgaddress() != null) {
							session.setAttribute("headportraitimg", headportraitimg.getHeadportraitimgaddress());
						}
						return "official";
					}
				} catch (NullPointerException e) {
					if (tempstr == null) {
						request.setAttribute("erorr", "输入账号密码有误!");
						return "login";
					} else {
						return "official";
					}
				}
			}
			if (identity[0].equals("admin")) {
				adminlist temp = new adminlist();
				temp.setAdminname(username);
				temp.setAdminpwd(pwd);
				adminlist adminlist = adminListService.findAllAdminPwd(temp);
				try {
					tempstr = adminlist.getAdminname();
					if (tempstr != null) {
						session.setAttribute("admin", tempstr);
						return "BackgroundHome";
					}
				} catch (NullPointerException e) {
					request.setAttribute("erorr", "输入账号密码有误!");
					return "login";
				}
			}
		} catch (NullPointerException e) {
			request.setAttribute("erorr", "选择登录方式!");
			e.printStackTrace();
			return "login";
		}

		return "login";
	}

	/**
	 * 注册
	 */
	@RequestMapping("/register")
	public String register(String usercall, String userpwd, String userphone, HttpServletRequest request) {
		if (usercall.equals("") || userpwd.equals("") || userphone.equals("")) {
			request.setAttribute("erorr", "输入账号密码不能为空!");
			return "register";
		}
		userlist user = new userlist();
		user.setUsercall(usercall);
		user.setUserphone(userphone);
		user.setUserpwd(userpwd);
		userlistService.insert(user);
		headportraitimg userimg = new headportraitimg();
		userimg.setHeadportraitimgusername(usercall);
		headPortraitImgService.insertuserimg(userimg);
		return "login";
	}

	/**
	 * 获取手机验证码
	 **/
	@RequestMapping("/getcode")
	public void getcode(String userphone, HttpServletResponse response, HttpServletRequest request) {
		response.setCharacterEncoding("UTF-8");
		try {
			HttpSession session = request.getSession();
			String code = "123456";
//			String code = Code.getNum(userphone);
			System.out.println(code);
			session.setAttribute("code", code);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	/**
	 * 判断验证码输入后登陆
	 **/
	@RequestMapping("/phonecod")
	public String phonecod(String userphone, String code, HttpServletRequest request) {
		HttpSession session = request.getSession();
		if (userphone.equals("") || code.equals("")) {
			request.setAttribute("erorr", "手机号或者验证码为空!");
			return "login";
		}
		System.out.println(code);
		if (code.equals(session.getAttribute("code"))) {
			userlist user = userlistService.selectUserPhone(userphone);
			if (user != null) {
				String tempstr = null;
				userlist userlist = userlistService.selectUserPhone(userphone);
				tempstr = userlist.getUsercall();
				if (tempstr != null) {
					session.setAttribute("user", tempstr);
					headportraitimg headportraitimg = headPortraitImgService.selectheadportrait(tempstr);
					if (headportraitimg.getHeadportraitimgaddress() != null) {
						session.setAttribute("headportraitimg", headportraitimg.getHeadportraitimgaddress());
					}
					return "official";
				}
			} else {
				request.setAttribute("erorr", "该手机号未注册!");
				return "login";
			}
		} else {
			request.setAttribute("erorr", "验证码错误!");
			return "login";
		}
		return "login";
	}

	/**
	 * 修改密码
	 */
	@RequestMapping("/updatepwd")
	public String updatepwd(String code, String userphone, String userpwd, HttpServletRequest request) {
		if (code.equals("") || userphone.equals("") || userpwd.equals("")) {
			request.setAttribute("erorr", "手机号,验证码,新密码不能为空!");
			return "updatepwd";
		}
		HttpSession session = request.getSession();
		if (code.equals(session.getAttribute("code"))) {
			userlist userlist = userlistService.selectUserPhone(userphone);
			userlist.setUserpwd(userpwd);
			userlistService.updatepwd(userlist);
			return "login";
		}
		return userpwd;
	}

	/**
	 * 注销
	 */
	@RequestMapping("/cancellation")
	public String cancellation(HttpServletRequest request) {
		HttpSession session = request.getSession();
		session.removeAttribute("user");
		System.out.println("注销成功");
		return "official";
	}

	/**
	 * 申请看房
	 */
	@RequestMapping("/apply")
	@ResponseBody
	public ModelAndView apply(HttpSession session, HttpServletRequest request, String housemoney, String housecall,
			String houseaddress,String housesize) {
		ModelAndView mav = new ModelAndView("official");
		//令牌验证
		if(!new Koken().kokenid(request, session)) {
			return mav;	
		}
		mav.addObject("news", "official");
		if ((String) session.getAttribute("user") == null) {
			mav.addObject("apply", "请先登录!");
			return mav;
		}
		// 查询所有数据
		userlist user = userlistService.selectUserCall((String) session.getAttribute("user"));
		if (user.getUsername() == null) {// 判断真实姓名是否为空
			mav.addObject("apply", "请绑定真实姓名后再租赁房屋!");
			return mav;
		} else {
			checkoutapplication coa = new checkoutapplication();
			coa.setCoausername(user.getUsername());
			coa.setCoauserid(user.getUserid());
			coa.setCoauserphone(user.getUserphone());
			coa.setCoahouseid(housecall);
			coa.setCoahouseaddress(houseaddress);
			coa.setCoahouseprice(Double.parseDouble(housemoney));
			coa.setCoahousesize(Double.parseDouble(housesize));
			coa.setCoastate("看房申请中");
			String temp=checkoutapplicationService.insertApply(coa);
			mav.addObject("apply", temp);
		}
		return mav;
	}

}

 

源码获取:博客首页 "资源" 里下载!

上一篇:cookie-parser与 express-session


下一篇:leetcode 326 矩阵中的最长递增路径