From 5f6a7103f7628f4edacfe554b5ad5e37c20438c2 Mon Sep 17 00:00:00 2001 From: wanglf3 Date: Thu, 29 Feb 2024 15:20:13 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=83=AD=E9=97=A8=E5=9F=8E=E5=B8=82=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E7=83=AD=E9=97=A8=E5=9F=8E=E5=B8=82=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/HotCityResponseDto.java | 15 +++++++++++++ .../application/out/LocationController.java | 21 ++++++++++++++++-- .../aggregates/standards/HotCityTag.java | 22 ++++++++++++++++++- .../domain/repository/LocationRepository.java | 4 ++++ .../repository/LocationRepositoryImpl.java | 15 +++++++++++++ .../jdbc/JdbcLocationRepository.java | 8 ++++++- 6 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/chint/application/dtos/HotCityResponseDto.java diff --git a/src/main/java/com/chint/application/dtos/HotCityResponseDto.java b/src/main/java/com/chint/application/dtos/HotCityResponseDto.java new file mode 100644 index 00000000..f6444c29 --- /dev/null +++ b/src/main/java/com/chint/application/dtos/HotCityResponseDto.java @@ -0,0 +1,15 @@ +package com.chint.application.dtos; + +import com.chint.application.dtos.response.LocationRes; +import lombok.Data; + +import java.util.List; + +@Data +public class HotCityResponseDto { + + private List internationalCitys; //热门国际城市 + + private List internalCitys; //热门国内城市 + +} diff --git a/src/main/java/com/chint/application/out/LocationController.java b/src/main/java/com/chint/application/out/LocationController.java index cd960083..c107d949 100644 --- a/src/main/java/com/chint/application/out/LocationController.java +++ b/src/main/java/com/chint/application/out/LocationController.java @@ -1,6 +1,7 @@ package com.chint.application.out; import cn.hutool.core.bean.BeanUtil; +import com.chint.application.dtos.HotCityResponseDto; import com.chint.application.dtos.LocationParam; import com.chint.application.dtos.response.LocationRes; import com.chint.domain.aggregates.order.Location; @@ -64,7 +65,7 @@ public class LocationController { @ApiOperation("获取热门城市") @PostMapping("/getHotCities") - public Result> getHotCities() { + public Result getHotCities() { List city = HotCityTag.citys; @@ -77,7 +78,23 @@ public class LocationController { .stream() .map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList(); } - return Result.Success(SUCCESS, locationRes); + + + List internationalCitys = HotCityTag.internationalCitys; + List internationalLocationRes = null; + + List internationalLocations = locationRepository.findHotIntnationalCitiesByCityName(internationalCitys); + if (internationalLocations != null && !internationalLocations.isEmpty()) { + internationalLocationRes = internationalLocations + .stream() + .map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList(); + } + + HotCityResponseDto dto = new HotCityResponseDto(); + dto.setInternalCitys(locationRes); + dto.setInternationalCitys(internationalLocationRes); + + return Result.Success(SUCCESS, dto); } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java b/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java index 1995908b..c3a297ca 100644 --- a/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java +++ b/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java @@ -6,9 +6,10 @@ import java.util.List; public class HotCityTag { -// public static final HashMap cityMap; public static final List citys; + public static final List internationalCitys; + static { citys = new ArrayList<>(); @@ -24,6 +25,25 @@ public class HotCityTag { citys.add("杭州"); citys.add("温州"); + internationalCitys = new ArrayList<>(); + internationalCitys.add("北美洲_美国_纽约州_纽约_"); + internationalCitys.add("北美洲_美国_内华达州_拉斯维加斯_"); + internationalCitys.add("北美洲_美国_伊利诺伊州_芝加哥_"); + internationalCitys.add("北美洲_美国_华盛顿哥伦比亚特区_华盛顿_"); + internationalCitys.add("欧洲_英国_英格兰_伦敦_"); + internationalCitys.add("欧洲_德国_拜恩(巴伐利亚)_慕尼黑_"); + internationalCitys.add("欧洲_西班牙_加泰罗尼亚_巴塞罗那_"); + internationalCitys.add("欧洲_德国_柏林_柏林_"); + internationalCitys.add("北美洲_美国_纽约州_阿姆斯特丹_"); + internationalCitys.add("欧洲_法国_法兰西岛_巴黎_"); + internationalCitys.add("欧洲_西班牙_马德里_马德里_"); + internationalCitys.add("欧洲_葡萄牙_特茹河谷里斯本_里斯本_"); + internationalCitys.add("欧洲_奥地利_维也纳_维也纳_"); + internationalCitys.add("亚洲_日本_东京都_东京_"); + internationalCitys.add("欧洲_挪威_奥斯陆市_奥斯陆_"); + internationalCitys.add("北美洲_美国_加利福尼亚州_旧金山_"); + internationalCitys.add("亚洲_新加坡_新加坡_新加坡_"); + } } diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index 3b330a1d..25cfa2e9 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -25,5 +25,9 @@ public interface LocationRepository { List findHotCitiesByCityName(List locationNames); + List findHotIntnationalCitiesByCityName(List locationNames); + List findByNameList(List locationIds); + + } \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index ebd2b9ae..9bb51a57 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -87,4 +87,19 @@ public class LocationRepositoryImpl implements LocationRepository { public List findHotCitiesByCityName(List locationNames) { return jdbcLocationRepository.findByLocationNameInAndLocationPathContainingAndLevel(locationNames,"3106_1_",3); } + + + @Override + public List findHotIntnationalCitiesByCityName(List locationNames){ + List hotCities = + jdbcLocationRepository.findByLocationPathNameInAndLevel(locationNames,3); + return hotCities; + } + + +// public List findHotIntnationalCitiesByCityName(List locationNames) { +// List hotCities = +// jdbcLocationRepository.findByLocationPathNameAndLevel(locationNames,3); +// return hotCities; +// } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java index 4a265b1d..f289cd07 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -27,7 +27,13 @@ public interface JdbcLocationRepository extends CrudRepository { List findByLocationNameIn(Collection locationName); - List findByLocationNameInAndLocationPathContainingAndLevel(Collection locationName, String locationPath, Integer level); List findByLocationIdIn(Collection locationId); + + List findByLocationNameInAndLocationPathContainingAndLevel(Collection locationName, + String locationPath, + Integer level); + + List findByLocationPathNameInAndLevel(Collection locationPathName,Integer level); + }