1.表格数据添加携程数据
This commit is contained in:
parent
c818afc501
commit
38f58a50fa
|
@ -0,0 +1,35 @@
|
|||
package com.chint.domain.aggregates.location.basedata;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.AirportPOIInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.POIData;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Table("airport_poi_info")
|
||||
public class AirportPOIInfoEntity {
|
||||
@Id
|
||||
private Long id;
|
||||
private String airportCode;
|
||||
private String airportName;
|
||||
private String airportEnName;
|
||||
|
||||
public static AirportPOIInfoEntity of(AirportPOIInfo airportPOIInfo) {
|
||||
AirportPOIInfoEntity airportPOIInfoEntity = BeanUtil
|
||||
.copyProperties(airportPOIInfo, AirportPOIInfoEntity.class);
|
||||
return airportPOIInfoEntity;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.chint.domain.aggregates.location.basedata;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.POIData;
|
||||
import lombok.Data;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Table("country_info")
|
||||
public class CountryInfoEntity {
|
||||
@Id
|
||||
private Long id;
|
||||
private Long countryId;
|
||||
private String name;
|
||||
private String enName;
|
||||
private String code;
|
||||
private long continentId;
|
||||
private String continentName;
|
||||
private String areaCode;
|
||||
|
||||
@MappedCollection(idColumn = "country_id", keyColumn = "country_key")
|
||||
private List<POIDataInfoEntity> poiDataInfoEntities;
|
||||
|
||||
public static CountryInfoEntity of(CountryResponse.CountryBaseInfo baseInfo) {
|
||||
CountryInfoEntity countryInfoEntity = BeanUtil
|
||||
.copyProperties(baseInfo, CountryInfoEntity.class);
|
||||
return countryInfoEntity;
|
||||
}
|
||||
|
||||
public CountryInfoEntity addPoiDataInfoEntity(POIDataInfoEntity poiDataInfoEntity) {
|
||||
if (this.poiDataInfoEntities == null) {
|
||||
this.poiDataInfoEntities = new ArrayList<>();
|
||||
}
|
||||
this.poiDataInfoEntities.add(poiDataInfoEntity);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.chint.domain.aggregates.location.basedata;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.AirportPOIInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.CountyLevelCityPOI;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Table("country_level_info")
|
||||
public class CountryLevelInfoEntity {
|
||||
@Id
|
||||
private Long id;
|
||||
private Long countyId;
|
||||
private String countyName;
|
||||
private String countyEnName;
|
||||
private Short corpTag;
|
||||
|
||||
public static CountryLevelInfoEntity of(CountyLevelCityPOI countyLevelCityPOI) {
|
||||
CountryLevelInfoEntity airportPOIInfoEntity = BeanUtil
|
||||
.copyProperties(countyLevelCityPOI, CountryLevelInfoEntity.class);
|
||||
return airportPOIInfoEntity;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.chint.domain.aggregates.location.basedata;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.POIData;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.PrefectureLevelCityInfo;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Table("province_info")
|
||||
public class POIDataInfoEntity {
|
||||
@Id
|
||||
private Long id;
|
||||
private Long provinceId;
|
||||
private String provinceName;
|
||||
private String provinceEnName;
|
||||
|
||||
// private List<PrefectureLevelCityInfo> prefectureLevelCityInfoList;
|
||||
@MappedCollection(idColumn = "poidata_id", keyColumn = "poidata_key")
|
||||
private List<PrefectureLevelCityInfoEntity> prefectureLevelCityInfoEntities;
|
||||
public static POIDataInfoEntity of(POIData poiData) {
|
||||
POIDataInfoEntity poiDataInfoEntity = BeanUtil
|
||||
.copyProperties(poiData, POIDataInfoEntity.class);
|
||||
return poiDataInfoEntity;
|
||||
}
|
||||
|
||||
public POIDataInfoEntity addPrefectureLevelCityInfoEntity(PrefectureLevelCityInfoEntity prefectureLevelCityInfoEntity) {
|
||||
if (this.prefectureLevelCityInfoEntities == null) {
|
||||
this.prefectureLevelCityInfoEntities = new ArrayList<>();
|
||||
}
|
||||
this.prefectureLevelCityInfoEntities.add(prefectureLevelCityInfoEntity);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.chint.domain.aggregates.location.basedata;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.*;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Table("prefecture_level_city_info")
|
||||
public class PrefectureLevelCityInfoEntity {
|
||||
@Id
|
||||
private Long id;
|
||||
private Long cityId;
|
||||
private String cityName;
|
||||
private String cityEnName;
|
||||
private Short corpFlag;
|
||||
// private StationInfo stationInfo;
|
||||
// private List<CountyLevelCityPOI> countyList;
|
||||
// private List<DistrictPOIInfo> districtList;
|
||||
private String districtCode;//行政区划代码
|
||||
|
||||
|
||||
@MappedCollection(idColumn = "pre_level_city_id", keyColumn = "pre_level_city_key")
|
||||
private List<AirportPOIInfoEntity> airportPOIInfoEntities;
|
||||
|
||||
|
||||
@MappedCollection(idColumn = "pre_level_city_id", keyColumn = "pre_level_city_key")
|
||||
private List<CountryLevelInfoEntity> countryLevelInfoEntities;
|
||||
|
||||
public static PrefectureLevelCityInfoEntity of(PrefectureLevelCityInfo prefectureLevelCityInfo) {
|
||||
PrefectureLevelCityInfoEntity poiDataInfoEntity = BeanUtil
|
||||
.copyProperties(prefectureLevelCityInfo, PrefectureLevelCityInfoEntity.class);
|
||||
return poiDataInfoEntity;
|
||||
}
|
||||
|
||||
public PrefectureLevelCityInfoEntity addAirportPOIInfoEntity(AirportPOIInfoEntity airportPOIInfoEntity) {
|
||||
if (this.airportPOIInfoEntities == null) {
|
||||
this.airportPOIInfoEntities = new ArrayList<>();
|
||||
}
|
||||
this.airportPOIInfoEntities.add(airportPOIInfoEntity);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PrefectureLevelCityInfoEntity addCountryLevelInfoEntity(CountryLevelInfoEntity countryLevelInfoEntity) {
|
||||
if (this.countryLevelInfoEntities == null) {
|
||||
this.countryLevelInfoEntities = new ArrayList<>();
|
||||
}
|
||||
this.countryLevelInfoEntities.add(countryLevelInfoEntity);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -6,8 +6,11 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
@ -26,4 +29,8 @@ public class Location {
|
|||
@Column("level")
|
||||
private Integer level;
|
||||
|
||||
|
||||
// public Location addFlightAirport(FlightAirport flightAirport){
|
||||
//
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
public interface CountryInfoEntityRepository {
|
||||
CountryInfoEntity save(CountryInfoEntity countryInfoEntity);
|
||||
|
||||
List<CountryInfoEntity> queryByCountryIdNotIn(List<Long> ids);
|
||||
List<CountryInfoEntity> findAll();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
|
||||
import com.chint.domain.aggregates.location.basedata.POIDataInfoEntity;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
public interface POIDataInfoEntityRepository {
|
||||
POIDataInfoEntity save(POIDataInfoEntity countryInfoEntity);
|
||||
}
|
|
@ -3,6 +3,11 @@ package com.chint.infrastructure.constant;
|
|||
public class CTripConstant {
|
||||
// 携程
|
||||
public static final String TICKET_PATH = "/SwitchAPI/Order/Ticket";
|
||||
|
||||
public static final String C_TRIP_COUNTRY_PATH = "/switchAPI/basedata/v2/getcountry";
|
||||
|
||||
public static final String C_TRIP_AllPOIInfo_PATH = "/switchapi/basedata/v2/queryAllPOIInfo";
|
||||
|
||||
public static final String C_TRIP_LOGIN_PATH = "/singlesignon/openapi/saml/login";
|
||||
public static final String C_TRIP_ENTITY_ID = "/zhengtai";
|
||||
public static final String C_TRIP_APP_ID = "zhengtai2024";
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
|
||||
import com.chint.domain.repository.CountryInfoEntityRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcCountryInfoEntityRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
@Repository
|
||||
public class CountryInfoEntityRepositoryImpl implements CountryInfoEntityRepository {
|
||||
|
||||
@Autowired
|
||||
private JdbcCountryInfoEntityRepository jdbcCountryInfoEntityRepository;
|
||||
|
||||
@Override
|
||||
public CountryInfoEntity save(CountryInfoEntity countryInfoEntity) {
|
||||
return jdbcCountryInfoEntityRepository.save(countryInfoEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CountryInfoEntity> queryByCountryIdNotIn(List<Long> ids) {
|
||||
|
||||
return jdbcCountryInfoEntityRepository.findByCountryIdNotIn(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CountryInfoEntity> findAll() {
|
||||
List<CountryInfoEntity> res = new ArrayList<>();
|
||||
jdbcCountryInfoEntityRepository.findAll().iterator().forEachRemaining(
|
||||
res::add);
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -99,9 +99,4 @@ public class LocationRepositoryImpl implements LocationRepository {
|
|||
}
|
||||
|
||||
|
||||
// public List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames) {
|
||||
// List<Location> hotCities =
|
||||
// jdbcLocationRepository.findByLocationPathNameAndLevel(locationNames,3);
|
||||
// return hotCities;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
|
||||
import com.chint.domain.aggregates.location.basedata.POIDataInfoEntity;
|
||||
import com.chint.domain.repository.CountryInfoEntityRepository;
|
||||
import com.chint.domain.repository.POIDataInfoEntityRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcCountryInfoEntityRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcPOIDataInfoEntityRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
@Repository
|
||||
public class POIDataInfoEntityRepositoryImpl implements POIDataInfoEntityRepository {
|
||||
|
||||
@Autowired
|
||||
private JdbcPOIDataInfoEntityRepository jdbcPOIDataInfoEntityRepository;
|
||||
@Override
|
||||
public POIDataInfoEntity save(POIDataInfoEntity poiDataInfoEntity) {
|
||||
return jdbcPOIDataInfoEntityRepository.save(poiDataInfoEntity);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.location.CountryEntity;
|
||||
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Repository
|
||||
public interface JdbcCountryInfoEntityRepository extends CrudRepository<CountryInfoEntity,Long> {
|
||||
|
||||
List<CountryInfoEntity> findByCountryIdNotIn(Collection<Long> countryId);
|
||||
}
|
|
@ -36,4 +36,5 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
|||
|
||||
List<Location> findByLocationPathNameInAndLevel(Collection<String> locationPathName,Integer level);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
|
||||
import com.chint.domain.aggregates.location.basedata.POIDataInfoEntity;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Repository
|
||||
public interface JdbcPOIDataInfoEntityRepository extends CrudRepository<POIDataInfoEntity,Long> {
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.chint.interfaces.rest.ctrip;
|
||||
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.Authentification;
|
||||
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryParam;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.request.QueryAllPOIInfoRequestType;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.QueryAllPOIInfoResponseType;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.chint.infrastructure.constant.CTripConstant.C_TRIP_AllPOIInfo_PATH;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CTripAllPOIInfoRequest {
|
||||
|
||||
|
||||
@Value("${cTrip.baseUrl}")
|
||||
public String C_TRIP_BASE_URL;
|
||||
|
||||
@Value("${cTrip.appKey}")
|
||||
private String C_TRIP_APP_KEY;
|
||||
|
||||
@Autowired
|
||||
private PostRequest postRequest;
|
||||
|
||||
@Autowired
|
||||
private CTripTicketRequest ticketRequest;
|
||||
private String allPOIInfoUrl;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
this.allPOIInfoUrl = C_TRIP_BASE_URL + C_TRIP_AllPOIInfo_PATH;
|
||||
}
|
||||
|
||||
|
||||
public QueryAllPOIInfoResponseType getAllPOIInfoQuery(Long countryId) {
|
||||
|
||||
Authentification authentification = new Authentification(C_TRIP_APP_KEY, ticketRequest.loadTicket());
|
||||
|
||||
QueryAllPOIInfoRequestType request = QueryAllPOIInfoRequestType.builder()
|
||||
.setAuth(authentification)
|
||||
.setCountryId(countryId)
|
||||
.provinceConditions()
|
||||
.setProvinceIds("")
|
||||
.setProvinceNames("")
|
||||
.prefectureLevelCityConditions()
|
||||
.setPrefectureLevelCityIds("")
|
||||
.setPrefectureLevelCityNames("")
|
||||
.setReturnDistrict(true)
|
||||
.setReturnCounty(true)
|
||||
.done() // returns to ProvinceCondition.Builder
|
||||
.done() // returns to QueryAllPOIInfoRequestType.Builder
|
||||
.poiConditions()
|
||||
.setReturnAirport(true)
|
||||
.setReturnTrainStation(true)
|
||||
.setReturnBusStation(false)
|
||||
.done() // returns to QueryAllPOIInfoRequestType.Builder
|
||||
.build();
|
||||
|
||||
QueryAllPOIInfoResponseType allPOIInfoResponseType = postRequest.post(allPOIInfoUrl, request,
|
||||
QueryAllPOIInfoResponseType.class);
|
||||
|
||||
return allPOIInfoResponseType;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.chint.interfaces.rest.ctrip;
|
||||
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.Authentification;
|
||||
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryAuthParam;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryParam;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.ticket.TicketParam;
|
||||
import com.google.gson.Gson;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.chint.infrastructure.constant.CTripConstant.C_TRIP_FLIGHT_CITY_PATH;
|
||||
import static com.chint.infrastructure.constant.CTripConstant.C_TRIP_COUNTRY_PATH;
|
||||
|
||||
import static com.chint.infrastructure.constant.CTripConstant.LANGUAGE_CN;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CTripCountryRequest {
|
||||
|
||||
|
||||
@Value("${cTrip.baseUrl}")
|
||||
public String C_TRIP_BASE_URL;
|
||||
|
||||
@Value("${cTrip.appKey}")
|
||||
private String C_TRIP_APP_KEY;
|
||||
|
||||
@Autowired
|
||||
private PostRequest postRequest;
|
||||
|
||||
@Autowired
|
||||
private CTripTicketRequest ticketRequest;
|
||||
private String countryUrl;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
this.countryUrl = C_TRIP_BASE_URL + C_TRIP_COUNTRY_PATH;
|
||||
}
|
||||
|
||||
|
||||
// public FlightCitySearchResponse getFlightCity(String Keyword, Integer AreaType) {
|
||||
// Gson gson = new Gson();
|
||||
// Authentification auth = new Authentification(C_TRIP_APP_KEY, ticketRequest.loadTicket());
|
||||
// FlightCitySearchRequest flightCitySearchRequest = new FlightCitySearchRequest();
|
||||
// flightCitySearchRequest.setAuth(auth);
|
||||
// flightCitySearchRequest.setKeyword(Keyword);
|
||||
// flightCitySearchRequest.setAreaType(AreaType);
|
||||
// flightCitySearchRequest.setLanguage(LANGUAGE_CN);
|
||||
// FlightCitySearchResponse flightCitySearchResponse = postRequest.post(flightCityUrl, flightCitySearchRequest, FlightCitySearchResponse.class);
|
||||
// log.info(gson.toJson(flightCitySearchResponse.getData().get(0)));
|
||||
// return flightCitySearchResponse;
|
||||
// }
|
||||
|
||||
public CountryResponse getCountry() {
|
||||
Authentification authentification = new Authentification(C_TRIP_APP_KEY, ticketRequest.loadTicket());
|
||||
String locale = UUID.fastUUID().toString();
|
||||
String requestId = "zh-CN";
|
||||
|
||||
CountryParam countryParam = CountryParam
|
||||
.of(requestId, locale)
|
||||
.auth(Authentification.of(C_TRIP_APP_KEY, ticketRequest.loadTicket()));
|
||||
|
||||
// countryParam.setAppKey(C_TRIP_APP_KEY);
|
||||
// countryParam.setTicket(ticketRequest.loadTicket());
|
||||
// CountryAuthParam countryAuthParam = new CountryAuthParam();
|
||||
// countryAuthParam.setAppKey(C_TRIP_APP_KEY);
|
||||
// countryAuthParam.setTicket(ticketRequest.loadTicket());
|
||||
// countryParam.setAuth(countryAuthParam);
|
||||
|
||||
CountryResponse countryResponse = postRequest.post(countryUrl, countryParam,
|
||||
CountryResponse.class);
|
||||
return countryResponse;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,8 +2,10 @@ package com.chint.interfaces.rest.ctrip.dto;
|
|||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class Authentification {
|
||||
private String AppKey;
|
||||
private String Ticket;
|
||||
|
@ -13,5 +15,13 @@ public class Authentification {
|
|||
Ticket = ticket;
|
||||
}
|
||||
|
||||
public static Authentification of(String appKey, String ticket) {
|
||||
Authentification authentification = new Authentification();
|
||||
authentification.AppKey = appKey;
|
||||
authentification.Ticket = ticket;
|
||||
return authentification;
|
||||
}
|
||||
|
||||
|
||||
// Constructors, getters, and setters
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.country;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wanglf3
|
||||
* @date 2024-03-02
|
||||
* @vsrsion 1.0
|
||||
**/
|
||||
|
||||
@Data
|
||||
public class CountryAuthParam {
|
||||
private String accessToken;
|
||||
private String appKey;
|
||||
private String expireTime;
|
||||
private String ticket;
|
||||
private String token;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.country;
|
||||
|
||||
import com.chint.interfaces.rest.ctrip.CTripTicketRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.Authentification;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@Data
|
||||
public class CountryParam {
|
||||
// private String AppKey;
|
||||
// private String Ticket;
|
||||
// private CountryAuthParam auth;
|
||||
|
||||
private String requestId;
|
||||
private String locale;
|
||||
// private Authentification authentification;
|
||||
private Authentification auth;
|
||||
|
||||
|
||||
public static CountryParam of(String requestId, String locale) {
|
||||
CountryParam countryParam = new CountryParam();
|
||||
countryParam.requestId = requestId;
|
||||
countryParam.locale = locale;
|
||||
return countryParam;
|
||||
}
|
||||
|
||||
public CountryParam auth(Authentification authentification) {
|
||||
this.auth = authentification;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Getters and setters (or you can make the fields public)
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.country;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CountryResponse {
|
||||
private int responseCode;
|
||||
private String responseDesc;
|
||||
|
||||
private List<CountryBaseInfo> countryList;
|
||||
|
||||
// Getters and setters
|
||||
@Data
|
||||
public static class CountryBaseInfo {
|
||||
private Long countryId;
|
||||
private String name;
|
||||
private String enName;
|
||||
private String code;
|
||||
private long continentId;
|
||||
private String continentName;
|
||||
private String areaCode;
|
||||
|
||||
|
||||
// Getters and setters
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.location.full.request;
|
||||
|
||||
|
||||
import com.chint.interfaces.rest.ctrip.dto.Authentification;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class QueryAllPOIInfoRequestType {
|
||||
private String auth;
|
||||
private Authentification auth;
|
||||
private Long countryId;
|
||||
private ProvinceCondition provinceConditions;
|
||||
private POICondition poiConditions;
|
||||
|
@ -36,7 +37,7 @@ public class QueryAllPOIInfoRequestType {
|
|||
}
|
||||
|
||||
public static class Builder {
|
||||
private String auth;
|
||||
private Authentification auth;
|
||||
private Long countryId;
|
||||
private ProvinceCondition.Builder provinceConditionsBuilder;
|
||||
private POICondition.Builder poiConditionsBuilder;
|
||||
|
@ -46,7 +47,7 @@ public class QueryAllPOIInfoRequestType {
|
|||
this.poiConditionsBuilder = new POICondition.Builder(this);
|
||||
}
|
||||
|
||||
public Builder setAuth(String auth) {
|
||||
public Builder setAuth(Authentification auth) {
|
||||
this.auth = auth;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public class CountyLevelCityPOI {
|
|||
private Long countyId;
|
||||
private String countyName;
|
||||
private String countyEnName;
|
||||
private Short corpFlag;
|
||||
private Short corpTag;
|
||||
private StationInfo stationInfo;
|
||||
|
||||
// Constructors, getters, and setters
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package com.chint;
|
||||
|
||||
import com.chint.domain.aggregates.location.basedata.*;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.CityRepository;
|
||||
import com.chint.domain.repository.CountryInfoEntityRepository;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.repository.POIDataInfoEntityRepository;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.interfaces.rest.ctrip.*;
|
||||
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.country.CountryResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.BookingRelatedApiRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.FlightProductInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.RouteInfo;
|
||||
|
@ -14,6 +19,7 @@ import com.chint.interfaces.rest.ctrip.dto.estimate.request.TrainProductInfo;
|
|||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.CTripCity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.CTripCountry;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.full.response.*;
|
||||
import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam;
|
||||
import com.chint.interfaces.rest.ctrip.dto.login.PCResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
|
@ -58,6 +64,20 @@ public class CTripTest {
|
|||
@Autowired
|
||||
private CTripFlightCitySearchRequest cTripFlightCitySearchRequest;
|
||||
|
||||
@Autowired
|
||||
private CTripCountryRequest cTripCountryRequest;
|
||||
|
||||
@Autowired
|
||||
private CTripAllPOIInfoRequest cTripAllPOIInfoRequest;
|
||||
|
||||
@Autowired
|
||||
private CountryInfoEntityRepository countryInfoEntityRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
private POIDataInfoEntityRepository poiDataInfoEntityRepository;
|
||||
|
||||
|
||||
private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365");
|
||||
|
||||
//@Test
|
||||
|
@ -118,7 +138,7 @@ public class CTripTest {
|
|||
System.out.println(loginRequest.h5Login(null));
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
void estimateFlight() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
user.setCompanyCode("A30000001");
|
||||
|
@ -151,15 +171,15 @@ public class CTripTest {
|
|||
System.out.println(gson.toJson(estimate));
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
void search() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("30469349853");
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
// @Test
|
||||
void searchAndHandlerData(){
|
||||
// @Test
|
||||
void searchAndHandlerData() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
SupplierCallbackData supplierCallbackData =
|
||||
SupplierCallbackData.of(SUPPLIER_C_TRIP);
|
||||
|
@ -168,15 +188,100 @@ public class CTripTest {
|
|||
supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
}
|
||||
|
||||
// @Test
|
||||
void backData(){
|
||||
// @Test
|
||||
void backData() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
cTripNoteController.handlerData("30607415392","Paid","HotelContract");
|
||||
cTripNoteController.handlerData("30607415392", "Paid", "HotelContract");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryFlightCity(){
|
||||
FlightCitySearchResponse flightCity = cTripFlightCitySearchRequest.getFlightCity("杭州", 2);
|
||||
void queryFlightCity() {
|
||||
FlightCitySearchResponse flightCity = cTripFlightCitySearchRequest.getFlightCity("洛杉矶", 1);
|
||||
System.out.println(flightCity);
|
||||
List<FlightCitySearchResponse.DataItem> data = flightCity.getData();
|
||||
// List<FlightCitySearchResponse.DatasItem> Datas = data.get
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryAllCountry() {
|
||||
CountryResponse countryResponse = cTripCountryRequest.getCountry();
|
||||
//获取国家信息
|
||||
List<CountryResponse.CountryBaseInfo> countryList = countryResponse.getCountryList();
|
||||
|
||||
|
||||
if (countryList != null) {
|
||||
for (CountryResponse.CountryBaseInfo baseInfo : countryList) {
|
||||
CountryInfoEntity countryInfoEntity = CountryInfoEntity.of(baseInfo);
|
||||
|
||||
Long countryId = baseInfo.getCountryId();
|
||||
QueryAllPOIInfoResponseType allPOIInfoQuery = cTripAllPOIInfoRequest.getAllPOIInfoQuery(countryId);
|
||||
List<POIData> dataList = allPOIInfoQuery.getDataList();
|
||||
|
||||
if (dataList != null) {
|
||||
for (POIData poiData : dataList) {
|
||||
if (poiData != null) {
|
||||
POIDataInfoEntity poiDataInfoEntity = POIDataInfoEntity.of(poiData);
|
||||
countryInfoEntity.addPoiDataInfoEntity(poiDataInfoEntity);
|
||||
|
||||
List<PrefectureLevelCityInfo> prefectureLevelCityInfoList = poiData.getPrefectureLevelCityInfoList();
|
||||
|
||||
for (PrefectureLevelCityInfo cityInfo : prefectureLevelCityInfoList) {
|
||||
|
||||
if (cityInfo != null) {
|
||||
PrefectureLevelCityInfoEntity prefectureLevelCityInfoEntity = PrefectureLevelCityInfoEntity.of(cityInfo);
|
||||
poiDataInfoEntity.addPrefectureLevelCityInfoEntity(prefectureLevelCityInfoEntity);
|
||||
|
||||
//取出stationInfo 交通信息
|
||||
StationInfo stationInfo = cityInfo.getStationInfo();
|
||||
//取出机场信息
|
||||
if (stationInfo != null) {
|
||||
List<AirportPOIInfo> airportList = stationInfo.getAirportList();
|
||||
|
||||
if (airportList != null) {
|
||||
for (AirportPOIInfo airportPOIInfo : airportList) {
|
||||
|
||||
if (airportPOIInfo != null) {
|
||||
AirportPOIInfoEntity airportPOIInfoEntity = AirportPOIInfoEntity.of(airportPOIInfo);
|
||||
prefectureLevelCityInfoEntity.addAirportPOIInfoEntity(airportPOIInfoEntity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<CountyLevelCityPOI> countyList = cityInfo.getCountyList();
|
||||
if (countyList != null) {
|
||||
for (CountyLevelCityPOI countyLevelCityPOI : countyList) {
|
||||
|
||||
if (countyLevelCityPOI != null) {
|
||||
CountryLevelInfoEntity countryLevelInfoEntity = CountryLevelInfoEntity.of(countyLevelCityPOI);
|
||||
prefectureLevelCityInfoEntity.addCountryLevelInfoEntity(countryLevelInfoEntity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
countryInfoEntityRepository.save(countryInfoEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// void queryAllPOIInfo(){
|
||||
// QueryAllPOIInfoResponseType allPOIInfoQuery = cTripAllPOIInfoRequest.getAllPOIInfoQuery(1L);
|
||||
// System.out.println(allPOIInfoQuery);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue