基于javaweb的SpringBoot房屋租赁系统(java+springboot+maven+vue+elementui+layui+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

341424020701

351424020701

361424020701

371424020701

381424020701

391424020701

基于javaweb的SpringBoot房屋租赁系统(java+springboot+maven+vue+elementui+layui+mysql)

项目介绍

基于SpringBoot Vue的大学生租房系统

角色:管理员、房主、用户

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

房主:房主登录进入大学生租房系统可以对首页,个人中心,房屋信息管理,预约看房管理,定金留房管理,租赁订单管理,房屋评价管理等功能进行相应操作

用户:用户登录进入大学生租房系统可以对首页,个人中心,预约看房管理,定金留房管理,租赁订单管理,房屋评价管理,消息提醒管理,我的收藏管理等功能进行相应操作

后端:SpringBoot+Mybaits

前端:Vue +ElementUI +Layui +HTML+CSS+JS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

/**
* 房屋信息
* 后端接口
* @email
*/
@RestController
@RequestMapping("/fangwuxinxi")
public class FangwuxinxiController {
@Autowired
private FangwuxinxiService fangwuxinxiService;

@Autowired
private StoreupService storeupService;




/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,FangwuxinxiEntity fangwuxinxi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("fangzhu")) {
fangwuxinxi.setFangzhuzhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<FangwuxinxiEntity> ew = new EntityWrapper<FangwuxinxiEntity>();
PageUtils page = fangwuxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, fangwuxinxi), params), params));

return R.ok().put("data", page);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
   	PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params));
return R.ok().put("data", page);
}

/**
* 列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params));
return R.ok().put("data", page);
}

/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
}

/**
* 详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
}

/**
* 根据name获取信息
*/
@RequestMapping("/info")
public R infoByName(@RequestParam String name){
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
return R.ok().put("data", config);
}

/**
* 保存
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
       return R.ok();
}

/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuming", yonghu.getYonghuming()));
if(user!=null) {
return R.error("用户已存在");
}
yonghu.setId(new Date().getTime());
yonghuService.insert(yonghu);
return R.ok();
}

/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
//ValidatorUtils.validateEntity(yonghu);
yonghuService.updateById(yonghu);//全部更新
return R.ok();
}


/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
yonghuService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}

/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);

if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
   public R save(@RequestBody XiaoxitixingEntity xiaoxitixing, HttpServletRequest request){
xiaoxitixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xiaoxitixing);
xiaoxitixingService.insert(xiaoxitixing);
return R.ok();
}

/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody XiaoxitixingEntity xiaoxitixing, HttpServletRequest request){
xiaoxitixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xiaoxitixing);
xiaoxitixingService.insert(xiaoxitixing);
return R.ok();
}

/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody XiaoxitixingEntity xiaoxitixing, HttpServletRequest request){
//ValidatorUtils.validateEntity(xiaoxitixing);
xiaoxitixingService.updateById(xiaoxitixing);//全部更新
return R.ok();
}


/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
xiaoxitixingService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}

/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
        }

if(tokenEntity != null) {
request.getSession().setAttribute("userId", tokenEntity.getUserid());
request.getSession().setAttribute("role", tokenEntity.getRole());
request.getSession().setAttribute("tableName", tokenEntity.getTablename());
request.getSession().setAttribute("username", tokenEntity.getUsername());
return true;
}

PrintWriter writer = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
try {
writer = response.getWriter();
writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));
} finally {
if(writer != null){
writer.close();
}
}
// throw new EIException("请先登录", 401);
return false;
}
}





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

/**
* 权限(Token)验证
*/
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {

public static final String LOGIN_TOKEN_KEY = "Token";

@Autowired
private TokenService tokenService;

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

//支持跨域请求
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
// 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态
if (request.getMethod().equals(RequestMethod.OPTIONS.name())) {
response.setStatus(HttpStatus.OK.value());
return false;
}

IgnoreAuth annotation;
if (handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);
} else {
return true;
}

//从header中获取token
String token = request.getHeader(LOGIN_TOKEN_KEY);

/**
* 不需要验证权限的方法直接放过
*/
if(annotation!=null) {
return true;
}

TokenEntity tokenEntity = null;
if(StringUtils.isNotBlank(token)) {
tokenEntity = tokenService.getTokenEntity(token);


项目链接:
https://javayms.github.io?id=241524180701201if
https://javayms.pages.dev?id=241524180701201if