|
|
|
@ -16,13 +16,17 @@
|
|
|
|
|
*/ |
|
|
|
|
package org.springblade.system.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import javafx.scene.effect.SepiaTone; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.StringPool; |
|
|
|
@ -33,6 +37,7 @@ import org.springblade.system.mapper.RegionMapper;
|
|
|
|
|
import org.springblade.system.service.IRegionService; |
|
|
|
|
import org.springblade.system.vo.RegionAllVO; |
|
|
|
|
import org.springblade.system.vo.RegionVO; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
@ -49,6 +54,9 @@ import static org.springblade.system.cache.RegionCache.*;
|
|
|
|
|
@Service |
|
|
|
|
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private BladeRedis bladeRedis; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean submit(Region region) { |
|
|
|
|
// 设置市级编号格式
|
|
|
|
@ -194,6 +202,54 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String selectAllStr() { |
|
|
|
|
String key = "REGION:ALL:ROW:DATA"; |
|
|
|
|
String str = bladeRedis.get(key); |
|
|
|
|
if(StringUtil.isBlank(str)){ |
|
|
|
|
QueryWrapper<Region> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("parent_code","00"); |
|
|
|
|
List<Region> regions = baseMapper.selectList(queryWrapper); |
|
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
|
for (Region region : regions) { |
|
|
|
|
String code = region.getCode(); |
|
|
|
|
JSONObject provinceObject = new JSONObject(); |
|
|
|
|
provinceObject.put("value",code); |
|
|
|
|
provinceObject.put("label",region.getName()); |
|
|
|
|
queryWrapper.eq("parent_code",code); |
|
|
|
|
List<Region> cityRegions = baseMapper.selectList(queryWrapper); |
|
|
|
|
JSONArray cityArray = new JSONArray(); |
|
|
|
|
for (Region cityRegion : cityRegions) { |
|
|
|
|
String cityCode = cityRegion.getCode(); |
|
|
|
|
JSONObject cityObject = new JSONObject(); |
|
|
|
|
cityObject.put("value",cityCode); |
|
|
|
|
cityObject.put("label",cityRegion.getName()); |
|
|
|
|
queryWrapper.eq("parent_code",cityCode); |
|
|
|
|
List<Region> areaRegions = baseMapper.selectList(queryWrapper); |
|
|
|
|
JSONArray areaArray = new JSONArray(); |
|
|
|
|
for (Region areaRegion : areaRegions){ |
|
|
|
|
String areaCode = areaRegion.getCode(); |
|
|
|
|
String areaName = areaRegion.getName(); |
|
|
|
|
JSONObject areaObject = new JSONObject(); |
|
|
|
|
cityObject.put("value",areaCode); |
|
|
|
|
cityObject.put("label",areaName); |
|
|
|
|
areaArray.add(cityObject); |
|
|
|
|
} |
|
|
|
|
if(areaArray.size() > 0){ |
|
|
|
|
cityObject.put("children",areaArray); |
|
|
|
|
} |
|
|
|
|
cityArray.add(cityObject); |
|
|
|
|
} |
|
|
|
|
if(cityArray.size() > 0){ |
|
|
|
|
provinceObject.put("children",cityArray); |
|
|
|
|
} |
|
|
|
|
jsonArray.add(provinceObject); |
|
|
|
|
} |
|
|
|
|
str = jsonArray.toJSONString(); |
|
|
|
|
} |
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<RegionVO> lazyTree(String parentCode, Map<String, Object> param) { |
|
|
|
|
return baseMapper.lazyTree(parentCode, param); |
|
|
|
|