diff --git a/src/main/java/com/chint/application/out/LocationController.java b/src/main/java/com/chint/application/out/LocationController.java index 33a720d5..57937020 100644 --- a/src/main/java/com/chint/application/out/LocationController.java +++ b/src/main/java/com/chint/application/out/LocationController.java @@ -4,18 +4,24 @@ import cn.hutool.core.bean.BeanUtil; import com.chint.application.dtos.LocationParam; import com.chint.application.dtos.response.LocationRes; import com.chint.domain.aggregates.order.Location; +import com.chint.domain.aggregates.standards.CityTag; +import com.chint.domain.aggregates.standards.HotCityTag; import com.chint.domain.repository.LocationRepository; import com.chint.domain.service.LocationDomainService; import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.StringCheck; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.List; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; @@ -55,4 +61,51 @@ public class LocationController { } return Result.Success(SUCCESS, locationRes); } + +// @ApiOperation("获取热门城市") +// @PostMapping("/getHotCities") +// public Result> getHotCities() { +// List city = new ArrayList<>(); +// city.add("上海"); +// city.add("北京"); +// city.add("广州"); +// city.add("深圳"); +// city.add("天津"); +// city.add("重庆"); +// city.add("苏州"); +// city.add("武汉"); +// city.add("成都"); +// city.add("杭州"); +// city.add("温州"); +// HashMap cityMap = HotCityTag.cityMap; +// Collection hotCity = cityMap.values(); +// List list = new ArrayList<>(hotCity); +// return Result.Success(SUCCESS, locationRepository.findHotCitiesByCityName(city)); +// +// +//// return Result.Success(SUCCESS, locationRepository.findHotCitiesByCityName(cityMap.values())); +// +// } + + @ApiOperation("获取热门城市") + @PostMapping("/getHotCities") + public Result> getHotCities() { + + List city = HotCityTag.citys; + + List locations = null; + List locationRes = null; + + locations = locationRepository.findHotCitiesByCityName(city); + if (locations != null && !locations.isEmpty()) { + locationRes = locations + .stream() + .map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList(); + } + return Result.Success(SUCCESS, locationRes); + + +// return Result.Success(SUCCESS, locationRepository.findHotCitiesByCityName(cityMap.values())); + + } } \ 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 new file mode 100644 index 00000000..1995908b --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java @@ -0,0 +1,29 @@ +package com.chint.domain.aggregates.standards; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class HotCityTag { + +// public static final HashMap cityMap; + public static final List citys; + + static { + citys = new ArrayList<>(); + + citys.add("上海"); + citys.add("北京"); + citys.add("广州"); + citys.add("深圳"); + citys.add("天津"); + citys.add("重庆"); + citys.add("苏州"); + citys.add("武汉"); + citys.add("成都"); + citys.add("杭州"); + citys.add("温州"); + + } + +} diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index a45e5d59..3b330a1d 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -23,5 +23,7 @@ public interface LocationRepository { String locationPathByName(String localName); + List findHotCitiesByCityName(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 65418e05..11dfb069 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -81,4 +81,12 @@ public class LocationRepositoryImpl implements LocationRepository { public List findByNameList(List locationIds) { return jdbcLocationRepository.findByLocationIdIn(locationIds); } + + + @Override + public List findHotCitiesByCityName(List locationNames) { + List hotCities = + jdbcLocationRepository.findByLocationNameInAndLocationPathContainingAndLevel(locationNames,"3106_1_",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 7a1a4841..c5d16d68 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -25,7 +25,10 @@ public interface JdbcLocationRepository extends CrudRepository { Location findByLocationName(String locationName); - List findByLocationNameIn(Collection locationName); - List findByLocationIdIn(Collection locationId); + + List findByLocationNameInAndLocationPathContainingAndLevel(Collection locationName, + String locationPath, + Integer level); + } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 4a5bec2e..d7d68120 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -56,7 +56,7 @@ class RouteApplicationTests { } @Test void loginSign() { - String sfno = "230615020"; + String sfno = "220407068"; String syscode = "FSSC"; String billcode = "CLSQ240226000100"; String companycode = "正泰集团股份有限公司";