1.添加获取热门城市接口
This commit is contained in:
parent
627ff7317c
commit
6abb2643a9
|
@ -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<List<Location>> getHotCities() {
|
||||
// List<String> 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<String, String> cityMap = HotCityTag.cityMap;
|
||||
// Collection hotCity = cityMap.values();
|
||||
// List<Integer> list = new ArrayList<>(hotCity);
|
||||
// return Result.Success(SUCCESS, locationRepository.findHotCitiesByCityName(city));
|
||||
//
|
||||
//
|
||||
//// return Result.Success(SUCCESS, locationRepository.findHotCitiesByCityName(cityMap.values()));
|
||||
//
|
||||
// }
|
||||
|
||||
@ApiOperation("获取热门城市")
|
||||
@PostMapping("/getHotCities")
|
||||
public Result<List<LocationRes>> getHotCities() {
|
||||
|
||||
List<String> city = HotCityTag.citys;
|
||||
|
||||
List<Location> locations = null;
|
||||
List<LocationRes> 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()));
|
||||
|
||||
}
|
||||
}
|
|
@ -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<String, String> cityMap;
|
||||
public static final List<String> 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("温州");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -23,5 +23,7 @@ public interface LocationRepository {
|
|||
|
||||
String locationPathByName(String localName);
|
||||
|
||||
List<Location> findHotCitiesByCityName(List<String> locationNames);
|
||||
|
||||
List<Location> findByNameList(List<Long> locationIds);
|
||||
}
|
|
@ -81,4 +81,12 @@ public class LocationRepositoryImpl implements LocationRepository {
|
|||
public List<Location> findByNameList(List<Long> locationIds) {
|
||||
return jdbcLocationRepository.findByLocationIdIn(locationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Location> findHotCitiesByCityName(List<String> locationNames) {
|
||||
List<Location> hotCities =
|
||||
jdbcLocationRepository.findByLocationNameInAndLocationPathContainingAndLevel(locationNames,"3106_1_",3);
|
||||
return hotCities;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,10 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
|||
|
||||
Location findByLocationName(String locationName);
|
||||
|
||||
List<Location> findByLocationNameIn(Collection<String> locationName);
|
||||
|
||||
List<Location> findByLocationIdIn(Collection<Long> locationId);
|
||||
|
||||
List<Location> findByLocationNameInAndLocationPathContainingAndLevel(Collection<String> locationName,
|
||||
String locationPath,
|
||||
Integer level);
|
||||
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class RouteApplicationTests {
|
|||
}
|
||||
@Test
|
||||
void loginSign() {
|
||||
String sfno = "230615020";
|
||||
String sfno = "220407068";
|
||||
String syscode = "FSSC";
|
||||
String billcode = "CLSQ240226000100";
|
||||
String companycode = "正泰集团股份有限公司";
|
||||
|
|
Loading…
Reference in New Issue