小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>

前言

围绕“搜索”核心业务,构建 “房屋寻租”完整前后端


一、项目简介

1.业务

分角色用户入口:普通用户/管理员用户
完善的管理功能:后台管理/权限管理
核心功能模块:房源浏览 / 搜索/地图找房
会员系统/预约看房
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第1张图片

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第2张图片

2.技术

核心技术&搜索引擎:ElasticSearch(基于5.x最新版本)
前端:Thymeleaf、Jquery、Bootstrap、webUpLoad
基础核心框架:Spring Boot + Spring Data JPA
权限控制:Spring Security
数据库:MySQL、H2
消息中间件:Kafka
应用数据分析:ELK
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第3张图片
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第4张图片

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第5张图片

二、项目设计

1.项目背景

方便找房子操作,北漂的我,居无定所,换个工作换个房子,虽然只换过一次房子,O(∩_∩)O哈哈~

2.数据库设计

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第6张图片
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第7张图片
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第8张图片

3.表设计原则

  • 数据聚合原则
  • 慎用数据库特性(为以后分库分表做打算)

三、项目:github地址

https://github.com/cunweizhao/es-house

四、ElasticSearch搭建,Windows版本-单个节点

下载地址:
https://www.elastic.co/cn/downloads/past-releases#elasticsearch
在这里插入图片描述
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第9张图片
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第10张图片

  • 启动:
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第11张图片
  • 浏览器出现这种情况,正常启动
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第12张图片

1.插件安装-head(提供界面)

下载地址:
https://github.com/mobz/elasticsearch-head

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第13张图片

  • 需要node环境
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第14张图片
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第15张图片
  • 下载一些依赖
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第16张图片
    启动:
npm run start
  • 修改配置,然后把插件与ES进行绑定
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第17张图片
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第18张图片
http.cors.enabled: true
http.cors.allow-origin: "*"

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第19张图片

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第20张图片

  • 链接成功
    小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第21张图片

五、项目:代码编写创建配置类

package com.zcw.eshouse.config;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @ClassName : JPAConfig
 * @Description : 配置类
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 11:16
 */
@Configuration
@EnableJpaRepositories(basePackages = "com.zcw.eshouse.repository")
@EnableTransactionManagement //允许事务管理
public class JPAConfig {
     

    /**
     * 创建数据源
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource(){
     
        return DataSourceBuilder.create().build();
    }
    /**
     * 创建实体类的管理工厂
     */
    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
     
        HibernateJpaVendorAdapter japVendor = new HibernateJpaVendorAdapter();
        //是否生成sql
        japVendor.setGenerateDdl(false);
        //管理工厂类
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
        entityManagerFactory.setDataSource(dataSource());
        //jpa的适配器
        entityManagerFactory.setJpaVendorAdapter(japVendor);
        entityManagerFactory.setPackagesToScan("com.zcw.eshouse.entity");
        return entityManagerFactory;
    }
    /**
     * 创建事务管理类
     */
    @Bean
    public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
     
        JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(entityManagerFactory);
        return transactionManager;
    }
}


六、H2内存数据库使用

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第22张图片

spring.datasource.driver-class-name=org.h2.Driver
# 内存模式
spring.datasource.url=jdbc:h2:mem:test

spring.datasource.schema=classpath:db/schema.sql
spring.datasource.data=classpath:db/data.sql

spring.thymeleaf.cache=true

elasticsearch.cluster.name=xunwu
elasticsearch.host=127.0.0.1
elasticsearch.port=9300

七、前端集成

H-ui.admin

1.jar包的依赖

<!-- 前端模板 thymeleaf 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.thymeleaf</groupId>
                    <artifactId>thymeleaf-spring5</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>${
     thymeleaf.version}</version>
        </dependency>

        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring4</artifactId>
            <version>3.0.2.RELEASE</version>
        </dependency>

2.编写webmvc配置类

package com.zcw.eshouse.config;

import org.modelmapper.ModelMapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;

/**
 * @ClassName : WebMvcConfig
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 16:20
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware {
     
    @Value("${spring.thymeleaf.cache}")
    private boolean thymeleafCacheEnable = true;

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
     
        this.applicationContext = applicationContext;
    }

    /**
     * 静态资源加载配置
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
     
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    /**
     * 模板资源解析器
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "spring.thymeleaf")
    public SpringResourceTemplateResolver templateResolver() {
     
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setCharacterEncoding("UTF-8");
        templateResolver.setCacheable(thymeleafCacheEnable);
        return templateResolver;
    }

    /**
     * Thymeleaf标准方言解释器
     */
    @Bean
    public SpringTemplateEngine templateEngine() {
     
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(templateResolver());
        // 支持Spring EL表达式
        templateEngine.setEnableSpringELCompiler(true);

        // 支持SpringSecurity方言
        SpringSecurityDialect securityDialect = new SpringSecurityDialect();
        templateEngine.addDialect(securityDialect);
        return templateEngine;
    }

    /**
     * 视图解析器--解析模板
     */
    @Bean
    public ThymeleafViewResolver viewResolver() {
     
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setTemplateEngine(templateEngine());
        return viewResolver;
    }

    /**
     * Bean Util
     * @return
     */
    @Bean
    public ModelMapper modelMapper() {
     
        return new ModelMapper();
    }
}


小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第23张图片
小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第24张图片

八、编写controller层代码

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第25张图片

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第26张图片

九、封装API统一返回对象

1.API格式封装

package com.zcw.eshouse.base;

/**
 * @ClassName : ApiResponse
 * @Description : API格式封装
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 16:55
 */
public class ApiResponse {
     
    private int code;
    private String message;
    private Object data;
    private boolean more;

    public ApiResponse(int code, String message, Object data) {
     
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ApiResponse() {
     
        this.code = Status.SUCCESS.getCode();
        this.message = Status.SUCCESS.getStandardMessage();
    }

    public int getCode() {
     
        return code;
    }

    public void setCode(int code) {
     
        this.code = code;
    }

    public String getMessage() {
     
        return message;
    }

    public void setMessage(String message) {
     
        this.message = message;
    }

    public Object getData() {
     
        return data;
    }

    public void setData(Object data) {
     
        this.data = data;
    }

    public boolean isMore() {
     
        return more;
    }

    public void setMore(boolean more) {
     
        this.more = more;
    }

    public static ApiResponse ofMessage(int code, String message) {
     
        return new ApiResponse(code, message, null);
    }

    public static ApiResponse ofSuccess(Object data) {
     
        return new ApiResponse(Status.SUCCESS.getCode(), Status.SUCCESS.getStandardMessage(), data);
    }

    public static ApiResponse ofStatus(Status status) {
     
        return new ApiResponse(status.getCode(), status.getStandardMessage(), null);
    }

    public enum Status {
     
        SUCCESS(200, "OK"),
        BAD_REQUEST(400, "Bad Request"),
        NOT_FOUND(404, "Not Found"),
        INTERNAL_SERVER_ERROR(500, "Unknown Internal Error"),
        NOT_VALID_PARAM(40005, "Not valid Params"),
        NOT_SUPPORTED_OPERATION(40006, "Operation not supported"),
        NOT_LOGIN(50000, "Not Login");

        private int code;
        private String standardMessage;

        Status(int code, String standardMessage) {
     
            this.code = code;
            this.standardMessage = standardMessage;
        }

        public int getCode() {
     
            return code;
        }

        public void setCode(int code) {
     
            this.code = code;
        }

        public String getStandardMessage() {
     
            return standardMessage;
        }

        public void setStandardMessage(String standardMessage) {
     
            this.standardMessage = standardMessage;
        }
    }
}


2.服务接口通用结构

package com.zcw.eshouse.service;

/**
 * @ClassName : ServiceResult
 * @Description : 服务接口通用结构
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 16:57
 */
public class ServiceResult<T> {
     
    private boolean success;
    private String message;
    private T result;

    public ServiceResult(boolean success) {
     
        this.success = success;
    }

    public ServiceResult(boolean success, String message) {
     
        this.success = success;
        this.message = message;
    }

    public ServiceResult(boolean success, String message, T result) {
     
        this.success = success;
        this.message = message;
        this.result = result;
    }

    public boolean isSuccess() {
     
        return success;
    }

    public void setSuccess(boolean success) {
     
        this.success = success;
    }

    public String getMessage() {
     
        return message;
    }

    public void setMessage(String message) {
     
        this.message = message;
    }

    public T getResult() {
     
        return result;
    }

    public void setResult(T result) {
     
        this.result = result;
    }

    public static <T> ServiceResult<T> success() {
     
        return new ServiceResult<>(true);
    }

    public static <T> ServiceResult<T> of(T result) {
     
        ServiceResult<T> serviceResult = new ServiceResult<>(true);
        serviceResult.setResult(result);
        return serviceResult;
    }

    public static <T> ServiceResult<T> notFound() {
     
        return new ServiceResult<>(false, Message.NOT_FOUND.getValue());
    }

    public enum Message {
     
        NOT_FOUND("Not Found Resource!"),
        NOT_LOGIN("User not login!");

        private String value;

        Message(String value) {
     
            this.value = value;
        }

        public String getValue() {
     
            return value;
        }
    }
}


十、搭建service层

package com.zcw.eshouse.service;

/**
 * 验证码服务
 */
public interface ISmsService {
     

    /**
     * 发送验证码到指定手机 并 缓存验证码 10分钟 及 请求间隔时间1分钟
     * @param telephone
     * @return
     */
    ServiceResult<String> sendSms(String telephone);

    /**
     * 获取缓存中的验证码
     * @param telehone
     * @return
     */
    String getSmsCode(String telehone);

    /**
     * 移除指定手机号的验证码缓存
     */
    void remove(String telephone);
}


十一、工具类

package com.zcw.eshouse.base;

import java.util.regex.Pattern;

import com.zcw.eshouse.entity.User;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @ClassName : LoginUserUtil
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 17:12
 */
public class LoginUserUtil {
     
    private static final String PHONE_REGEX = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
    private static final Pattern PHONE_PATTERN = Pattern.compile(PHONE_REGEX);

    private static final String EMAIL_REGEX = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
    private static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX);

    public static User load() {
     
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        if (principal != null && principal instanceof User) {
     
            return (User) principal;
        }
        return null;
    }

    public static Long getLoginUserId() {
     
        User user = load();
        if (user == null) {
     
            return -1L;
        }

        return user.getId();
    }

    /**
     * 验证手机号码
     *
     * 移动号码段:139、138、137、136、135、134、150、151、152、157、158、159、182、183、187、188、147
     * 联通号码段:130、131、132、136、185、186、145
     * 电信号码段:133、153、180、189
     *
     * @param target 目标号码
     * @return 如果是手机号码 返回true; 反之,返回false
     */
    public static boolean checkTelephone(String target) {
     
        return PHONE_PATTERN.matcher(target).matches();
    }

    /**
     * 验证一般的英文邮箱
     * @param target 目标邮箱
     * @return 如果符合邮箱规则 返回true; 反之,返回false
     */
    public static boolean checkEmail(String target) {
     
        return EMAIL_PATTERN.matcher(target).matches();
    }
}


十二、异常拦截器配置

1.修改配置项

小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第27张图片

package com.zcw.eshouse.base;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @ClassName : AppErrorController
 * @Description : web错误 全局配置
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 17:44
 */
@Controller
public class AppErrorController implements ErrorController {
     
    private static final String ERROR_PATH = "/error";

    private ErrorAttributes errorAttributes;

    @Override
    public String getErrorPath() {
     
        return ERROR_PATH;
    }

    @Autowired
    public AppErrorController(ErrorAttributes errorAttributes) {
     
        this.errorAttributes = errorAttributes;
    }

    /**
     * Web页面错误处理
     */
    @RequestMapping(value = ERROR_PATH, produces = "text/html")
    public String errorPageHandler(HttpServletRequest request, HttpServletResponse response) {
     
        int status = response.getStatus();
        switch (status) {
     
            case 403:
                return "403";
            case 404:
                return "404";
            case 500:
                return "500";
        }

        return "index";
    }

    /**
     * 除Web页面外的错误处理,比如Json/XML等
     */
    @RequestMapping(value = ERROR_PATH)
    @ResponseBody
    public ApiResponse errorApiHandler(HttpServletRequest request) {
     
        RequestAttributes requestAttributes = new ServletRequestAttributes(request);

        Map<String, Object> attr = this.errorAttributes.getErrorAttributes(requestAttributes, false);
        int status = getStatus(request);

        return ApiResponse.ofMessage(status, String.valueOf(attr.getOrDefault("message", "error")));
    }

    private int getStatus(HttpServletRequest request) {
     
        Integer status = (Integer) request.getAttribute("javax.servlet.error.status_code");
        if (status != null) {
     
            return status;
        }

        return 500;
    }
}


小清新【一目了然掌握核心技术】----------基于ElasticSearch的搜房网实战<一>_第28张图片

十三、后台管理模块实现

package com.zcw.eshouse.base;

/**
 * @ClassName : ApiDataTableResponse
 * @Description : Datatables响应结构
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:42
 */
public class ApiDataTableResponse extends ApiResponse {
     
    private int draw;
    private long recordsTotal;
    private long recordsFiltered;

    public ApiDataTableResponse(ApiResponse.Status status) {
     
        this(status.getCode(), status.getStandardMessage(), null);
    }

    public ApiDataTableResponse(int code, String message, Object data) {
     
        super(code, message, data);
    }

    public int getDraw() {
     
        return draw;
    }

    public void setDraw(int draw) {
     
        this.draw = draw;
    }

    public long getRecordsTotal() {
     
        return recordsTotal;
    }

    public void setRecordsTotal(long recordsTotal) {
     
        this.recordsTotal = recordsTotal;
    }

    public long getRecordsFiltered() {
     
        return recordsFiltered;
    }

    public void setRecordsFiltered(long recordsFiltered) {
     
        this.recordsFiltered = recordsFiltered;
    }
}


package com.zcw.eshouse.base;

/**
 * @ClassName : HouseOperation
 * @Description : 房屋操作状态常量定义
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:53
 */
public class HouseOperation {
     
    public static final int PASS = 1; // 通过审核

    public static final int PULL_OUT = 2; // 下架。重新审核

    public static final int DELETE = 3; // 逻辑删除

    public static final int RENT = 4; // 出租
}


package com.zcw.eshouse.base;

/**
 * 房源状态
 */
public enum HouseStatus {
     
    NOT_AUDITED(0), // 未审核
    PASSES(1), // 审核通过
    RENTED(2), // 已出租
    DELETED(3); // 逻辑删除
    private int value;

    HouseStatus(int value) {
     
        this.value = value;
    }

    public int getValue() {
     
        return value;
    }
}


package com.zcw.eshouse.base;

/**
 * @enum : HouseSubscribeStatus
 * @Description : 预约状态码
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:51
 */
public enum HouseSubscribeStatus {
     
    NO_SUBSCRIBE(0), // 未预约
    IN_ORDER_LIST(1), // 已加入待看清单
    IN_ORDER_TIME(2), // 已经预约看房时间
    FINISH(3); // 已完成预约

    private int value;

    HouseSubscribeStatus(int value) {
     
        this.value = value;
    }

    public int getValue() {
     
        return value;
    }

    public static HouseSubscribeStatus of(int value) {
     
        for (HouseSubscribeStatus status : HouseSubscribeStatus.values()) {
     
            if (status.getValue() == value) {
     
                return status;
            }
        }
        return HouseSubscribeStatus.NO_SUBSCRIBE;
    }
}


package com.zcw.eshouse.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @ClassName : SupportAddress
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:31
 */
@Entity
@Table(name = "support_address")
public class SupportAddress {
     
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // 上一级行政单位
    @Column(name = "belong_to")
    private String belongTo;

    @Column(name = "en_name")
    private String enName;

    @Column(name = "cn_name")
    private String cnName;

    private String level;

    @Column(name = "baidu_map_lng")
    private double baiduMapLongitude;

    @Column(name = "baidu_map_lat")
    private double baiduMapLatitude;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public String getBelongTo() {
     
        return belongTo;
    }

    public void setBelongTo(String belongTo) {
     
        this.belongTo = belongTo;
    }

    public String getEnName() {
     
        return enName;
    }

    public void setEnName(String enName) {
     
        this.enName = enName;
    }

    public String getCnName() {
     
        return cnName;
    }

    public void setCnName(String cnName) {
     
        this.cnName = cnName;
    }

    public String getLevel() {
     
        return level;
    }

    public void setLevel(String level) {
     
        this.level = level;
    }

    public double getBaiduMapLongitude() {
     
        return baiduMapLongitude;
    }

    public void setBaiduMapLongitude(double baiduMapLongitude) {
     
        this.baiduMapLongitude = baiduMapLongitude;
    }

    public double getBaiduMapLatitude() {
     
        return baiduMapLatitude;
    }

    public void setBaiduMapLatitude(double baiduMapLatitude) {
     
        this.baiduMapLatitude = baiduMapLatitude;
    }

    /**
     * 行政级别定义
     */
    public enum Level {
     
        CITY("city"),
        REGION("region");

        private String value;

        Level(String value) {
     
            this.value = value;
        }

        public String getValue() {
     
            return value;
        }

        public static Level of(String value) {
     
            for (Level level : Level.values()) {
     
                if (level.getValue().equals(value)) {
     
                    return level;
                }
            }

            throw new IllegalArgumentException();
        }
    }
}

package com.zcw.eshouse.service.house;

import com.zcw.eshouse.entity.SupportAddress;
import com.zcw.eshouse.service.ServiceMultiResult;
import com.zcw.eshouse.service.ServiceResult;
import com.zcw.eshouse.service.search.BaiduMapLocation;
import com.zcw.eshouse.web.dto.SubwayDTO;
import com.zcw.eshouse.web.dto.SubwayStationDTO;
import com.zcw.eshouse.web.dto.SupportAddressDTO;

import java.util.List;
import java.util.Map;

/**
 * 地址服务接口
 */
public interface IAddressService {
     
    /**
     * 获取所有支持的城市列表
     * @return
     */
    ServiceMultiResult<SupportAddressDTO> findAllCities();

    /**
     * 根据英文简写获取具体区域的信息
     * @param cityEnName
     * @param regionEnName
     * @return
     */
    Map<SupportAddress.Level, SupportAddressDTO> findCityAndRegion(String cityEnName, String regionEnName);

    /**
     * 根据城市英文简写获取该城市所有支持的区域信息
     * @param cityName
     * @return
     */
    ServiceMultiResult findAllRegionsByCityName(String cityName);

    /**
     * 获取该城市所有的地铁线路
     * @param cityEnName
     * @return
     */
    List<SubwayDTO> findAllSubwayByCity(String cityEnName);

    /**
     * 获取地铁线路所有的站点
     * @param subwayId
     * @return
     */
    List<SubwayStationDTO> findAllStationBySubway(Long subwayId);

    /**
     * 获取地铁线信息
     * @param subwayId
     * @return
     */
    ServiceResult<SubwayDTO> findSubway(Long subwayId);

    /**
     * 获取地铁站点信息
     * @param stationId
     * @return
     */
    ServiceResult<SubwayStationDTO> findSubwayStation(Long stationId);

    /**
     * 根据城市英文简写获取城市详细信息
     * @param cityEnName
     * @return
     */
    ServiceResult<SupportAddressDTO> findCity(String cityEnName);

    /**
     * 根据城市以及具体地位获取百度地图的经纬度
     */
    ServiceResult<BaiduMapLocation> getBaiduMapLocation(String city, String address);

    /**
     * 上传百度LBS数据
     */
    ServiceResult lbsUpload(BaiduMapLocation location, String title, String address,
                            long houseId, int price, int area);

    /**
     * 移除百度LBS数据
     * @param houseId
     * @return
     */
    ServiceResult removeLbs(Long houseId);
}


package com.zcw.eshouse.service.house;

import com.zcw.eshouse.base.HouseSubscribeStatus;
import com.zcw.eshouse.service.ServiceMultiResult;
import com.zcw.eshouse.service.ServiceResult;
import com.zcw.eshouse.service.search.DatatableSearch;
import com.zcw.eshouse.service.search.MapSearch;
import com.zcw.eshouse.web.dto.HouseDTO;
import com.zcw.eshouse.web.dto.HouseSubscribeDTO;
import com.zcw.eshouse.web.form.HouseForm;
import com.zcw.eshouse.web.form.RentSearch;
import java.util.Date;

import org.springframework.data.util.Pair;

import java.util.Date;

/**
 * @interface : IHouseService
 * @Description : 房屋管理服务接口
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:30
 */
public interface IHouseService {
     
    /**
     * 新增
     * @param houseForm
     * @return
     */
    ServiceResult<HouseDTO> save(HouseForm houseForm);

    ServiceResult update(HouseForm houseForm);

    ServiceMultiResult<HouseDTO> adminQuery(DatatableSearch searchBody);

    /**
     * 查询完整房源信息
     * @param id
     * @return
     */
    ServiceResult<HouseDTO> findCompleteOne(Long id);

    /**
     * 移除图片
     * @param id
     * @return
     */
    ServiceResult removePhoto(Long id);

    /**
     * 更新封面
     * @param coverId
     * @param targetId
     * @return
     */
    ServiceResult updateCover(Long coverId, Long targetId);

    /**
     * 新增标签
     * @param houseId
     * @param tag
     * @return
     */
    ServiceResult addTag(Long houseId, String tag);

    /**
     * 移除标签
     * @param houseId
     * @param tag
     * @return
     */
    ServiceResult removeTag(Long houseId, String tag);

    /**
     * 更新房源状态
     * @param id
     * @param status
     * @return
     */
    ServiceResult updateStatus(Long id, int status);

    /**
     * 查询房源信息集
     * @param rentSearch
     * @return
     */
    ServiceMultiResult<HouseDTO> query(RentSearch rentSearch);

    /**
     * 全地图查询
     * @param mapSearch
     * @return
     */
    ServiceMultiResult<HouseDTO> wholeMapQuery(MapSearch mapSearch);

    /**
     * 精确范围数据查询
     * @param mapSearch
     * @return
     */
    ServiceMultiResult<HouseDTO> boundMapQuery(MapSearch mapSearch);

    /**
     * 加入预约清单
     * @param houseId
     * @return
     */
    ServiceResult addSubscribeOrder(Long houseId);

    /**
     * 获取对应状态的预约列表
     */
    ServiceMultiResult<Pair<HouseDTO, HouseSubscribeDTO>> querySubscribeList(HouseSubscribeStatus status, int start, int size);

    /**
     * 预约看房时间
     * @param houseId
     * @param orderTime
     * @param telephone
     * @param desc
     * @return
     */
    ServiceResult subscribe(Long houseId, Date orderTime, String telephone, String desc);

    /**
     * 取消预约
     * @param houseId
     * @return
     */
    ServiceResult cancelSubscribe(Long houseId);

    /**
     * 管理员查询预约信息接口
     * @param start
     * @param size
     */
    ServiceMultiResult<Pair<HouseDTO, HouseSubscribeDTO>> findSubscribeList(int start, int size);

    /**
     * 完成预约
     */
    ServiceResult finishSubscribe(Long houseId);
}


package com.zcw.eshouse.service.house;

import com.qiniu.common.QiniuException;

import java.io.File;
import java.io.InputStream;
import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;

/**
 * 七牛云服务
 */
public interface IQiNiuService {
     
    Response uploadFile(File file) throws QiniuException;

    Response uploadFile(InputStream inputStream) throws QiniuException;

    Response delete(String key) throws QiniuException;
}


package com.zcw.eshouse.service.house;

import java.io.File;
import java.io.InputStream;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;

/**
 * @ClassName : QiNiuServiceImpl
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:56
 */
@Service
public class QiNiuServiceImpl implements IQiNiuService, InitializingBean {
     
    @Autowired
    private UploadManager uploadManager;

    @Autowired
    private BucketManager bucketManager;

    @Autowired
    private Auth auth;

    @Value("${qiniu.Bucket}")
    private String bucket;

    private StringMap putPolicy;

    @Override
    public Response uploadFile(File file) throws QiniuException {
     
        Response response = this.uploadManager.put(file, null, getUploadToken());
        int retry = 0;
        while (response.needRetry() && retry < 3) {
     
            response = this.uploadManager.put(file, null, getUploadToken());
            retry++;
        }
        return response;
    }

    @Override
    public Response uploadFile(InputStream inputStream) throws QiniuException {
     
        Response response = this.uploadManager.put(inputStream, null, getUploadToken(), null, null);
        int retry = 0;
        while (response.needRetry() && retry < 3) {
     
            response = this.uploadManager.put(inputStream, null, getUploadToken(), null, null);
            retry++;
        }
        return response;
    }

    @Override
    public Response delete(String key) throws QiniuException {
     
        Response response = bucketManager.delete(this.bucket, key);
        int retry = 0;
        while (response.needRetry() && retry++ < 3) {
     
            response = bucketManager.delete(bucket, key);
        }
        return response;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
     
        this.putPolicy = new StringMap();
        putPolicy.put("returnBody", "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"bucket\":\"$(bucket)\",\"width\":$(imageInfo.width), \"height\":${imageInfo.height}}");
    }

    /**
     * 获取上传凭证
     * @return
     */
    private String getUploadToken() {
     
        return this.auth.uploadToken(bucket, null, 3600, putPolicy);
    }
}


package com.zcw.eshouse.service.search;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * @ClassName : BaiduMapLocation
 * @Description :百度位置信息
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:40
 */
public class BaiduMapLocation {
     
    // 经度
    @JsonProperty("lon")
    private double longitude;

    // 纬度
    @JsonProperty("lat")
    private double latitude;

    public double getLongitude() {
     
        return longitude;
    }

    public void setLongitude(double longitude) {
     
        this.longitude = longitude;
    }

    public double getLatitude() {
     
        return latitude;
    }

    public void setLatitude(double latitude) {
     
        this.latitude = latitude;
    }
}


package com.zcw.eshouse.service.search;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
/**
 * @ClassName : DatatableSearch
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:45
 */
public class DatatableSearch {
     
    /**
     * Datatables要求回显字段
     */
    private int draw;

    /**
     * Datatables规定分页字段
     */
    private int start;
    private int length;

    private Integer status;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTimeMin;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTimeMax;

    private String city;
    private String title;
    private String direction;
    private String orderBy;

    public int getDraw() {
     
        return draw;
    }

    public void setDraw(int draw) {
     
        this.draw = draw;
    }

    public int getStart() {
     
        return start;
    }

    public void setStart(int start) {
     
        this.start = start;
    }

    public int getLength() {
     
        return length;
    }

    public void setLength(int length) {
     
        this.length = length;
    }

    public Integer getStatus() {
     
        return status;
    }

    public void setStatus(Integer status) {
     
        this.status = status;
    }

    public Date getCreateTimeMin() {
     
        return createTimeMin;
    }

    public void setCreateTimeMin(Date createTimeMin) {
     
        this.createTimeMin = createTimeMin;
    }

    public Date getCreateTimeMax() {
     
        return createTimeMax;
    }

    public void setCreateTimeMax(Date createTimeMax) {
     
        this.createTimeMax = createTimeMax;
    }

    public String getCity() {
     
        return city;
    }

    public void setCity(String city) {
     
        this.city = city;
    }

    public String getTitle() {
     
        return title;
    }

    public void setTitle(String title) {
     
        this.title = title;
    }

    public String getDirection() {
     
        return direction;
    }

    public void setDirection(String direction) {
     
        this.direction = direction;
    }

    public String getOrderBy() {
     
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
     
        this.orderBy = orderBy;
    }
}


package com.zcw.eshouse.service.search;

/**
 * @ClassName : MapSearch
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:49
 */
public class MapSearch {
     

    private String cityEnName;

    /**
     * 地图缩放级别
     */
    private int level = 12;
    private String orderBy = "lastUpdateTime";
    private String orderDirection = "desc";
    /**
     * 左上角
     */
    private Double leftLongitude;
    private Double leftLatitude;

    /**
     * 右下角
     */
    private Double rightLongitude;
    private Double rightLatitude;

    private int start = 0;
    private int size = 5;

    public String getCityEnName() {
     
        return cityEnName;
    }

    public void setCityEnName(String cityEnName) {
     
        this.cityEnName = cityEnName;
    }

    public int getLevel() {
     
        return level;
    }

    public void setLevel(int level) {
     
        this.level = level;
    }

    public String getOrderBy() {
     
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
     
        this.orderBy = orderBy;
    }

    public String getOrderDirection() {
     
        return orderDirection;
    }

    public void setOrderDirection(String orderDirection) {
     
        this.orderDirection = orderDirection;
    }

    public Double getLeftLongitude() {
     
        return leftLongitude;
    }

    public void setLeftLongitude(Double leftLongitude) {
     
        this.leftLongitude = leftLongitude;
    }

    public Double getLeftLatitude() {
     
        return leftLatitude;
    }

    public void setLeftLatitude(Double leftLatitude) {
     
        this.leftLatitude = leftLatitude;
    }

    public Double getRightLongitude() {
     
        return rightLongitude;
    }

    public void setRightLongitude(Double rightLongitude) {
     
        this.rightLongitude = rightLongitude;
    }

    public Double getRightLatitude() {
     
        return rightLatitude;
    }

    public void setRightLatitude(Double rightLatitude) {
     
        this.rightLatitude = rightLatitude;
    }

    public int getStart() {
     
        return start < 0 ? 0 : start;
    }

    public void setStart(int start) {
     
        this.start = start;
    }

    public int getSize() {
     
        return size > 100 ? 100 : size;
    }

    public void setSize(int size) {
     
        this.size = size;
    }
}


package com.zcw.eshouse.service;

import com.zcw.eshouse.entity.User;
import com.zcw.eshouse.web.dto.UserDTO;

/**
 * 用户服务
 */
public interface IUserService {
     
    User findUserByName(String userName);

    ServiceResult<UserDTO> findById(Long userId);

    /**
     * 根据电话号码寻找用户
     * @param telephone
     * @return
     */
    User findUserByTelephone(String telephone);

    /**
     * 通过手机号注册用户
     * @param telehone
     * @return
     */
    User addUserByPhone(String telehone);

    /**
     * 修改指定属性值
     * @param profile
     * @param value
     * @return
     */
    ServiceResult modifyUserProfile(String profile, String value);
}


package com.zcw.eshouse.service;

import java.util.List;

/**
 * @ClassName : ServiceMultiResult
 * @Description : 通用多结果Service返回结构
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:30
 */
public class ServiceMultiResult<T> {
     
    private long total;
    private List<T> result;

    public ServiceMultiResult(long total, List<T> result) {
     
        this.total = total;
        this.result = result;
    }

    public long getTotal() {
     
        return total;
    }

    public void setTotal(long total) {
     
        this.total = total;
    }

    public List<T> getResult() {
     
        return result;
    }

    public void setResult(List<T> result) {
     
        this.result = result;
    }

    public int getResultSize() {
     
        if (this.result == null) {
     
            return 0;
        }
        return this.result.size();
    }
}


package com.zcw.eshouse.web.dto;

/**
 * @ClassName : HouseDetailDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:35
 */
public class HouseDetailDTO {
     
    private String description;

    private String layoutDesc;

    private String traffic;

    private String roundService;

    private int rentWay;

    private Long adminId;

    private String address;

    private Long subwayLineId;

    private Long subwayStationId;

    private String subwayLineName;

    private String subwayStationName;

    public String getDescription() {
     
        return description;
    }

    public void setDescription(String description) {
     
        this.description = description;
    }

    public String getLayoutDesc() {
     
        return layoutDesc;
    }

    public void setLayoutDesc(String layoutDesc) {
     
        this.layoutDesc = layoutDesc;
    }

    public String getTraffic() {
     
        return traffic;
    }

    public void setTraffic(String traffic) {
     
        this.traffic = traffic;
    }

    public String getRoundService() {
     
        return roundService;
    }

    public void setRoundService(String roundService) {
     
        this.roundService = roundService;
    }

    public int getRentWay() {
     
        return rentWay;
    }

    public void setRentWay(int rentWay) {
     
        this.rentWay = rentWay;
    }

    public Long getAdminId() {
     
        return adminId;
    }

    public void setAdminId(Long adminId) {
     
        this.adminId = adminId;
    }

    public String getAddress() {
     
        return address;
    }

    public void setAddress(String address) {
     
        this.address = address;
    }

    public Long getSubwayLineId() {
     
        return subwayLineId;
    }

    public void setSubwayLineId(Long subwayLineId) {
     
        this.subwayLineId = subwayLineId;
    }

    public Long getSubwayStationId() {
     
        return subwayStationId;
    }

    public void setSubwayStationId(Long subwayStationId) {
     
        this.subwayStationId = subwayStationId;
    }

    public String getSubwayLineName() {
     
        return subwayLineName;
    }

    public void setSubwayLineName(String subwayLineName) {
     
        this.subwayLineName = subwayLineName;
    }

    public String getSubwayStationName() {
     
        return subwayStationName;
    }

    public void setSubwayStationName(String subwayStationName) {
     
        this.subwayStationName = subwayStationName;
    }
}


package com.zcw.eshouse.web.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @ClassName : HouseDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:32
 */
public class HouseDTO implements Serializable {
     
    private static final long serialVersionUID = 8918735582286008182L;
    private Long id;

    private String title;

    private int price;

    private int area;

    private int direction;

    private int room;

    private int parlour;

    private int bathroom;

    private int floor;

    private Long adminId;

    private String district;

    private int totalFloor;

    private int watchTimes;

    private int buildYear;

    private int status;

    private Date createTime;

    private Date lastUpdateTime;

    private String cityEnName;

    private String regionEnName;

    private String street;

    private String cover;

    private int distanceToSubway;

    private HouseDetailDTO houseDetail;

    private List<String> tags;

    private List<HousePictureDTO> pictures;

    private int subscribeStatus;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public String getTitle() {
     
        return title;
    }

    public void setTitle(String title) {
     
        this.title = title;
    }

    public int getPrice() {
     
        return price;
    }

    public void setPrice(int price) {
     
        this.price = price;
    }

    public int getArea() {
     
        return area;
    }

    public void setArea(int area) {
     
        this.area = area;
    }

    public int getDirection() {
     
        return direction;
    }

    public void setDirection(int direction) {
     
        this.direction = direction;
    }

    public int getRoom() {
     
        return room;
    }

    public void setRoom(int room) {
     
        this.room = room;
    }

    public int getParlour() {
     
        return parlour;
    }

    public void setParlour(int parlour) {
     
        this.parlour = parlour;
    }

    public int getBathroom() {
     
        return bathroom;
    }

    public void setBathroom(int bathroom) {
     
        this.bathroom = bathroom;
    }

    public int getFloor() {
     
        return floor;
    }

    public void setFloor(int floor) {
     
        this.floor = floor;
    }

    public Long getAdminId() {
     
        return adminId;
    }

    public void setAdminId(Long adminId) {
     
        this.adminId = adminId;
    }

    public String getDistrict() {
     
        return district;
    }

    public void setDistrict(String district) {
     
        this.district = district;
    }

    public int getTotalFloor() {
     
        return totalFloor;
    }

    public void setTotalFloor(int totalFloor) {
     
        this.totalFloor = totalFloor;
    }

    public int getWatchTimes() {
     
        return watchTimes;
    }

    public void setWatchTimes(int watchTimes) {
     
        this.watchTimes = watchTimes;
    }

    public int getBuildYear() {
     
        return buildYear;
    }

    public void setBuildYear(int buildYear) {
     
        this.buildYear = buildYear;
    }

    public int getStatus() {
     
        return status;
    }

    public void setStatus(int status) {
     
        this.status = status;
    }

    public List<String> getTags() {
     
        if (this.tags == null) {
     
            tags = new ArrayList<>();
        }
        return tags;
    }

    public void setTags(List<String> tags) {
     
        this.tags = tags;
    }

    public Date getCreateTime() {
     
        return createTime;
    }

    public void setCreateTime(Date createTime) {
     
        this.createTime = createTime;
    }

    public Date getLastUpdateTime() {
     
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
     
        this.lastUpdateTime = lastUpdateTime;
    }

    public String getCityEnName() {
     
        return cityEnName;
    }

    public void setCityEnName(String cityEnName) {
     
        this.cityEnName = cityEnName;
    }

    public String getStreet() {
     
        return street;
    }

    public void setStreet(String street) {
     
        this.street = street;
    }

    public String getCover() {
     
        return cover;
    }

    public void setCover(String cover) {
     
        this.cover = cover;
    }

    public int getDistanceToSubway() {
     
        return distanceToSubway;
    }

    public void setDistanceToSubway(int distanceToSubway) {
     
        this.distanceToSubway = distanceToSubway;
    }

    public HouseDetailDTO getHouseDetail() {
     
        return houseDetail;
    }

    public void setHouseDetail(HouseDetailDTO houseDetail) {
     
        this.houseDetail = houseDetail;
    }

    public String getRegionEnName() {
     
        return regionEnName;
    }

    public void setRegionEnName(String regionEnName) {
     
        this.regionEnName = regionEnName;
    }

    public List<HousePictureDTO> getPictures() {
     
        return pictures;
    }

    public void setPictures(List<HousePictureDTO> pictures) {
     
        this.pictures = pictures;
    }

    public int getSubscribeStatus() {
     
        return subscribeStatus;
    }

    public void setSubscribeStatus(int subscribeStatus) {
     
        this.subscribeStatus = subscribeStatus;
    }

    @Override
    public String toString() {
     
        return "HouseDTO{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", price=" + price +
                ", area=" + area +
                ", floor=" + floor +
                ", totalFloor=" + totalFloor +
                ", watchTimes=" + watchTimes +
                ", buildYear=" + buildYear +
                ", status=" + status +
                ", createTime=" + createTime +
                ", lastUpdateTime=" + lastUpdateTime +
                ", cityEnName='" + cityEnName + '\'' +
                ", cover='" + cover + '\'' +
                ", houseDetail=" + houseDetail +
                ", pictures=" + pictures +
                '}';
    }
}


package com.zcw.eshouse.web.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * @ClassName : HousePictureDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:52
 */
public class HousePictureDTO {
     

    private Long id;

    @JsonProperty(value = "house_id")
    private Long houseId;

    private String path;

    @JsonProperty(value = "cdn_prefix")
    private String cdnPrefix;

    private int width;

    private int height;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public Long getHouseId() {
     
        return houseId;
    }

    public void setHouseId(Long houseId) {
     
        this.houseId = houseId;
    }

    public String getPath() {
     
        return path;
    }

    public void setPath(String path) {
     
        this.path = path;
    }

    public String getCdnPrefix() {
     
        return cdnPrefix;
    }

    public void setCdnPrefix(String cdnPrefix) {
     
        this.cdnPrefix = cdnPrefix;
    }

    public int getWidth() {
     
        return width;
    }

    public void setWidth(int width) {
     
        this.width = width;
    }

    public int getHeight() {
     
        return height;
    }

    public void setHeight(int height) {
     
        this.height = height;
    }

    @Override
    public String toString() {
     
        return "HousePictureDTO{" +
                "id=" + id +
                ", houseId=" + houseId +
                ", path='" + path + '\'' +
                ", cdnPrefix='" + cdnPrefix + '\'' +
                ", width=" + width +
                ", height=" + height +
                '}';
    }
}


package com.zcw.eshouse.web.dto;

import java.util.Date;

/**
 * @ClassName : HouseSubscribeDTO
 * @Description : 预约看房实体类
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:50
 */
public class HouseSubscribeDTO {
     
    private Long id;

    private Long houseId;

    private Long userId;

    private Long adminId;

    // 预约状态 1-加入待看清单 2-已预约看房时间 3-看房完成
    private int status;

    private Date createTime;

    private Date lastUpdateTime;

    private Date orderTime;

    private String telephone;

    private String desc;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public Long getHouseId() {
     
        return houseId;
    }

    public void setHouseId(Long houseId) {
     
        this.houseId = houseId;
    }

    public Long getUserId() {
     
        return userId;
    }

    public void setUserId(Long userId) {
     
        this.userId = userId;
    }

    public Long getAdminId() {
     
        return adminId;
    }

    public void setAdminId(Long adminId) {
     
        this.adminId = adminId;
    }

    public int getStatus() {
     
        return status;
    }

    public void setStatus(int status) {
     
        this.status = status;
    }

    public Date getCreateTime() {
     
        return createTime;
    }

    public void setCreateTime(Date createTime) {
     
        this.createTime = createTime;
    }

    public Date getLastUpdateTime() {
     
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
     
        this.lastUpdateTime = lastUpdateTime;
    }

    public Date getOrderTime() {
     
        return orderTime;
    }

    public void setOrderTime(Date orderTime) {
     
        this.orderTime = orderTime;
    }

    public String getTelephone() {
     
        return telephone;
    }

    public void setTelephone(String telephone) {
     
        this.telephone = telephone;
    }

    public String getDesc() {
     
        return desc;
    }

    public void setDesc(String desc) {
     
        this.desc = desc;
    }
}


package com.zcw.eshouse.web.dto;

/**
 * @ClassName : QiNiuPutRet
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:52
 */
public class QiNiuPutRet {
     
    public String key;
    public String hash;
    public String bucket;
    public int width;
    public int height;

    @Override
    public String toString() {
     
        return "QiNiuPutRet{" +
                "key='" + key + '\'' +
                ", hash='" + hash + '\'' +
                ", bucket='" + bucket + '\'' +
                ", width=" + width +
                ", height=" + height +
                '}';
    }
}


package com.zcw.eshouse.web.dto;

/**
 * @ClassName : SubwayDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:37
 */
public class SubwayDTO {
     
    private Long id;
    private String name;
    private String cityEnName;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public String getName() {
     
        return name;
    }

    public void setName(String name) {
     
        this.name = name;
    }

    public String getCityEnName() {
     
        return cityEnName;
    }

    public void setCityEnName(String cityEnName) {
     
        this.cityEnName = cityEnName;
    }
}


package com.zcw.eshouse.web.dto;

/**
 * @ClassName : SubwayStationDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:39
 */
public class SubwayStationDTO {
     
    private Long id;
    private Long subwayId;
    private String name;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public Long getSubwayId() {
     
        return subwayId;
    }

    public void setSubwayId(Long subwayId) {
     
        this.subwayId = subwayId;
    }

    public String getName() {
     
        return name;
    }

    public void setName(String name) {
     
        this.name = name;
    }
}


package com.zcw.eshouse.web.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * @ClassName : SupportAddressDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:29
 */
public class SupportAddressDTO {
     
    private Long id;
    @JsonProperty(value = "belong_to")
    private String belongTo;

    @JsonProperty(value = "en_name")
    private String enName;

    @JsonProperty(value = "cn_name")
    private String cnName;

    private String level;

    private double baiduMapLongitude;

    private double baiduMapLatitude;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public String getBelongTo() {
     
        return belongTo;
    }

    public void setBelongTo(String belongTo) {
     
        this.belongTo = belongTo;
    }

    public String getEnName() {
     
        return enName;
    }

    public void setEnName(String enName) {
     
        this.enName = enName;
    }

    public String getCnName() {
     
        return cnName;
    }

    public void setCnName(String cnName) {
     
        this.cnName = cnName;
    }

    public String getLevel() {
     
        return level;
    }

    public void setLevel(String level) {
     
        this.level = level;
    }

    public double getBaiduMapLongitude() {
     
        return baiduMapLongitude;
    }

    public void setBaiduMapLongitude(double baiduMapLongitude) {
     
        this.baiduMapLongitude = baiduMapLongitude;
    }

    public double getBaiduMapLatitude() {
     
        return baiduMapLatitude;
    }

    public void setBaiduMapLatitude(double baiduMapLatitude) {
     
        this.baiduMapLatitude = baiduMapLatitude;
    }
}


package com.zcw.eshouse.web.dto;

/**
 * @ClassName : UserDTO
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:42
 */
public class UserDTO {
     
    private Long id;
    private String name;
    private String avatar;
    private String phoneNumber;
    private String lastLoginTime;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public String getName() {
     
        return name;
    }

    public void setName(String name) {
     
        this.name = name;
    }

    public String getAvatar() {
     
        return avatar;
    }

    public void setAvatar(String avatar) {
     
        this.avatar = avatar;
    }

    public String getPhoneNumber() {
     
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
     
        this.phoneNumber = phoneNumber;
    }

    public String getLastLoginTime() {
     
        return lastLoginTime;
    }

    public void setLastLoginTime(String lastLoginTime) {
     
        this.lastLoginTime = lastLoginTime;
    }
}


package com.zcw.eshouse.web.form;

import java.util.List;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @ClassName : HouseForm
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:43
 */
public class HouseForm {
     
    private Long id;

    @NotNull(message = "大标题不允许为空!")
    @Size(min = 1, max = 30, message = "标题长度必须在1~30之间")
    private String title;

    @NotNull(message = "必须选中一个城市")
    @Size(min = 1, message = "非法的城市")
    private String cityEnName;

    @NotNull(message = "必须选中一个地区")
    @Size(min = 1, message = "非法的地区")
    private String regionEnName;

    @NotNull(message = "必须填写街道")
    @Size(min = 1, message = "非法的街道")
    private String street;

    @NotNull(message = "必须填写小区")
    private String district;

    @NotNull(message = "详细地址不允许为空!")
    @Size(min = 1, max = 30, message = "详细地址长度必须在1~30之间")
    private String detailAddress;

    @NotNull(message = "必须填写卧室数量")
    @Min(value = 1, message = "非法的卧室数量")
    private Integer room;

    private int parlour;

    @NotNull(message = "必须填写所属楼层")
    private Integer floor;

    @NotNull(message = "必须填写总楼层")
    private Integer totalFloor;

    @NotNull(message = "必须填写房屋朝向")
    private Integer direction;

    @NotNull(message = "必须填写建筑起始时间")
    @Min(value = 1900, message = "非法的建筑起始时间")
    private Integer buildYear;

    @NotNull(message = "必须填写面积")
    @Min(value = 1)
    private Integer area;

    @NotNull(message = "必须填写租赁价格")
    @Min(value = 1)
    private Integer price;

    @NotNull(message = "必须选中一个租赁方式")
    @Min(value = 0)
    @Max(value = 1)
    private Integer rentWay;

    private Long subwayLineId;

    private Long subwayStationId;

    private int distanceToSubway = -1;

    private String layoutDesc;

    private String roundService;

    private String traffic;

    @Size(max = 255)
    private String description;

    private String cover;

    private List<String> tags;

    private List<PhotoForm> photos;

    public Long getId() {
     
        return id;
    }

    public void setId(Long id) {
     
        this.id = id;
    }

    public String getTitle() {
     
        return title;
    }

    public void setTitle(String title) {
     
        this.title = title;
    }

    public String getCityEnName() {
     
        return cityEnName;
    }

    public void setCityEnName(String cityEnName) {
     
        this.cityEnName = cityEnName;
    }

    public String getRegionEnName() {
     
        return regionEnName;
    }

    public void setRegionEnName(String regionEnName) {
     
        this.regionEnName = regionEnName;
    }

    public String getStreet() {
     
        return street;
    }

    public void setStreet(String street) {
     
        this.street = street;
    }

    public String getDistrict() {
     
        return district;
    }

    public void setDistrict(String district) {
     
        this.district = district;
    }

    public String getDetailAddress() {
     
        return detailAddress;
    }

    public void setDetailAddress(String detailAddress) {
     
        this.detailAddress = detailAddress;
    }

    public Integer getRoom() {
     
        return room;
    }

    public void setRoom(Integer room) {
     
        this.room = room;
    }

    public int getParlour() {
     
        return parlour;
    }

    public void setParlour(int parlour) {
     
        this.parlour = parlour;
    }

    public Integer getFloor() {
     
        return floor;
    }

    public void setFloor(Integer floor) {
     
        this.floor = floor;
    }

    public Integer getTotalFloor() {
     
        return totalFloor;
    }

    public void setTotalFloor(Integer totalFloor) {
     
        this.totalFloor = totalFloor;
    }

