优化分组管理
parent
6fb820e49c
commit
fed353c645
|
@ -18,6 +18,8 @@ import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,4 +124,18 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Region> getAllChild(String parent) {
|
||||||
|
List<Region> result = new ArrayList<>();
|
||||||
|
for (String key : civilCodeMap.keySet()) {
|
||||||
|
if (parent == null) {
|
||||||
|
if (ObjectUtils.isEmpty(civilCodeMap.get(key).getParentCode().trim())) {
|
||||||
|
result.add(Region.getInstance(key, civilCodeMap.get(key).getName(), civilCodeMap.get(key).getParentCode()));
|
||||||
|
}
|
||||||
|
}else if (civilCodeMap.get(key).getParentCode().equals(parent)) {
|
||||||
|
result.add(Region.getInstance(key, civilCodeMap.get(key).getName(), civilCodeMap.get(key).getParentCode()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.service;
|
||||||
import com.genersoft.iot.vmp.service.bean.Region;
|
import com.genersoft.iot.vmp.service.bean.Region;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface IRegionService {
|
public interface IRegionService {
|
||||||
|
|
||||||
|
@ -24,4 +26,6 @@ public interface IRegionService {
|
||||||
* 更新区域
|
* 更新区域
|
||||||
*/
|
*/
|
||||||
void update(Region region);
|
void update(Region region);
|
||||||
|
|
||||||
|
List<Region> getAllChild(String parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.genersoft.iot.vmp.service.impl;
|
package com.genersoft.iot.vmp.service.impl;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||||
|
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
import com.genersoft.iot.vmp.service.IRegionService;
|
import com.genersoft.iot.vmp.service.IRegionService;
|
||||||
import com.genersoft.iot.vmp.service.bean.Region;
|
import com.genersoft.iot.vmp.service.bean.Region;
|
||||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||||
|
@ -29,6 +32,10 @@ public class RegionServiceImpl implements IRegionService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CommonGbChannelMapper commonGbChannelMapper;
|
private CommonGbChannelMapper commonGbChannelMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CivilCodeFileConf civilCodeFileConf;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(Region region) {
|
public void add(Region region) {
|
||||||
assert region.getCommonRegionName() != null;
|
assert region.getCommonRegionName() != null;
|
||||||
|
@ -86,4 +93,9 @@ public class RegionServiceImpl implements IRegionService {
|
||||||
regionMapper.update(region);
|
regionMapper.update(region);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Region> getAllChild(String parent) {
|
||||||
|
return civilCodeFileConf.getAllChild(parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,4 +120,5 @@ public class CommonChannelController {
|
||||||
return commonGbChannelService.getRandomCode(type);
|
return commonGbChannelService.getRandomCode(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.vmanager.region;
|
package com.genersoft.iot.vmp.vmanager.region;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
|
||||||
import com.genersoft.iot.vmp.service.IRegionService;
|
import com.genersoft.iot.vmp.service.IRegionService;
|
||||||
import com.genersoft.iot.vmp.service.bean.Region;
|
import com.genersoft.iot.vmp.service.bean.Region;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
@ -9,11 +10,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Tag(name = "行政区划管理")
|
@Tag(name = "区域管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/region")
|
@RequestMapping("/api/region")
|
||||||
public class RegionController {
|
public class RegionController {
|
||||||
|
@ -74,4 +76,15 @@ public class RegionController {
|
||||||
){
|
){
|
||||||
return regionService.queryChildGroupList(regionParentId, page, count);
|
return regionService.queryChildGroupList(regionParentId, page, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所属的行政区划下的行政区划")
|
||||||
|
@Parameter(name = "parent", description = "所属的行政区划", required = false)
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/base/child/list")
|
||||||
|
public List<Region> getAllChild(@RequestParam(required = false) String parent){
|
||||||
|
if (ObjectUtils.isEmpty(parent.trim())) {
|
||||||
|
parent = null;
|
||||||
|
}
|
||||||
|
return regionService.getAllChild(parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue