1.项目背景
在互联网+时代背景下,传统的租房管理模式已难以满足现代化管理的需求。随着Java Web技术的快速发展,基于B/S架构的管理系统成为行业标准。本项目springboot94sk3正是基于这一背景开发的现代化租房管理系统。
2.项目目标
-
实现租房业务的数字化管理
-
提高信息处理效率和准确性
-
提供友好的用户交互体验
-
确保系统稳定性和安全性
3. 技术选型理由
选择Spring Boot + MySQL技术栈基于以下考虑:
-
Spring Boot:简化配置,快速开发
-
MySQL:开源、稳定、社区活跃
-
MyBatis Plus:简化数据库操作
-
Maven:依赖管理和项目构建
4.数据sql
此处sql只放了部分
sql
DROP TABLE IF EXISTS `config`;
CREATE TABLE `config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(100) NOT NULL COMMENT '配置参数名称',
`value` varchar(100) DEFAULT NULL COMMENT '配置参数值',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='配置文件';
/*Data for the table `config` */
insert into `config`(`id`,`name`,`value`) values (1,'picture1','http://localhost:8080/springboot94sk3/upload/picture1.jpg');
insert into `config`(`id`,`name`,`value`) values (2,'picture2','http://localhost:8080/springboot94sk3/upload/picture2.jpg');
insert into `config`(`id`,`name`,`value`) values (3,'picture3','http://localhost:8080/springboot94sk3/upload/picture3.jpg');
insert into `config`(`id`,`name`,`value`) values (6,'homepage',NULL);
/*Table structure for table `dingdanxinxi` */
DROP TABLE IF EXISTS `dingdanxinxi`;
CREATE TABLE `dingdanxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`zukezhanghao` varchar(200) DEFAULT NULL COMMENT '租客账号',
`zukexingming` varchar(200) DEFAULT NULL COMMENT '租客姓名',
`fangwubianhao` varchar(200) DEFAULT NULL COMMENT '房屋编号',
`fangwumingcheng` varchar(200) DEFAULT NULL COMMENT '房屋名称',
`fangwudizhi` varchar(200) DEFAULT NULL COMMENT '房屋地址',
`zulinjiage` int(11) DEFAULT NULL COMMENT '租赁价格',
`ruzhuriqi` datetime DEFAULT NULL COMMENT '入住日期',
`beizhu` longtext COMMENT '备注',
`lianxidianhua` varchar(200) DEFAULT NULL COMMENT '联系电话',
`wuzhuzhanghao` varchar(200) DEFAULT NULL COMMENT '屋主账号',
`sfsh` varchar(200) DEFAULT '否' COMMENT '是否审核',
`shhf` longtext COMMENT '审核回复',
`ispay` varchar(200) DEFAULT '未支付' COMMENT '是否支付',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8 COMMENT='订单信息';
/*Data for the table `dingdanxinxi` */
insert into `dingdanxinxi`(`id`,`addtime`,`zukezhanghao`,`zukexingming`,`fangwubianhao`,`fangwumingcheng`,`fangwudizhi`,`zulinjiage`,`ruzhuriqi`,`beizhu`,`lianxidianhua`,`wuzhuzhanghao`,`sfsh`,`shhf`,`ispay`) values (51,'2021-05-02 12:01:25','租客账号1','租客姓名1','房屋编号1','房屋名称1','房屋地址1',1,'2021-05-02 12:01:25','备注1','13823888881','屋主账号1','是','','未支付');
insert into `dingdanxinxi`(`id`,`addtime`,`zukezhanghao`,`zukexingming`,`fangwubianhao`,`fangwumingcheng`,`fangwudizhi`,`zulinjiage`,`ruzhuriqi`,`beizhu`,`lianxidianhua`,`wuzhuzhanghao`,`sfsh`,`shhf`,`ispay`) values (52,'2021-05-02 12:01:25','租客账号2','租客姓名2','房屋编号2','房屋名称2','房屋地址2',2,'2021-05-02 12:01:25','备注2','13823888882','屋主账号2','是','','未支付');
insert into `dingdanxinxi`(`id`,`addtime`,`zukezhanghao`,`zukexingming`,`fangwubianhao`,`fangwumingcheng`,`fangwudizhi`,`zulinjiage`,`ruzhuriqi`,`beizhu`,`lianxidianhua`,`wuzhuzhanghao`,`sfsh`,`shhf`,`ispay`) values (53,'2021-05-02 12:01:25','租客账号3','租客姓名3','房屋编号3','房屋名称3','房屋地址3',3,'2021-05-02 12:01:25','备注3','13823888883','屋主账号3','是','','未支付');
insert into `dingdanxinxi`(`id`,`addtime`,`zukezhanghao`,`zukexingming`,`fangwubianhao`,`fangwumingcheng`,`fangwudizhi`,`zulinjiage`,`ruzhuriqi`,`beizhu`,`lianxidianhua`,`wuzhuzhanghao`,`sfsh`,`shhf`,`ispay`) values (54,'2021-05-02 12:01:25','租客账号4','租客姓名4','房屋编号4','房屋名称4','房屋地址4',4,'2021-05-02 12:01:25','备注4','13823888884','屋主账号4','是','','未支付');
insert into `dingdanxinxi`(`id`,`addtime`,`zukezhanghao`,`zukexingming`,`fangwubianhao`,`fangwumingcheng`,`fangwudizhi`,`zulinjiage`,`ruzhuriqi`,`beizhu`,`lianxidianhua`,`wuzhuzhanghao`,`sfsh`,`shhf`,`ispay`) values (55,'2021-05-02 12:01:25','租客账号5','租客姓名5','房屋编号5','房屋名称5','房屋地址5',5,'2021-05-02 12:01:25','备注5','13823888885','屋主账号5','是','','未支付');
insert into `dingdanxinxi`(`id`,`addtime`,`zukezhanghao`,`zukexingming`,`fangwubianhao`,`fangwumingcheng`,`fangwudizhi`,`zulinjiage`,`ruzhuriqi`,`beizhu`,`lianxidianhua`,`wuzhuzhanghao`,`sfsh`,`shhf`,`ispay`) values (56,'2021-05-02 12:01:25','租客账号6','租客姓名6','房屋编号6','房屋名称6','房屋地址6',6,'2021-05-02 12:01:25','备注6','13823888886','屋主账号6','是','','未支付');
/*Table structure for table `discussfangyuanxinxi` */
DROP TABLE IF EXISTS `discussfangyuanxinxi`;
CREATE TABLE `discussfangyuanxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`refid` bigint(20) NOT NULL COMMENT '关联表id',
`userid` bigint(20) NOT NULL COMMENT '用户id',
`nickname` varchar(200) DEFAULT NULL COMMENT '用户名',
`content` longtext NOT NULL COMMENT '评论内容',
`reply` longtext COMMENT '回复内容',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=137 DEFAULT CHARSET=utf8 COMMENT='房源信息评论表';
/*Data for the table `discussfangyuanxinxi` */
insert into `discussfangyuanxinxi`(`id`,`addtime`,`refid`,`userid`,`nickname`,`content`,`reply`) values (131,'2021-05-02 12:01:25',1,1,'用户名1','评论内容1','回复内容1');
insert into `discussfangyuanxinxi`(`id`,`addtime`,`refid`,`userid`,`nickname`,`content`,`reply`) values (132,'2021-05-02 12:01:25',2,2,'用户名2','评论内容2','回复内容2');
insert into `discussfangyuanxinxi`(`id`,`addtime`,`refid`,`userid`,`nickname`,`content`,`reply`) values (133,'2021-05-02 12:01:25',3,3,'用户名3','评论内容3','回复内容3');
insert into `discussfangyuanxinxi`(`id`,`addtime`,`refid`,`userid`,`nickname`,`content`,`reply`) values (134,'2021-05-02 12:01:25',4,4,'用户名4','评论内容4','回复内容4');
insert into `discussfangyuanxinxi`(`id`,`addtime`,`refid`,`userid`,`nickname`,`content`,`reply`) values (135,'2021-05-02 12:01:25',5,5,'用户名5','评论内容5','回复内容5');
insert into `discussfangyuanxinxi`(`id`,`addtime`,`refid`,`userid`,`nickname`,`content`,`reply`) values (136,'2021-05-02 12:01:25',6,6,'用户名6','评论内容6','回复内容6');
/*Table structure for table `fangyuanxinxi` */
DROP TABLE IF EXISTS `fangyuanxinxi`;
CREATE TABLE `fangyuanxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`fangwubianhao` varchar(200) DEFAULT NULL COMMENT '房屋编号',
`fangwumingcheng` varchar(200) DEFAULT NULL COMMENT '房屋名称',
`fangwudizhi` varchar(200) DEFAULT NULL COMMENT '房屋地址',
`fangwuzhuangtai` varchar(200) DEFAULT NULL COMMENT '房屋状态',
`fangwutedian` varchar(200) DEFAULT NULL COMMENT '房屋特点',
`fangwujieshao` longtext COMMENT '房屋介绍',
`chengjiaoliang` varchar(200) DEFAULT NULL COMMENT '成交量',
`zulinjiage` int(11) DEFAULT NULL COMMENT '租赁价格',
`xiangqing` longtext COMMENT '详情',
`fangwuzhaopian` varchar(200) DEFAULT NULL COMMENT '房屋照片',
`wuzhuzhanghao` varchar(200) DEFAULT NULL COMMENT '屋主账号',
`wuzhuxingming` varchar(200) DEFAULT NULL COMMENT '屋主姓名',
`lianxidianhua` varchar(200) DEFAULT NULL COMMENT '联系电话',
`sfsh` varchar(200) DEFAULT '否' COMMENT '是否审核',
`shhf` longtext COMMENT '审核回复',
`thumbsupnum` int(11) DEFAULT '0' COMMENT '赞',
`crazilynum` int(11) DEFAULT '0' COMMENT '踩',
`clicktime` datetime DEFAULT NULL COMMENT '最近点击时间',
`clicknum` int(11) DEFAULT '0' COMMENT '点击次数',
PRIMARY KEY (`id`),
UNIQUE KEY `fangwubianhao` (`fangwubianhao`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COMMENT='房源信息';
5.项目架构

6.核心代码
用户端
sql
package com.controller;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
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.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
/**
* 登录相关
*/
@RequestMapping("users")
@RestController
public class UserController{
@Autowired
private UserService userService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
userService.update(user,null);
return R.ok("密码已重置为:123456");
}
/**
* 列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/list")
public R list( UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", userService.selectListView(ew));
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
房主
sql
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.WuzhuEntity;
import com.entity.view.WuzhuView;
import com.service.WuzhuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 屋主
* 后端接口
* @author
* @email
* @date 2021-05-02 12:00:50
*/
@RestController
@RequestMapping("/wuzhu")
public class WuzhuController {
@Autowired
private WuzhuService wuzhuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
WuzhuEntity user = wuzhuService.selectOne(new EntityWrapper<WuzhuEntity>().eq("wuzhuzhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"wuzhu", "屋主" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody WuzhuEntity wuzhu){
//ValidatorUtils.validateEntity(wuzhu);
WuzhuEntity user = wuzhuService.selectOne(new EntityWrapper<WuzhuEntity>().eq("wuzhuzhanghao", wuzhu.getWuzhuzhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
wuzhu.setId(uId);
wuzhuService.insert(wuzhu);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
WuzhuEntity user = wuzhuService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
WuzhuEntity user = wuzhuService.selectOne(new EntityWrapper<WuzhuEntity>().eq("wuzhuzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
wuzhuService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,WuzhuEntity wuzhu,
HttpServletRequest request){
EntityWrapper<WuzhuEntity> ew = new EntityWrapper<WuzhuEntity>();
PageUtils page = wuzhuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wuzhu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,WuzhuEntity wuzhu,
HttpServletRequest request){
EntityWrapper<WuzhuEntity> ew = new EntityWrapper<WuzhuEntity>();
PageUtils page = wuzhuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wuzhu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( WuzhuEntity wuzhu){
EntityWrapper<WuzhuEntity> ew = new EntityWrapper<WuzhuEntity>();
ew.allEq(MPUtil.allEQMapPre( wuzhu, "wuzhu"));
return R.ok().put("data", wuzhuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(WuzhuEntity wuzhu){
EntityWrapper< WuzhuEntity> ew = new EntityWrapper< WuzhuEntity>();
ew.allEq(MPUtil.allEQMapPre( wuzhu, "wuzhu"));
WuzhuView wuzhuView = wuzhuService.selectView(ew);
return R.ok("查询屋主成功").put("data", wuzhuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
WuzhuEntity wuzhu = wuzhuService.selectById(id);
return R.ok().put("data", wuzhu);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
WuzhuEntity wuzhu = wuzhuService.selectById(id);
return R.ok().put("data", wuzhu);
}
7.结果展示
登录页面

管理端页面

用户端

8.注意
需要数据库配置改成自己的