1.热门城市列表信息添加国际热门城市信息。

This commit is contained in:
wanglf3 2024-02-29 15:20:13 +08:00
parent faf24581d9
commit 5f6a7103f7
6 changed files with 81 additions and 4 deletions

View File

@ -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<LocationRes> internationalCitys; //热门国际城市
private List<LocationRes> internalCitys; //热门国内城市
}

View File

@ -1,6 +1,7 @@
package com.chint.application.out; package com.chint.application.out;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.HotCityResponseDto;
import com.chint.application.dtos.LocationParam; import com.chint.application.dtos.LocationParam;
import com.chint.application.dtos.response.LocationRes; import com.chint.application.dtos.response.LocationRes;
import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.Location;
@ -64,7 +65,7 @@ public class LocationController {
@ApiOperation("获取热门城市") @ApiOperation("获取热门城市")
@PostMapping("/getHotCities") @PostMapping("/getHotCities")
public Result<List<LocationRes>> getHotCities() { public Result<HotCityResponseDto> getHotCities() {
List<String> city = HotCityTag.citys; List<String> city = HotCityTag.citys;
@ -77,7 +78,23 @@ public class LocationController {
.stream() .stream()
.map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList(); .map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList();
} }
return Result.Success(SUCCESS, locationRes);
List<String> internationalCitys = HotCityTag.internationalCitys;
List<LocationRes> internationalLocationRes = null;
List<Location> 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);
} }
} }

View File

@ -6,9 +6,10 @@ import java.util.List;
public class HotCityTag { public class HotCityTag {
// public static final HashMap<String, String> cityMap;
public static final List<String> citys; public static final List<String> citys;
public static final List<String> internationalCitys;
static { static {
citys = new ArrayList<>(); citys = new ArrayList<>();
@ -24,6 +25,25 @@ public class HotCityTag {
citys.add("杭州"); citys.add("杭州");
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("亚洲_新加坡_新加坡_新加坡_");
} }
} }

View File

@ -25,5 +25,9 @@ public interface LocationRepository {
List<Location> findHotCitiesByCityName(List<String> locationNames); List<Location> findHotCitiesByCityName(List<String> locationNames);
List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames);
List<Location> findByNameList(List<Long> locationIds); List<Location> findByNameList(List<Long> locationIds);
} }

View File

@ -87,4 +87,19 @@ public class LocationRepositoryImpl implements LocationRepository {
public List<Location> findHotCitiesByCityName(List<String> locationNames) { public List<Location> findHotCitiesByCityName(List<String> locationNames) {
return jdbcLocationRepository.findByLocationNameInAndLocationPathContainingAndLevel(locationNames,"3106_1_",3); return jdbcLocationRepository.findByLocationNameInAndLocationPathContainingAndLevel(locationNames,"3106_1_",3);
} }
@Override
public List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames){
List<Location> hotCities =
jdbcLocationRepository.findByLocationPathNameInAndLevel(locationNames,3);
return hotCities;
}
// public List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames) {
// List<Location> hotCities =
// jdbcLocationRepository.findByLocationPathNameAndLevel(locationNames,3);
// return hotCities;
// }
} }

View File

@ -27,7 +27,13 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLocationNameIn(Collection<String> locationName); List<Location> findByLocationNameIn(Collection<String> locationName);
List<Location> findByLocationNameInAndLocationPathContainingAndLevel(Collection<String> locationName, String locationPath, Integer level);
List<Location> findByLocationIdIn(Collection<Long> locationId); List<Location> findByLocationIdIn(Collection<Long> locationId);
List<Location> findByLocationNameInAndLocationPathContainingAndLevel(Collection<String> locationName,
String locationPath,
Integer level);
List<Location> findByLocationPathNameInAndLevel(Collection<String> locationPathName,Integer level);
} }