|
@@ -39,6 +39,8 @@ public class UserController {
|
|
|
private DicInfoService dicInfoService;
|
|
|
@Autowired
|
|
|
private CompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private PrivilegeNodeService privilegeNodeService;
|
|
|
|
|
|
/**
|
|
|
* 登录demo做测试,后续删除
|
|
@@ -266,20 +268,232 @@ public class UserController {
|
|
|
*/
|
|
|
@RequestMapping(value = "areaList", method = RequestMethod.POST)
|
|
|
public BaseResult<?> areaList(HttpServletRequest request) {
|
|
|
- int version = (int) toolUtils.getRequestContent(request,"version",1);
|
|
|
- int pid = (int) toolUtils.getRequestContent(request,"pid",1);
|
|
|
- List<GlobalLocationDTO> list = new ArrayList<>();
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer pid = (Integer) toolUtils.getRequestContent(request,"pid",1);
|
|
|
+ List<GlobalLocationDTO> list1;
|
|
|
+ List<SectionDTO> list2;
|
|
|
+ List<GlobalLocationDTO> countryList;
|
|
|
+ List<GlobalLocationDTO> provinceList;
|
|
|
+ List<GlobalLocationDTO> cityList;
|
|
|
+ List<GlobalLocationDTO> areaList;
|
|
|
+ List<SectionDTO> sectionList;
|
|
|
+
|
|
|
if (pid == 0) {
|
|
|
- GlobalLocationDTO dto = new GlobalLocationDTO();
|
|
|
- dto.setPid(0);
|
|
|
- dto.setLevel(1);
|
|
|
- dto.setVersion(version);
|
|
|
- List<GlobalLocationDTO> countryList = globalLocationService.getLocationListByDTO(dto);
|
|
|
+ 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;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ list2.add(s);
|
|
|
+ g.setSectionList(list2);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ g.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : cityList) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (GlobalLocationDTO g1 : areaList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ g.setAreaList(list1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ list1.add(new GlobalLocationDTO(g.getId(),g.getPid(),g.getName()));
|
|
|
+ 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);
|
|
|
+ dto1.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : provinceList) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (GlobalLocationDTO g1 : cityList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ g.setCityList(list1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ list1.add(new GlobalLocationDTO(g.getId(),g.getPid(),g.getName()));
|
|
|
+ g.setCityList(list1);
|
|
|
+ GlobalLocationDTO dto1 = g.getCityList().get(0);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ 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);
|
|
|
+ dto2.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : countryList) {
|
|
|
+ boolean isFlag = false;
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ for (GlobalLocationDTO g1 : provinceList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ g.setProvinceList(list1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ GlobalLocationDTO dto = new GlobalLocationDTO(g.getId(), g.getPid(), g.getName());
|
|
|
+ list1.add(dto);
|
|
|
+ g.setProvinceList(list1);
|
|
|
+ GlobalLocationDTO dto1 = g.getProvinceList().get(0);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ list1.add(new GlobalLocationDTO(dto.getId(),dto.getPid(),dto.getName()));
|
|
|
+ dto1.setCityList(list1);
|
|
|
+ GlobalLocationDTO dto2 = g.getProvinceList().get(0).getCityList().get(0);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ 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);
|
|
|
+ dto3.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
- GlobalLocationDTO locationDTO = globalLocationService.getAreaById(pid, version);
|
|
|
+ GlobalLocationDTO dto = globalLocationService.getGlobalLocationDTOById(pid, version);
|
|
|
+ if (dto == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ 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;
|
|
|
+ for (SectionDTO s : sectionList) {
|
|
|
+ if (Objects.equals(g.getId(),s.getPid())) {
|
|
|
+ list2.add(s);
|
|
|
+ g.setSectionList(list2);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(g.getId());
|
|
|
+ sectionDTO.setName(g.getName());
|
|
|
+ sectionDTO.setPid(g.getPid());
|
|
|
+ list2.add(sectionDTO);
|
|
|
+ g.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : cityList) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (GlobalLocationDTO g1 : areaList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ g.setAreaList(list1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ list1.add(new GlobalLocationDTO(g.getId(),g.getPid(),g.getName()));
|
|
|
+ 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);
|
|
|
+ dto1.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (GlobalLocationDTO g : provinceList) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (GlobalLocationDTO g1 : cityList) {
|
|
|
+ if (Objects.equals(g.getId(),g1.getPid())) {
|
|
|
+ list1.add(g1);
|
|
|
+ g.setCityList(list1);
|
|
|
+ isFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ list1.add(new GlobalLocationDTO(g.getId(),g.getPid(),g.getName()));
|
|
|
+ g.setCityList(list1);
|
|
|
+ GlobalLocationDTO dto1 = g.getCityList().get(0);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ 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);
|
|
|
+ dto2.setSectionList(list2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setProvinceList(provinceList);
|
|
|
+ if (dto.getProvinceList().isEmpty() || dto.getProvinceList() == null) {
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ list1.add(new GlobalLocationDTO(dto.getId(),dto.getPid(),dto.getName()));
|
|
|
+ dto.setProvinceList(list1);
|
|
|
+ GlobalLocationDTO dto1 = dto.getProvinceList().get(0);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ list1.add(new GlobalLocationDTO(dto.getId(),dto.getPid(),dto.getName()));
|
|
|
+ dto1.setCityList(list1);
|
|
|
+ GlobalLocationDTO dto2 = dto.getProvinceList().get(0).getCityList().get(0);
|
|
|
+ list1 = new ArrayList<>();
|
|
|
+ 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);
|
|
|
+ dto3.setSectionList(list2);
|
|
|
+ }
|
|
|
+ countryList = new ArrayList<>();
|
|
|
+ countryList.add(dto);
|
|
|
}
|
|
|
+
|
|
|
GlobalLocationVO globalLocationVO = new GlobalLocationVO();
|
|
|
- globalLocationVO.setList(list);
|
|
|
+ globalLocationVO.setList(countryList);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,globalLocationVO);
|
|
|
}
|
|
|
|
|
@@ -642,4 +856,75 @@ public class UserController {
|
|
|
companyVO.setId(id);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,companyVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户权限列表
|
|
|
+ * @param request 用户名
|
|
|
+ * @return 用户权限列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/privilegeList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> privilegeList(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
+ if (username.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ UserDTO userDTO = userService.getPrivilegeList(username);
|
|
|
+ if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ String[] strings = userDTO.getPrivilegeList().split(",");
|
|
|
+ List<PrivilegeNodeDTO> list = new ArrayList<>();
|
|
|
+ // 查看权限
|
|
|
+ List<PrivilegeNodeDTO> privilegeList = privilegeNodeService.getPrivilegeListByParentId(1, version);
|
|
|
+ List<PrivilegeNodeDTO> subList = new ArrayList<>();
|
|
|
+ for (PrivilegeNodeDTO dto : privilegeList) {
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (String s : strings) {
|
|
|
+ if (Objects.equals(Integer.valueOf(s),dto.getId())) {
|
|
|
+ subList.add(new PrivilegeNodeDTO(dto.getId(),dto.getName(),1));
|
|
|
+ isFlag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ subList.add(new PrivilegeNodeDTO(dto.getId(),dto.getName(),0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(new PrivilegeNodeDTO(1,"查看权限",1,subList));
|
|
|
+ // 操作权限
|
|
|
+ List<PrivilegeNodeDTO> privilegeList1 = privilegeNodeService.getPrivilegeListByParentId(14, version);
|
|
|
+ List<PrivilegeNodeDTO> subList1 = new ArrayList<>();
|
|
|
+ for (PrivilegeNodeDTO dto : privilegeList1) {
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (String s : strings) {
|
|
|
+ if (Objects.equals(Integer.valueOf(s),dto.getId())) {
|
|
|
+ subList1.add(new PrivilegeNodeDTO(dto.getId(),dto.getName(),1));
|
|
|
+ isFlag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ subList1.add(new PrivilegeNodeDTO(dto.getId(),dto.getName(),0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(new PrivilegeNodeDTO(14,"操作权限",1,subList1));
|
|
|
+ // 命令权限
|
|
|
+ List<PrivilegeNodeDTO> privilegeList2 = privilegeNodeService.getPrivilegeListByParentId(26, version);
|
|
|
+ List<PrivilegeNodeDTO> subList2 = new ArrayList<>();
|
|
|
+ for (PrivilegeNodeDTO dto : privilegeList2) {
|
|
|
+ boolean isFlag = false;
|
|
|
+ for (String s : strings) {
|
|
|
+ if (Objects.equals(Integer.valueOf(s),dto.getId())) {
|
|
|
+ subList2.add(new PrivilegeNodeDTO(dto.getId(),dto.getName(),1));
|
|
|
+ isFlag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isFlag) {
|
|
|
+ subList2.add(new PrivilegeNodeDTO(dto.getId(),dto.getName(),0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(new PrivilegeNodeDTO(26,"命令权限",1,subList2));
|
|
|
+ PrivilegeVO privilegeVO = new PrivilegeVO();
|
|
|
+ privilegeVO.setList(list);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,privilegeVO);
|
|
|
+ }
|
|
|
}
|