|
@@ -16,9 +16,9 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@RestController
|
|
|
@CrossOrigin
|
|
@@ -276,14 +276,13 @@ public class UserController {
|
|
|
List<GlobalLocationDTO> provinceList;
|
|
|
List<GlobalLocationDTO> cityList;
|
|
|
List<GlobalLocationDTO> areaList;
|
|
|
- List<SectionDTO> sectionList;
|
|
|
+ List<SectionDTO> sectionList = sectionService.getAllSectionList();
|
|
|
|
|
|
if (pid == 0) {
|
|
|
countryList = globalLocationService.getGlobalList(1, version);
|
|
|
provinceList = globalLocationService.getGlobalList(2, version);
|
|
|
cityList = globalLocationService.getGlobalList(3, version);
|
|
|
areaList = globalLocationService.getGlobalList(4, version);
|
|
|
- sectionList = sectionService.getAllSectionList();
|
|
|
for (GlobalLocationDTO g : areaList) {
|
|
|
list2 = new ArrayList<>();
|
|
|
boolean isFlag = false;
|
|
@@ -319,11 +318,24 @@ public class UserController {
|
|
|
g.setAreaList(list1);
|
|
|
list2 = new ArrayList<>();
|
|
|
GlobalLocationDTO dto1 = g.getAreaList().get(0);
|
|
|
- SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(g.getId());
|
|
|
- sectionDTO.setName(g.getName());
|
|
|
- sectionDTO.setPid(g.getPid());
|
|
|
- list2.add(sectionDTO);
|
|
|
+ boolean isRight = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(s.getId());
|
|
|
+ sectionDTO.setName(s.getName());
|
|
|
+ sectionDTO.setPid(s.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ isRight = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isRight) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ }
|
|
|
dto1.setSectionList(list2);
|
|
|
}
|
|
|
}
|
|
@@ -346,12 +358,25 @@ public class UserController {
|
|
|
list1.add(new GlobalLocationDTO(g.getId(),g.getPid(),g.getName()));
|
|
|
dto1.setAreaList(list1);
|
|
|
GlobalLocationDTO dto2 = g.getCityList().get(0).getAreaList().get(0);
|
|
|
- SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(g.getId());
|
|
|
- sectionDTO.setName(g.getName());
|
|
|
- sectionDTO.setPid(g.getPid());
|
|
|
list2 = new ArrayList<>();
|
|
|
- list2.add(sectionDTO);
|
|
|
+ boolean isRight = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(s.getId());
|
|
|
+ sectionDTO.setName(s.getName());
|
|
|
+ sectionDTO.setPid(s.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ isRight = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isRight) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ }
|
|
|
dto2.setSectionList(list2);
|
|
|
}
|
|
|
}
|
|
@@ -379,12 +404,25 @@ public class UserController {
|
|
|
list1.add(new GlobalLocationDTO(dto.getId(),dto.getPid(),dto.getName()));
|
|
|
dto2.setAreaList(list1);
|
|
|
GlobalLocationDTO dto3 = g.getProvinceList().get(0).getCityList().get(0).getAreaList().get(0);
|
|
|
- SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(dto.getId());
|
|
|
- sectionDTO.setName(dto.getName());
|
|
|
- sectionDTO.setPid(dto.getPid());
|
|
|
list2 = new ArrayList<>();
|
|
|
- list2.add(sectionDTO);
|
|
|
+ boolean isRight = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(s.getId());
|
|
|
+ sectionDTO.setName(s.getName());
|
|
|
+ sectionDTO.setPid(s.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ isRight = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isRight) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ }
|
|
|
dto3.setSectionList(list2);
|
|
|
}
|
|
|
}
|
|
@@ -394,7 +432,6 @@ public class UserController {
|
|
|
provinceList = globalLocationService.getLocationListByPid(pid, version);
|
|
|
cityList = globalLocationService.getCityListByPid(pid,version);
|
|
|
areaList = globalLocationService.getAreaListByPid(pid,version);
|
|
|
- sectionList = sectionService.getAllSectionListByPid(pid);
|
|
|
for (GlobalLocationDTO g : areaList) {
|
|
|
list2 = new ArrayList<>();
|
|
|
boolean isFlag = false;
|
|
@@ -430,11 +467,24 @@ public class UserController {
|
|
|
g.setAreaList(list1);
|
|
|
list2 = new ArrayList<>();
|
|
|
GlobalLocationDTO dto1 = g.getAreaList().get(0);
|
|
|
- SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(g.getId());
|
|
|
- sectionDTO.setName(g.getName());
|
|
|
- sectionDTO.setPid(g.getPid());
|
|
|
- list2.add(sectionDTO);
|
|
|
+ boolean isRight = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(s.getId());
|
|
|
+ sectionDTO.setName(s.getName());
|
|
|
+ sectionDTO.setPid(s.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ isRight = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isRight) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ }
|
|
|
dto1.setSectionList(list2);
|
|
|
}
|
|
|
}
|
|
@@ -457,12 +507,25 @@ public class UserController {
|
|
|
list1.add(new GlobalLocationDTO(g.getId(),g.getPid(),g.getName()));
|
|
|
dto1.setAreaList(list1);
|
|
|
GlobalLocationDTO dto2 = g.getCityList().get(0).getAreaList().get(0);
|
|
|
- SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(g.getId());
|
|
|
- sectionDTO.setName(g.getName());
|
|
|
- sectionDTO.setPid(g.getPid());
|
|
|
list2 = new ArrayList<>();
|
|
|
- list2.add(sectionDTO);
|
|
|
+ boolean isRight = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(s.getId());
|
|
|
+ sectionDTO.setName(s.getName());
|
|
|
+ sectionDTO.setPid(s.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ isRight = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isRight) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ }
|
|
|
dto2.setSectionList(list2);
|
|
|
}
|
|
|
}
|
|
@@ -480,12 +543,25 @@ public class UserController {
|
|
|
list1.add(new GlobalLocationDTO(dto.getId(),dto.getPid(),dto.getName()));
|
|
|
dto2.setAreaList(list1);
|
|
|
GlobalLocationDTO dto3 = dto.getProvinceList().get(0).getCityList().get(0).getAreaList().get(0);
|
|
|
- SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(dto.getId());
|
|
|
- sectionDTO.setName(dto.getName());
|
|
|
- sectionDTO.setPid(dto.getPid());
|
|
|
list2 = new ArrayList<>();
|
|
|
- list2.add(sectionDTO);
|
|
|
+ boolean isRight = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(dto.getId(),s.getPid())) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(s.getId());
|
|
|
+ sectionDTO.setName(s.getName());
|
|
|
+ sectionDTO.setPid(s.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ isRight = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isRight) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(dto.getId());
|
|
|
+ sectionDTO.setName(dto.getName());
|
|
|
+ sectionDTO.setPid(dto.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ }
|
|
|
dto3.setSectionList(list2);
|
|
|
}
|
|
|
countryList = new ArrayList<>();
|
|
@@ -927,4 +1003,162 @@ public class UserController {
|
|
|
privilegeVO.setList(list);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,privilegeVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取区域权限列表
|
|
|
+ * @param request username
|
|
|
+ * @return 区域权限列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/sectionList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> sectionList(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ UserDTO userDTO = userService.getZoneListByUserid(id);
|
|
|
+ if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ GlobalLocationVO globalLocationVO = new GlobalLocationVO();
|
|
|
+ globalLocationVO.setList(new ArrayList<>());
|
|
|
+ if (userDTO.getZoneList() == null || userDTO.getZoneList().isEmpty()) {
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,globalLocationVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> zones = Arrays.asList(userDTO.getZoneList().split(","));
|
|
|
+ List<GlobalLocationDTO> list1;
|
|
|
+ List<SectionDTO> list2;
|
|
|
+ List<GlobalLocationDTO> oneCountryList = globalLocationService.getCountryOfSectionList(version);
|
|
|
+ List<GlobalLocationDTO> provinceList = globalLocationService.getGlobalList(2, version);
|
|
|
+ List<GlobalLocationDTO> cityList = globalLocationService.getGlobalList(3, version);
|
|
|
+ List<GlobalLocationDTO> areaList = globalLocationService.getGlobalList(4, version);
|
|
|
+ List<SectionDTO> sectionList = sectionService.getListByIdList(zones);
|
|
|
+
|
|
|
+ // 将只有一级区域与所有二级区域合并
|
|
|
+ provinceList = Stream.of(provinceList, oneCountryList)
|
|
|
+ .flatMap(Collection::stream)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<GlobalLocationDTO> newAreaList = new ArrayList<>();
|
|
|
+ for (GlobalLocationDTO g : areaList) {
|
|
|
+ list2 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ s.setSelect(1);
|
|
|
+ list2.add(s);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ GlobalLocationDTO dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setSectionList(list2);
|
|
|
+ newAreaList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GlobalLocationDTO> newCityList = new ArrayList<>();
|
|
|
+ for (GlobalLocationDTO g : cityList) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (GlobalLocationDTO g1 : newAreaList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ GlobalLocationDTO dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setAreaList(list1);
|
|
|
+ newCityList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : cityList) {
|
|
|
+ list2 = new ArrayList<>();
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(s.getPid(),g.getId())) {
|
|
|
+ s.setSelect(1);
|
|
|
+ list2.add(s);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ GlobalLocationDTO dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setSectionList(list2);
|
|
|
+ list1.add(dto);
|
|
|
+ dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setAreaList(list1);
|
|
|
+ newCityList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GlobalLocationDTO> newProvinceList = new ArrayList<>();
|
|
|
+ for (GlobalLocationDTO g : provinceList) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (GlobalLocationDTO g1 : newCityList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ GlobalLocationDTO dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setCityList(list1);
|
|
|
+ newProvinceList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : provinceList) {
|
|
|
+ list2 = new ArrayList<>();
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(s.getPid(),g.getId())) {
|
|
|
+ s.setSelect(1);
|
|
|
+ list2.add(s);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isFlag) {
|
|
|
+ GlobalLocationDTO dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setSectionList(list2);
|
|
|
+ list1.add(dto);
|
|
|
+ dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setAreaList(list1);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ list1.add(dto);
|
|
|
+ dto = new GlobalLocationDTO();
|
|
|
+ dto.setId(g.getId());
|
|
|
+ dto.setPid(g.getPid());
|
|
|
+ dto.setName(g.getName());
|
|
|
+ dto.setCityList(list1);
|
|
|
+ newProvinceList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ globalLocationVO.setList(newProvinceList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,globalLocationVO);
|
|
|
+ }
|
|
|
}
|