实现mongodb查询房产数据接口
This commit is contained in:
parent
ace860102d
commit
0e59b3179e
18
pom.xml
18
pom.xml
|
@ -106,12 +106,12 @@
|
|||
<artifactId>okhttp</artifactId>
|
||||
<version>4.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>sitemap-j</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.ossez</groupId>-->
|
||||
<!-- <artifactId>sitemap-j</artifactId>-->
|
||||
<!-- <version>1.0.1-SNAPSHOT</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- swagger -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
|
@ -188,6 +188,12 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mailgun</groupId>
|
||||
<artifactId>mailgun-java</artifactId>
|
||||
|
|
|
@ -3,18 +3,13 @@ package com.northtecom.visatrack.api.controller.api;
|
|||
import com.northtecom.visatrack.api.controller.vo.VisaCaseSearch;
|
||||
import com.northtecom.visatrack.api.service.impl.BlogService;
|
||||
import com.northtecom.visatrack.api.service.impl.VisaCaseService;
|
||||
import com.redfin.sitemapgenerator.ChangeFreq;
|
||||
import com.redfin.sitemapgenerator.WebSitemapGenerator;
|
||||
import com.redfin.sitemapgenerator.WebSitemapUrl;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The API related to website content.
|
||||
|
@ -64,16 +59,16 @@ public class ContentController {
|
|||
|
||||
|
||||
|
||||
WebSitemapGenerator wsg = new WebSitemapGenerator("https://www.usvisatrack.com/", new File("D:\\home\\"));
|
||||
for (int i = 0; i < 39553; i++) {
|
||||
|
||||
|
||||
|
||||
WebSitemapUrl url = new WebSitemapUrl.Options("https://www.usvisatrack.com/visa/detail?id=" + i)
|
||||
.lastMod(new Date()).priority(1.0).changeFreq(ChangeFreq.HOURLY).build();
|
||||
wsg.addUrl(url);
|
||||
}
|
||||
wsg.write();
|
||||
// WebSitemapGenerator wsg = new WebSitemapGenerator("https://www.usvisatrack.com/", new File("D:\\home\\"));
|
||||
// for (int i = 0; i < 39553; i++) {
|
||||
//
|
||||
//
|
||||
//
|
||||
// WebSitemapUrl url = new WebSitemapUrl.Options("https://www.usvisatrack.com/visa/detail?id=" + i)
|
||||
// .lastMod(new Date()).priority(1.0).changeFreq(ChangeFreq.HOURLY).build();
|
||||
// wsg.addUrl(url);
|
||||
// }
|
||||
// wsg.write();
|
||||
|
||||
|
||||
// bt = FileUtils.readFileToByteArray(new File("D:\\home\\sitemap.xml"));
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.northtecom.visatrack.api.controller.api;
|
||||
|
||||
import com.northtecom.visatrack.api.controller.vo.SearchListVo;
|
||||
import com.northtecom.visatrack.api.data.mongo.ResidenceDocument;
|
||||
import com.northtecom.visatrack.api.service.mongoservice.MlsListingService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/24/19:16
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/mls/listing")
|
||||
public class MlsListingController {
|
||||
|
||||
private final MlsListingService mlsListingService;
|
||||
|
||||
public MlsListingController(MlsListingService mlsListingService) {
|
||||
this.mlsListingService = mlsListingService;
|
||||
}
|
||||
|
||||
@PostMapping("/searchList")
|
||||
public Page<ResidenceDocument> searchList(SearchListVo searchListVo) {
|
||||
return mlsListingService.searchList(searchListVo);
|
||||
}
|
||||
|
||||
@GetMapping("/getDetailByListId")
|
||||
public ResidenceDocument getDetailByMlsNumberAndRetsId(String listId) {
|
||||
String mlsNumber = listId.split("_")[0];
|
||||
String retsId = listId.split("_")[1];
|
||||
|
||||
return mlsListingService.getDetailByMlsNumberAndRetsId(mlsNumber, retsId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.northtecom.visatrack.api.controller.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/24/19:19
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class SearchListVo {
|
||||
private String searchAddress;
|
||||
private Integer searchKMRadius = 10;
|
||||
private Integer minPrice;
|
||||
private Integer maxPrice;
|
||||
private Integer pageIndex = 0;
|
||||
private Integer pageSize = 30;
|
||||
private String sortField;
|
||||
private String sortDirection;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/20/22:59
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document("agents")
|
||||
@CompoundIndex(name = "agent_uid", def = "{'mlsAgentId': 1, 'mlsRets': 1}")
|
||||
public class AgentDocument {
|
||||
@Id
|
||||
private String _id;
|
||||
private Long mlsAgentId;
|
||||
private Long mlsRets;
|
||||
private String nameFirst;
|
||||
private String nameLast;
|
||||
private String email;
|
||||
private String phoneOffice;
|
||||
private String phoneCell;
|
||||
private Date dateC;
|
||||
private Date dateM;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/14/20:15
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ClassDocument implements Serializable {
|
||||
private String className;
|
||||
private String visibleName;
|
||||
private String description;
|
||||
private String standardName;
|
||||
|
||||
private List<FieldDocument> fieldDocuments = new ArrayList<>();
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/14/20:18
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FieldDocument implements Serializable {
|
||||
|
||||
private String systemName;
|
||||
private String standardName;
|
||||
private String longName;
|
||||
private String dbName;
|
||||
private String shortName;
|
||||
private String maximumLength;
|
||||
private String dataType;
|
||||
|
||||
}
|
|
@ -0,0 +1,494 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.PersistenceCreator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/21/20:24
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
public class ListJson implements Serializable {
|
||||
|
||||
@JsonProperty("mlsNumber")
|
||||
private String mlsNumber;
|
||||
@JsonProperty("confRets")
|
||||
private ConfRetsDTO confRets;
|
||||
@JsonProperty("listingType")
|
||||
private String listingType;
|
||||
@JsonProperty("listingStatus")
|
||||
private String listingStatus;
|
||||
@JsonProperty("geolocationLat")
|
||||
private String geolocationLat;
|
||||
@JsonProperty("geolocationLong")
|
||||
private String geolocationLong;
|
||||
@JsonProperty("priceList")
|
||||
private Integer priceList;
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
@JsonProperty("address")
|
||||
private AddressDTO address;
|
||||
@JsonProperty("county")
|
||||
private CountyDTO county;
|
||||
@JsonProperty("agent")
|
||||
private AgentDTO agent;
|
||||
@JsonProperty("office")
|
||||
private OfficeDTO office;
|
||||
@JsonProperty("photoCount")
|
||||
private Integer photoCount;
|
||||
@JsonProperty("dateEntered")
|
||||
private Date dateEntered;
|
||||
|
||||
public ListJson() {
|
||||
}
|
||||
|
||||
@PersistenceCreator
|
||||
public ListJson(String mlsNumber, ConfRetsDTO confRets, String listingType, String listingStatus,
|
||||
String geolocationLat, String geolocationLong, Integer priceList, String description,
|
||||
AddressDTO address, CountyDTO county, AgentDTO agent, OfficeDTO office, Integer photoCount,
|
||||
Date dateEntered) {
|
||||
this.mlsNumber = mlsNumber;
|
||||
this.confRets = confRets;
|
||||
this.listingType = listingType;
|
||||
this.listingStatus = listingStatus;
|
||||
this.geolocationLat = geolocationLat;
|
||||
this.geolocationLong = geolocationLong;
|
||||
this.priceList = priceList;
|
||||
this.description = description;
|
||||
this.address = address;
|
||||
this.county = county;
|
||||
this.agent = agent;
|
||||
this.office = office;
|
||||
this.photoCount = photoCount;
|
||||
this.dateEntered = dateEntered;
|
||||
}
|
||||
|
||||
public String getMlsNumber() {
|
||||
return mlsNumber;
|
||||
}
|
||||
|
||||
public void setMlsNumber(String mlsNumber) {
|
||||
this.mlsNumber = mlsNumber;
|
||||
}
|
||||
|
||||
public ConfRetsDTO getConfRets() {
|
||||
return confRets;
|
||||
}
|
||||
|
||||
public void setConfRets(ConfRetsDTO confRets) {
|
||||
this.confRets = confRets;
|
||||
}
|
||||
|
||||
public String getListingType() {
|
||||
return listingType;
|
||||
}
|
||||
|
||||
public void setListingType(String listingType) {
|
||||
this.listingType = listingType;
|
||||
}
|
||||
|
||||
public String getListingStatus() {
|
||||
return listingStatus;
|
||||
}
|
||||
|
||||
public void setListingStatus(String listingStatus) {
|
||||
this.listingStatus = listingStatus;
|
||||
}
|
||||
|
||||
public String getGeolocationLat() {
|
||||
return geolocationLat;
|
||||
}
|
||||
|
||||
public void setGeolocationLat(String geolocationLat) {
|
||||
this.geolocationLat = geolocationLat;
|
||||
}
|
||||
|
||||
public String getGeolocationLong() {
|
||||
return geolocationLong;
|
||||
}
|
||||
|
||||
public void setGeolocationLong(String geolocationLong) {
|
||||
this.geolocationLong = geolocationLong;
|
||||
}
|
||||
|
||||
public Integer getPriceList() {
|
||||
return priceList;
|
||||
}
|
||||
|
||||
public void setPriceList(Integer priceList) {
|
||||
this.priceList = priceList;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public AddressDTO getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(AddressDTO address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public CountyDTO getCounty() {
|
||||
return county;
|
||||
}
|
||||
|
||||
public void setCounty(CountyDTO county) {
|
||||
this.county = county;
|
||||
}
|
||||
|
||||
public AgentDTO getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void setAgent(AgentDTO agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
|
||||
public OfficeDTO getOffice() {
|
||||
return office;
|
||||
}
|
||||
|
||||
public void setOffice(OfficeDTO office) {
|
||||
this.office = office;
|
||||
}
|
||||
|
||||
public Integer getPhotoCount() {
|
||||
return photoCount;
|
||||
}
|
||||
|
||||
public void setPhotoCount(Integer photoCount) {
|
||||
this.photoCount = photoCount;
|
||||
}
|
||||
|
||||
public Date getDateEntered() {
|
||||
return dateEntered;
|
||||
}
|
||||
|
||||
public void setDateEntered(Date dateEntered) {
|
||||
this.dateEntered = dateEntered;
|
||||
}
|
||||
|
||||
public void setAgentDtoData(String agentId, String agentNameFirst, String agentNameLast, String agentEmail,
|
||||
String agentPhoneOffice, String agentPhoneCell) {
|
||||
this.setAgent(new AgentDTO(agentId, agentNameFirst, agentNameLast, agentEmail, agentPhoneOffice,
|
||||
agentPhoneCell));
|
||||
}
|
||||
|
||||
public void setOfficeDtoData(String officeId, String officeName, String officeEmail) {
|
||||
this.setOffice(new OfficeDTO(officeId, officeName, officeEmail));
|
||||
}
|
||||
|
||||
public class ConfRetsDTO implements Serializable {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Integer id;
|
||||
@JsonProperty("dateM")
|
||||
private Date dateM;
|
||||
@JsonProperty("uid")
|
||||
private String uid;
|
||||
|
||||
public ConfRetsDTO() {
|
||||
}
|
||||
|
||||
public ConfRetsDTO(Integer id, Date dateM, String uid) {
|
||||
this.id = id;
|
||||
this.dateM = dateM;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getDateM() {
|
||||
return dateM;
|
||||
}
|
||||
|
||||
public void setDateM(Date dateM) {
|
||||
this.dateM = dateM;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
}
|
||||
|
||||
public class AddressDTO implements Serializable {
|
||||
|
||||
@JsonProperty("addressOneLine")
|
||||
private String addressOneLine;
|
||||
@JsonProperty("address")
|
||||
private String address;
|
||||
@JsonProperty("number")
|
||||
private String number;
|
||||
@JsonProperty("street")
|
||||
private String street;
|
||||
@JsonProperty("unit")
|
||||
private String unit;
|
||||
@JsonProperty("town")
|
||||
private String town;
|
||||
@JsonProperty("state")
|
||||
private String state;
|
||||
@JsonProperty("zip")
|
||||
private String zip;
|
||||
|
||||
public AddressDTO() {
|
||||
}
|
||||
|
||||
@PersistenceCreator
|
||||
public AddressDTO(String addressOneLine, String address, String number, String street, String unit,
|
||||
String town, String state, String zip) {
|
||||
this.addressOneLine = addressOneLine;
|
||||
this.address = address;
|
||||
this.number = number;
|
||||
this.street = street;
|
||||
this.unit = unit;
|
||||
this.town = town;
|
||||
this.state = state;
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getAddressOneLine() {
|
||||
return addressOneLine;
|
||||
}
|
||||
|
||||
public void setAddressOneLine(String addressOneLine) {
|
||||
this.addressOneLine = addressOneLine;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public String getTown() {
|
||||
return town;
|
||||
}
|
||||
|
||||
public void setTown(String town) {
|
||||
this.town = town;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CountyDTO implements Serializable {
|
||||
|
||||
@JsonProperty("countyId")
|
||||
private String countyId;
|
||||
@JsonProperty("countyName")
|
||||
private String countyName;
|
||||
|
||||
public CountyDTO() {
|
||||
}
|
||||
|
||||
@PersistenceCreator
|
||||
public CountyDTO(String countyId, String countyName) {
|
||||
this.countyId = countyId;
|
||||
this.countyName = countyName;
|
||||
}
|
||||
|
||||
public String getCountyId() {
|
||||
return countyId;
|
||||
}
|
||||
|
||||
public void setCountyId(String countyId) {
|
||||
this.countyId = countyId;
|
||||
}
|
||||
|
||||
public String getCountyName() {
|
||||
return countyName;
|
||||
}
|
||||
|
||||
public void setCountyName(String countyName) {
|
||||
this.countyName = countyName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class AgentDTO implements Serializable {
|
||||
|
||||
@JsonProperty("agentId")
|
||||
private String agentId;
|
||||
@JsonProperty("agentNameFirst")
|
||||
private String agentNameFirst;
|
||||
@JsonProperty("agentNameLast")
|
||||
private String agentNameLast;
|
||||
@JsonProperty("agentEmail")
|
||||
private String agentEmail;
|
||||
@JsonProperty("agentPhoneOffice")
|
||||
private String agentPhoneOffice;
|
||||
@JsonProperty("agentPhoneCell")
|
||||
private String agentPhoneCell;
|
||||
|
||||
public AgentDTO() {
|
||||
}
|
||||
|
||||
@PersistenceCreator
|
||||
public AgentDTO(String agentId, String agentNameFirst, String agentNameLast, String agentEmail,
|
||||
String agentPhoneOffice, String agentPhoneCell) {
|
||||
this.agentId = agentId;
|
||||
this.agentNameFirst = agentNameFirst;
|
||||
this.agentNameLast = agentNameLast;
|
||||
this.agentEmail = agentEmail;
|
||||
this.agentPhoneOffice = agentPhoneOffice;
|
||||
this.agentPhoneCell = agentPhoneCell;
|
||||
}
|
||||
|
||||
public String getAgentId() {
|
||||
return agentId;
|
||||
}
|
||||
|
||||
public void setAgentId(String agentId) {
|
||||
this.agentId = agentId;
|
||||
}
|
||||
|
||||
public String getAgentNameFirst() {
|
||||
return agentNameFirst;
|
||||
}
|
||||
|
||||
public void setAgentNameFirst(String agentNameFirst) {
|
||||
this.agentNameFirst = agentNameFirst;
|
||||
}
|
||||
|
||||
public String getAgentNameLast() {
|
||||
return agentNameLast;
|
||||
}
|
||||
|
||||
public void setAgentNameLast(String agentNameLast) {
|
||||
this.agentNameLast = agentNameLast;
|
||||
}
|
||||
|
||||
public String getAgentEmail() {
|
||||
return agentEmail;
|
||||
}
|
||||
|
||||
public void setAgentEmail(String agentEmail) {
|
||||
this.agentEmail = agentEmail;
|
||||
}
|
||||
|
||||
public String getAgentPhoneOffice() {
|
||||
return agentPhoneOffice;
|
||||
}
|
||||
|
||||
public void setAgentPhoneOffice(String agentPhoneOffice) {
|
||||
this.agentPhoneOffice = agentPhoneOffice;
|
||||
}
|
||||
|
||||
public String getAgentPhoneCell() {
|
||||
return agentPhoneCell;
|
||||
}
|
||||
|
||||
public void setAgentPhoneCell(String agentPhoneCell) {
|
||||
this.agentPhoneCell = agentPhoneCell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class OfficeDTO implements Serializable {
|
||||
|
||||
@JsonProperty("officeId")
|
||||
private String officeId;
|
||||
@JsonProperty("officeName")
|
||||
private String officeName;
|
||||
@JsonProperty("officeEmail")
|
||||
private String officeEmail;
|
||||
|
||||
public OfficeDTO() {
|
||||
}
|
||||
|
||||
@PersistenceCreator
|
||||
public OfficeDTO(String officeId, String officeName, String officeEmail) {
|
||||
this.officeId = officeId;
|
||||
this.officeName = officeName;
|
||||
this.officeEmail = officeEmail;
|
||||
}
|
||||
|
||||
public String getOfficeId() {
|
||||
return officeId;
|
||||
}
|
||||
|
||||
public void setOfficeId(String officeId) {
|
||||
this.officeId = officeId;
|
||||
}
|
||||
|
||||
public String getOfficeName() {
|
||||
return officeName;
|
||||
}
|
||||
|
||||
public void setOfficeName(String officeName) {
|
||||
this.officeName = officeName;
|
||||
}
|
||||
|
||||
public String getOfficeEmail() {
|
||||
return officeEmail;
|
||||
}
|
||||
|
||||
public void setOfficeEmail(String officeEmail) {
|
||||
this.officeEmail = officeEmail;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/20/21:31
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document("offices")
|
||||
@CompoundIndex(name = "office_uid", def = "{'mlsOfficeId': 1, 'mlsRets': 1}")
|
||||
public class OfficeDocument implements Serializable {
|
||||
@Id
|
||||
private String _id;
|
||||
private Long mlsOfficeId;
|
||||
private Long mlsRets;
|
||||
private String name;
|
||||
private String email;
|
||||
private String url;
|
||||
private String streetName;
|
||||
private String unitName;
|
||||
private String town;
|
||||
private String state;
|
||||
private String zip;
|
||||
private Date dateC;
|
||||
private Date dateM;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/21/19:42
|
||||
* @Description:
|
||||
*/
|
||||
public class PhotoDocument implements Serializable {
|
||||
|
||||
private String photoId;
|
||||
private String photoUrl;
|
||||
private String photoCaption;
|
||||
private String photoS3Key;
|
||||
|
||||
public PhotoDocument() {
|
||||
}
|
||||
|
||||
public PhotoDocument(String photoId, String photoUrl, String photoCaption, String photoS3Key) {
|
||||
this.photoId = photoId;
|
||||
this.photoUrl = photoUrl;
|
||||
this.photoCaption = photoCaption;
|
||||
this.photoS3Key = photoS3Key;
|
||||
}
|
||||
|
||||
public String getPhotoId() {
|
||||
return photoId;
|
||||
}
|
||||
|
||||
public void setPhotoId(String photoId) {
|
||||
this.photoId = photoId;
|
||||
}
|
||||
|
||||
public String getPhotoUrl() {
|
||||
return photoUrl;
|
||||
}
|
||||
|
||||
public void setPhotoUrl(String photoUrl) {
|
||||
this.photoUrl = photoUrl;
|
||||
}
|
||||
|
||||
public String getPhotoCaption() {
|
||||
return photoCaption;
|
||||
}
|
||||
|
||||
public void setPhotoCaption(String photoCaption) {
|
||||
this.photoCaption = photoCaption;
|
||||
}
|
||||
|
||||
public String getPhotoS3Key() {
|
||||
return photoS3Key;
|
||||
}
|
||||
|
||||
public void setPhotoS3Key(String photoS3Key) {
|
||||
this.photoS3Key = photoS3Key;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.PersistenceCreator;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||||
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
|
||||
import org.springframework.data.mongodb.core.index.GeoSpatialIndexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/21/19:13
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Document("residences")
|
||||
@CompoundIndex(name = "residence_uid", def = "{'mlsNumber': 1, 'mlsRets': 1}")
|
||||
public class ResidenceDocument implements Serializable {
|
||||
|
||||
@Id
|
||||
private String _id;
|
||||
private String mlsNumber;
|
||||
private String mlsRets;
|
||||
private String listingType;
|
||||
private String listingStatus;
|
||||
private String geolocationLat;
|
||||
private String geolocationLong;
|
||||
@GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE)
|
||||
private Point location;
|
||||
private Integer priceList;
|
||||
private String description;
|
||||
private ListJson.AddressDTO address;
|
||||
private ListJson.CountyDTO county;
|
||||
private ListJson.AgentDTO agent;
|
||||
private ListJson.OfficeDTO office;
|
||||
private List<PhotoDocument> photos;
|
||||
private Date dateC;
|
||||
private Date dateM;
|
||||
|
||||
@PersistenceCreator
|
||||
public ResidenceDocument(String _id, String mlsNumber, String mlsRets, String listingType, String listingStatus,
|
||||
String geolocationLat, String geolocationLong, Point location, Integer priceList,
|
||||
String description, ListJson.AddressDTO address, ListJson.CountyDTO county,
|
||||
ListJson.AgentDTO agent, ListJson.OfficeDTO office, List<PhotoDocument> photos,
|
||||
Date dateC, Date dateM) {
|
||||
this._id = _id;
|
||||
this.mlsNumber = mlsNumber;
|
||||
this.mlsRets = mlsRets;
|
||||
this.listingType = listingType;
|
||||
this.listingStatus = listingStatus;
|
||||
this.geolocationLat = geolocationLat;
|
||||
this.geolocationLong = geolocationLong;
|
||||
this.location = location;
|
||||
this.priceList = priceList;
|
||||
this.description = description;
|
||||
this.address = address;
|
||||
this.county = county;
|
||||
this.agent = agent;
|
||||
this.office = office;
|
||||
this.photos = photos;
|
||||
this.dateC = dateC;
|
||||
this.dateM = dateM;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.northtecom.visatrack.api.data.mongo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/14/20:12
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Document("resources")
|
||||
public class ResourceDocument implements Serializable {
|
||||
@Id
|
||||
private String _id;
|
||||
private String resourceID;
|
||||
private String standardName;
|
||||
private String visibleName;
|
||||
private String description;
|
||||
private String keyField;
|
||||
|
||||
private List<ClassDocument> classes = new ArrayList<>();
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.northtecom.visatrack.api.data.query;
|
||||
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/24/9:44
|
||||
* @Description:
|
||||
*/
|
||||
public class MlsAgentMongoDbQueryBuilder {
|
||||
public Query query;
|
||||
|
||||
public MlsAgentMongoDbQueryBuilder() {
|
||||
query = new Query();
|
||||
}
|
||||
|
||||
public static MlsAgentMongoDbQueryBuilder newBuilder() {
|
||||
return new MlsAgentMongoDbQueryBuilder();
|
||||
}
|
||||
|
||||
public Query build() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public MlsAgentMongoDbQueryBuilder withMlsAgentId(String mlsAgentId) {
|
||||
if (StringUtils.hasText(mlsAgentId)) {
|
||||
query.addCriteria(Criteria.where("mlsAgentId").is(mlsAgentId));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MlsAgentMongoDbQueryBuilder withMlsRets(String mlsRets) {
|
||||
if (StringUtils.hasText(mlsRets)) {
|
||||
query.addCriteria(Criteria.where("mlsRets").is(mlsRets));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.northtecom.visatrack.api.data.query;
|
||||
|
||||
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/24/9:31
|
||||
* @Description:
|
||||
*/
|
||||
public class MlsListingMongoDbQueryBuilder {
|
||||
|
||||
public Query query;
|
||||
|
||||
public MlsListingMongoDbQueryBuilder() {
|
||||
query = new Query();
|
||||
}
|
||||
|
||||
public static MlsListingMongoDbQueryBuilder newBuilder() {
|
||||
return new MlsListingMongoDbQueryBuilder();
|
||||
}
|
||||
|
||||
public Query build() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public MlsListingMongoDbQueryBuilder withMlsNumber(String mlsNumber) {
|
||||
if (StringUtils.hasText(mlsNumber)) {
|
||||
query.addCriteria(Criteria.where("mlsNumber").is(mlsNumber));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MlsListingMongoDbQueryBuilder withMlsRets(String mlsRets) {
|
||||
if (StringUtils.hasText(mlsRets)) {
|
||||
query.addCriteria(Criteria.where("mlsRets").is(mlsRets));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.northtecom.visatrack.api.data.query;
|
||||
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/24/9:44
|
||||
* @Description:
|
||||
*/
|
||||
public class MlsOfficeMongoDbQueryBuilder {
|
||||
public Query query;
|
||||
|
||||
public MlsOfficeMongoDbQueryBuilder() {
|
||||
query = new Query();
|
||||
}
|
||||
|
||||
public static MlsOfficeMongoDbQueryBuilder newBuilder() {
|
||||
return new MlsOfficeMongoDbQueryBuilder();
|
||||
}
|
||||
|
||||
public Query build() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public MlsOfficeMongoDbQueryBuilder withMlsOfficeId(String mlsOfficeId) {
|
||||
if (StringUtils.hasText(mlsOfficeId)) {
|
||||
query.addCriteria(Criteria.where("mlsOfficeId").is(mlsOfficeId));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MlsOfficeMongoDbQueryBuilder withMlsRets(String mlsRets) {
|
||||
if (StringUtils.hasText(mlsRets)) {
|
||||
query.addCriteria(Criteria.where("mlsRets").is(mlsRets));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.northtecom.visatrack.api.service.mongoservice;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/24/20:32
|
||||
* @Description:
|
||||
*/
|
||||
public enum LikeSearchMode {
|
||||
/**
|
||||
* 前后模糊
|
||||
*/
|
||||
CONTAINS,
|
||||
/**
|
||||
* 前模糊
|
||||
*/
|
||||
START,
|
||||
/**
|
||||
* 后模糊
|
||||
*/
|
||||
END,
|
||||
/**
|
||||
* 精确
|
||||
*/
|
||||
EXACT
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.northtecom.visatrack.api.service.mongoservice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/20/22:57
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MlsAgentService {
|
||||
|
||||
private final MongoTemplate mongoTemplate;
|
||||
|
||||
public MlsAgentService(MongoTemplate mongoTemplate) {
|
||||
this.mongoTemplate = mongoTemplate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.northtecom.visatrack.api.service.mongoservice;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.northtecom.visatrack.api.controller.vo.SearchListVo;
|
||||
import com.northtecom.visatrack.api.data.mongo.ResidenceDocument;
|
||||
import com.northtecom.visatrack.api.data.query.MlsListingMongoDbQueryBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/21/19:46
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MlsListingService {
|
||||
|
||||
private final MongoTemplate mongoTemplate;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final MongoDbQueryService mongoDbQueryService;
|
||||
|
||||
public MlsListingService(
|
||||
MongoTemplate mongoTemplate,
|
||||
ObjectMapper objectMapper, MongoDbQueryService mongoDbQueryService) {
|
||||
|
||||
this.mongoTemplate = mongoTemplate;
|
||||
this.objectMapper = objectMapper;
|
||||
this.mongoDbQueryService = mongoDbQueryService;
|
||||
}
|
||||
|
||||
|
||||
public Page<ResidenceDocument> searchList(SearchListVo searchListVo) {
|
||||
|
||||
Pageable pageable = PageRequest.of(searchListVo.getPageIndex(), searchListVo.getPageSize(),
|
||||
Sort.by(Sort.Direction.DESC, "mlsNumber"));
|
||||
|
||||
List<Criteria> queryList = new ArrayList<>();
|
||||
|
||||
queryList.add(Criteria.where("listingStatus").is("ACTIVE"));
|
||||
|
||||
if (searchListVo.getMaxPrice() != null && searchListVo.getMaxPrice().intValue() > 0) {
|
||||
queryList.add(Criteria.where("priceList").lte(searchListVo.getMaxPrice()));
|
||||
}
|
||||
if (searchListVo.getMinPrice() != null && searchListVo.getMinPrice().intValue() > 0) {
|
||||
queryList.add(Criteria.where("priceList").gte(searchListVo.getMinPrice()));
|
||||
}
|
||||
if (StringUtils.hasText(searchListVo.getSearchAddress())) {
|
||||
queryList.add(Criteria.where("address.addressOneLine").regex(".*" + searchListVo.getSearchAddress().trim() + ".*", "i"));
|
||||
}
|
||||
|
||||
return mongoDbQueryService.queryPagePage(queryList, pageable, ResidenceDocument.class);
|
||||
}
|
||||
|
||||
|
||||
public ResidenceDocument getDetailByMlsNumberAndRetsId(String mlsNumber, String retsId) {
|
||||
MlsListingMongoDbQueryBuilder builder = new MlsListingMongoDbQueryBuilder();
|
||||
builder.withMlsNumber(mlsNumber);
|
||||
builder.withMlsRets(retsId);
|
||||
return mongoTemplate.find(builder.build(), ResidenceDocument.class).stream().findFirst().orElse(null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.northtecom.visatrack.api.service.mongoservice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/20/21:44
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MlsOfficeService {
|
||||
|
||||
|
||||
private final MongoTemplate mongoTemplate;
|
||||
|
||||
|
||||
public MlsOfficeService(MongoTemplate mongoTemplate) {
|
||||
this.mongoTemplate = mongoTemplate;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.northtecom.visatrack.api.service.mongoservice;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/12/25/15:06
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
public class MongoDbQueryService {
|
||||
private final MongoTemplate mongoTemplate;
|
||||
|
||||
public MongoDbQueryService(MongoTemplate mongoTemplate) {
|
||||
this.mongoTemplate = mongoTemplate;
|
||||
}
|
||||
|
||||
public <T> Page<T> queryPagePage(List<Criteria> criteriaList, Pageable pageable, Class<T> entityClass) {
|
||||
Query queryCount = buildCountQuery(criteriaList);
|
||||
Long dataCount = mongoTemplate.count(queryCount, entityClass);
|
||||
|
||||
Query queryPageData = buildPageDataQuery(criteriaList, pageable);
|
||||
List<T> pageData = mongoTemplate.find(queryPageData, entityClass);
|
||||
|
||||
return new PageImpl<T>(pageData, pageable, dataCount);
|
||||
}
|
||||
|
||||
private Query buildPageDataQuery(List<Criteria> criteriaList, Pageable pageable) {
|
||||
Query query = new Query();
|
||||
for (Criteria criteria : criteriaList) {
|
||||
query.addCriteria(criteria);
|
||||
}
|
||||
query.with(pageable);
|
||||
return query;
|
||||
}
|
||||
|
||||
private Query buildCountQuery(List<Criteria> criteriaList) {
|
||||
Query query = new Query();
|
||||
for (Criteria criteria : criteriaList) {
|
||||
query.addCriteria(criteria);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ crawl:
|
|||
proxyPort: 7890
|
||||
|
||||
|
||||
|
||||
server:
|
||||
port: ${app.web.host}
|
||||
|
||||
|
@ -38,6 +39,14 @@ spring:
|
|||
deserialization:
|
||||
fail-on-unknown-properties: false
|
||||
fail-on-ignored-properties: false
|
||||
data:
|
||||
mongodb:
|
||||
database: rets # 操作的库
|
||||
host: 54.39.157.60
|
||||
username: neoadmin
|
||||
password: ppvm29nBi99yK2PddfgY
|
||||
port: 27017
|
||||
authentication-database: admin #认证的库
|
||||
datasource:
|
||||
username: ${app.database.username}
|
||||
password: ${app.database.password}
|
||||
|
|
Loading…
Reference in New Issue