随着房屋迭代更新的速度越来越快,房地产过剩越来越多。导致年轻人出现对购买房屋的花销越来越高,房屋租赁共享平台是因为社会对房屋的需求多样,但是又存在部分人因为缺乏资金购买商品房的问题而设计的。这个房屋租赁品台不仅能够很好的解决年轻人因为资金不足而购买不了房屋,而且能够从一定程度上减少房屋资源的浪费。
为了使房屋资源利用效率最优化,首先结合市面出现“有偿共享”的共享方式和社会实际情况进行需求分析,其次,对当前软件开发技术进行研究,提出使用Spring、SpringBoot框架以及Android平台,MySQL5.7数据库管理数据实现前台用户信息管理、订单管理、房屋管理和后台订单管理、房屋管理、用户信息管理等功能租赁系统。本系统能够从一定程度上减少房屋资源的浪费的现象。
关键词:房屋 租赁平台 SpringBoot 小程序
【650】基于微信小程序的房屋租赁平台设计与实现
ABSTRACT
With the faster and faster iteration and renewal of houses, there is more and more excess real estate. As a result, young people spend more and more on buying houses. The housing rental sharing platform is designed because of the diverse social demand for houses, but some people lack funds to buy commercial houses. This house rental platform can not only solve the problem that young people cannot buy houses because of insufficient funds, but also reduce the waste of housing resources to a certain extent.
In order to optimize the utilization efficiency of housing resources, firstly, the demand analysis is carried out in combination with the sharing mode of "paid sharing" in the market and the actual social situation. Secondly, the current software development technology is studied, and it is proposed to use spring, springboot framework and Android platform, MySQL 5.7 database management data to realize foreground user information management, order management, housing management and background order management, housing management User information management and other functions leasing system. This system can reduce the waste of housing resources to a certain extent.
Key words: house rental platform springboot applet
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.csmaxwell</groupId>
<artifactId>srent</artifactId>
<version>0.1.0</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
</properties>
<modules>
<module>srent-core</module>
<module>srent-db</module>
<module>srent-wx-api</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.csmaxwell</groupId>
<artifactId>srent-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.csmaxwell</groupId>
<artifactId>srent-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.csmaxwell</groupId>
<artifactId>srent-wx-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Spring Boot Mybatis 依赖 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.1.0.Final</version>
</dependency>
<!-- MySQL 连接驱动依赖 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-pay</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.github.qcloudsms</groupId>
<artifactId>qcloudsms</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api</artifactId>
<version>5.4.4</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>[7.2.0, 7.2.99]</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- 热部署模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!-- 测试模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
package com.csmaxwell.srent.core.config;
import com.csmaxwell.srent.core.util.ResponseUtil;
import org.hibernate.validator.internal.engine.path.PathImpl;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import java.util.Set;
@ControllerAdvice
@Order( value = Ordered.LOWEST_PRECEDENCE )
public class GlobalExceptionHandler {
@ExceptionHandler(IllegalArgumentException.class)
@ResponseBody
public Object badArgumentHandler(IllegalArgumentException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseBody
public Object badArgumentHandler(MissingServletRequestParameterException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody
public Object badArgumentHandler(HttpMessageNotReadableException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(ValidationException.class)
@ResponseBody
public Object badArgumentHandler(ValidationException e) {
e.printStackTrace();
if (e instanceof ConstraintViolationException) {
ConstraintViolationException exs = (ConstraintViolationException) e;
Set<ConstraintViolation<?>> violations = exs.getConstraintViolations();
for (ConstraintViolation<?> item : violations) {
String message = ((PathImpl) item.getPropertyPath()).getLeafNode().getName() + item.getMessage();
return ResponseUtil.fail(402, message);
}
}
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(Exception.class)
@ResponseBody
public Object seriousHandler(Exception e) {
e.printStackTrace();
return ResponseUtil.serious();
}
}
package com.csmaxwell.srent.core.system;
import com.csmaxwell.srent.core.util.SystemInfoPrinter;
import com.csmaxwell.srent.db.service.SrentSystemConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 系统启动服务,用于设置系统配置信息、检查系统状态及打印系统信息
*/
@Component
class SystemInistService {
private SystemInistService systemInistService;
@Autowired
private Environment environment;
@PostConstruct
private void inist() {
systemInistService = this;
initConfigs();
SystemInfoPrinter.printInfo("Srent 初始化信息", getSystemInfo());
}
private final static Map<String, String> DEFAULT_CONFIGS = new HashMap<>();
static {
// 小程序相关配置默认值
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_NEW, "6");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_HOT, "6");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_BRAND, "4");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_TOPIC, "4");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_CATLOG_LIST, "4");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_CATLOG_GOODS, "4");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_SHARE, "false");
// 运费相关配置默认值
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_EXPRESS_FREIGHT_VALUE, "8");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_EXPRESS_FREIGHT_MIN, "88");
// 订单相关配置默认值
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_ORDER_UNPAID, "30");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_ORDER_UNCONFIRM, "7");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_ORDER_COMMENT, "7");
// 订单相关配置默认值
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_NAME, "srent");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_ADDRESS, "上海");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_PHONE, "021-xxxx-xxxx");
DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_QQ, "738696120");
}
@Autowired
private SrentSystemConfigService srentSystemConfigService;
private void initConfigs() {
// 1. 读取数据库全部配置信息
Map<String, String> configs = srentSystemConfigService.queryAll();
// 2. 分析DEFAULT_CONFIGS
for (Map.Entry<String, String> entry : DEFAULT_CONFIGS.entrySet()) {
if(configs.containsKey(entry.getKey())){
continue;
}
configs.put(entry.getKey(), entry.getValue());
srentSystemConfigService.addConfig(entry.getKey(), entry.getValue());
}
SystemConfig.setConfigs(configs);
}
private Map<String, String> getSystemInfo() {
Map<String, String> infos = new LinkedHashMap<>();
infos.put(SystemInfoPrinter.CREATE_PART_COPPER + 0, "系统信息");
// 测试获取application-db.yml配置信息
infos.put("服务器端口", environment.getProperty("server.port"));
infos.put("数据库USER", environment.getProperty("spring.datasource.druid.username"));
infos.put("数据库地址", environment.getProperty("spring.datasource.druid.url"));
infos.put("对象存储", environment.getProperty("srent.storage.active"));
infos.put("本地对象存储路径", environment.getProperty("srent.storage.local" +
".storagePath"));
infos.put("本地对象访问地址", environment.getProperty("srent.storage.local" +
".address"));
infos.put("本地对象访问端口", environment.getProperty("srent.storage.local" +
".port"));
// 微信相关信息
infos.put(SystemInfoPrinter.CREATE_PART_COPPER + 2, "微信相关");
infos.put("微信APP KEY", environment.getProperty("srent.wx.app-id"));
infos.put("微信APP-SECRET", environment.getProperty("srent.wx" +
".app-secret"));
return infos;
}
}