|
@@ -6,6 +6,9 @@ import com.sxtvs.open.api.news.service.IAreaService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -17,4 +20,20 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements IAreaService {
|
|
|
|
|
|
+ public List<Area> areaList(){
|
|
|
+ List<Area> list = lambdaQuery().le(Area::getLevel, 2).list();
|
|
|
+ List<Area> rs = new ArrayList<>();
|
|
|
+ Area curr = new Area();
|
|
|
+ for(Area area : list){
|
|
|
+ if(area.getLevel() == 1){
|
|
|
+ curr = area;
|
|
|
+ rs.add(curr);
|
|
|
+ }else {
|
|
|
+ curr.getDistricts().add(area);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return rs;
|
|
|
+
|
|
|
+ }
|
|
|
}
|