    public Integer getDirection() {
     
        return direction;
    }

    public void setDirection(Integer direction) {
     
        this.direction = direction;
    }

    public Integer getBuildYear() {
     
        return buildYear;
    }

    public void setBuildYear(Integer buildYear) {
     
        this.buildYear = buildYear;
    }

    public Integer getArea() {
     
        return area;
    }

    public void setArea(Integer area) {
     
        this.area = area;
    }

    public Integer getPrice() {
     
        return price;
    }

    public void setPrice(Integer price) {
     
        this.price = price;
    }

    public Integer getRentWay() {
     
        return rentWay;
    }

    public void setRentWay(Integer rentWay) {
     
        this.rentWay = rentWay;
    }

    public Long getSubwayLineId() {
     
        return subwayLineId;
    }

    public void setSubwayLineId(Long subwayLineId) {
     
        this.subwayLineId = subwayLineId;
    }

    public Long getSubwayStationId() {
     
        return subwayStationId;
    }

    public void setSubwayStationId(Long subwayStationId) {
     
        this.subwayStationId = subwayStationId;
    }

    public int getDistanceToSubway() {
     
        return distanceToSubway;
    }

    public void setDistanceToSubway(int distanceToSubway) {
     
        this.distanceToSubway = distanceToSubway;
    }

    public String getLayoutDesc() {
     
        return layoutDesc;
    }

    public void setLayoutDesc(String layoutDesc) {
     
        this.layoutDesc = layoutDesc;
    }

    public String getRoundService() {
     
        return roundService;
    }

    public void setRoundService(String roundService) {
     
        this.roundService = roundService;
    }

    public String getTraffic() {
     
        return traffic;
    }

    public void setTraffic(String traffic) {
     
        this.traffic = traffic;
    }

    public String getDescription() {
     
        return description;
    }

    public void setDescription(String description) {
     
        this.description = description;
    }

    public String getCover() {
     
        return cover;
    }

    public void setCover(String cover) {
     
        this.cover = cover;
    }

    public List<String> getTags() {
     
        return tags;
    }

    public void setTags(List<String> tags) {
     
        this.tags = tags;
    }

    public List<PhotoForm> getPhotos() {
     
        return photos;
    }

    public void setPhotos(List<PhotoForm> photos) {
     
        this.photos = photos;
    }

    @Override
    public String toString() {
     
        return "HouseForm{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", cityEnName='" + cityEnName + '\'' +
                ", regionEnName='" + regionEnName + '\'' +
                ", district='" + district + '\'' +
                ", detailAddress='" + detailAddress + '\'' +
                ", room=" + room +
                ", parlour=" + parlour +
                ", floor=" + floor +
                ", totalFloor=" + totalFloor +
                ", direction=" + direction +
                ", buildYear=" + buildYear +
                ", area=" + area +
                ", price=" + price +
                ", rentWay=" + rentWay +
                ", subwayLineId=" + subwayLineId +
                ", subwayStationId=" + subwayStationId +
                ", distanceToSubway=" + distanceToSubway +
                ", layoutDesc='" + layoutDesc + '\'' +
                ", roundService='" + roundService + '\'' +
                ", traffic='" + traffic + '\'' +
                ", description='" + description + '\'' +
                ", cover='" + cover + '\'' +
                ", photos=" + photos +
                '}';
    }
}



package com.zcw.eshouse.web.form;

/**
 * @ClassName : PhotoForm
 * @Description :
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:44
 */
public class PhotoForm {
     
    private String path;

    private int width;

    private int height;

    public String getPath() {
     
        return path;
    }

    public void setPath(String path) {
     
        this.path = path;
    }

    public int getWidth() {
     
        return width;
    }

    public void setWidth(int width) {
     
        this.width = width;
    }

    public int getHeight() {
     
        return height;
    }

    public void setHeight(int height) {
     
        this.height = height;
    }
}

package com.zcw.eshouse.web.form;

/**
 * @ClassName : RentSearch
 * @Description : 租房请求参数结构体
 * @Author : Zhaocunwei
 * @Date: 2020-07-31 18:48
 */
public class RentSearch {
     

    private String cityEnName;
    private String regionEnName;
    private String priceBlock;
    private String areaBlock;
    private int room;
    private int direction;
    private String keywords;
    private int rentWay = -1;
    private String orderBy = "lastUpdateTime";
    private String orderDirection = "desc";

    public int getDirection() {
     
        return direction;
    }

    public void setDirection(int direction) {
     
        this.direction = direction;
    }

    private int start = 0;

    private int size = 5;

    public String getCityEnName() {
     
        return cityEnName;
    }

    public void setCityEnName(String cityEnName) {
     
        this.cityEnName = cityEnName;
    }

    public int getStart() {
     
        return start > 0 ? start : 0;
    }

    public void setStart(int start) {
     
        this.start = start;
    }

    public int getSize() {
     
        if (this.size < 1) {
     
            return 5;
        } else if (this.size > 100) {
     
            return 100;
        } else {
     
            return this.size;
        }
    }

    public void setSize(int size) {
     
        this.size = size;
    }

    public String getRegionEnName() {
     
        return regionEnName;
    }

    public void setRegionEnName(String regionEnName) {
     
        this.regionEnName = regionEnName;
    }

    public String getPriceBlock() {
     
        return priceBlock;
    }

    public void setPriceBlock(String priceBlock) {
     
        this.priceBlock = priceBlock;
    }

    public String getAreaBlock() {
     
        return areaBlock;
    }

    public void setAreaBlock(String areaBlock) {
     
        this.areaBlock = areaBlock;
    }

    public int getRoom() {
     
        return room;
    }

    public void setRoom(int room) {
     
        this.room = room;
    }

    public String getKeywords() {
     
        return keywords;
    }

    public void setKeywords(String keywords) {
     
        this.keywords = keywords;
    }

    public int getRentWay() {
     
        if (rentWay > -2 && rentWay < 2) {
     
            return rentWay;
        } else {
     
            return -1;
        }
    }

    public void setRentWay(int rentWay) {
     
        this.rentWay = rentWay;
    }

    public String getOrderBy() {
     
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
     
        this.orderBy = orderBy;
    }

    public String getOrderDirection() {
     
        return orderDirection;
    }

    public void setOrderDirection(String orderDirection) {
     
        this.orderDirection = orderDirection;
    }

    @Override
    public String toString() {
     
        return "RentSearch {" +
                "cityEnName='" + cityEnName + '\'' +
                ", regionEnName='" + regionEnName + '\'' +
                ", priceBlock='" + priceBlock + '\'' +
                ", areaBlock='" + areaBlock + '\'' +
                ", room=" + room +
                ", direction=" + direction +
                ", keywords='" + keywords + '\'' +
                ", rentWay=" + rentWay +
                ", orderBy='" + orderBy + '\'' +
                ", orderDirection='" + orderDirection + '\'' +
                ", start=" + start +
                ", size=" + size +
                '}';
    }
}


你可能感兴趣的:(ElasticSearch,elasticsearch)