|
|
@@ -1,18 +1,23 @@
|
|
|
package io.renren.modules.qyh.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import io.renren.common.utils.PageUtils;
|
|
|
import io.renren.common.utils.Query;
|
|
|
+import io.renren.common.utils.R;
|
|
|
import io.renren.modules.qyh.entity.ServiceCityEntity;
|
|
|
import io.renren.modules.qyh.mapper.ServiceCityMapper;
|
|
|
import io.renren.modules.qyh.service.ServiceCityService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
@Service("serviceCityService")
|
|
|
@@ -37,4 +42,24 @@ public class ServiceCityServiceImpl extends ServiceImpl<ServiceCityMapper, Servi
|
|
|
public void updateEntityById(ServiceCityEntity serviceCityEntity) {
|
|
|
this.updateById(serviceCityEntity);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R hotCityList(Map<String, Object> params) {
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ List<ServiceCityEntity> list = this.list();
|
|
|
+ //按首字母分组
|
|
|
+ Map<String, List<ServiceCityEntity>> map = list.stream().collect(Collectors.groupingBy(ServiceCityEntity::getLetter));
|
|
|
+ //分组后按首字母排序
|
|
|
+ map.entrySet().stream().sorted(Map.Entry.comparingByKey());
|
|
|
+ for (Map.Entry<String, List<ServiceCityEntity>> entry : map.entrySet()) {
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.put("letter", entry.getKey());
|
|
|
+ map1.put("city", entry.getValue());
|
|
|
+ jsonArray.add(map1);
|
|
|
+ }
|
|
|
+ //查热门 按排序排
|
|
|
+ List<ServiceCityEntity> hot = list.stream().filter(item -> item.getIsHot().equals("1"))
|
|
|
+ .sorted((o1, o2) -> o1.getSort() - o2.getSort()).collect(Collectors.toList());
|
|
|
+ return R.ok().put("hot",hot).put("city",jsonArray);
|
|
|
+ }
|
|
|
}
|