Browse Source

区县、街道、社区下拉框

master
yinzuomei 2 years ago
parent
commit
6453e1c296
  1. 54
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  2. 20
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

54
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -19,6 +19,9 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
@ -41,6 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -564,4 +568,54 @@ public class CustomerAgencyController {
return new Result<PageData<CommunityListByAgencyIdResultDTO>>().ok(customerAgencyService.getCommunityList(dto)); return new Result<PageData<CommunityListByAgencyIdResultDTO>>().ok(customerAgencyService.getCommunityList(dto));
} }
/**
* 返回区县列表
* @param tokenDto
* @return
*/
@PostMapping("districtList")
public Result<List<CustomerAgencyDTO>> districtList(@LoginUser TokenDto tokenDto){
Map<String, Object> params=new HashMap<>();
params.put("CUSTOMER_ID",tokenDto.getCustomerId());
params.put("LEVEL",OrgLevelEnum.DISTRICT.getCode());
params.put("PID",null);
return new Result<List<CustomerAgencyDTO>>().ok(customerAgencyService.list(params));
}
/**
* 返回街道列表必传区县
* @param tokenDto
* @param districtId
* @return
*/
@PostMapping("streetList/{districtId}")
public Result<List<CustomerAgencyDTO>> streetList(@LoginUser TokenDto tokenDto,@PathVariable("districtId")String districtId){
if(StringUtils.isBlank(districtId)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"districtId为空","请先选择区县");
}
Map<String, Object> params=new HashMap<>();
params.put("CUSTOMER_ID",tokenDto.getCustomerId());
params.put("LEVEL",OrgLevelEnum.STREET.getCode());
params.put("PID",districtId);
return new Result<List<CustomerAgencyDTO>>().ok(customerAgencyService.list(params));
}
/**
* 返回社区列表街道必传
* @param tokenDto
* @param streetId
* @return
*/
@PostMapping("communityList/{streetId}")
public Result<List<CustomerAgencyDTO>> communityList(@LoginUser TokenDto tokenDto,@PathVariable("streetId")String streetId){
if(StringUtils.isBlank(streetId)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"streetId为空","请先选择街道");
}
Map<String, Object> params=new HashMap<>();
params.put("CUSTOMER_ID",tokenDto.getCustomerId());
params.put("LEVEL",OrgLevelEnum.COMMUNITY.getCode());
params.put("PID",streetId);
return new Result<List<CustomerAgencyDTO>>().ok(customerAgencyService.list(params));
}
} }

20
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -18,7 +18,6 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -45,7 +44,6 @@ import com.epmet.constant.CustomerGridConstant;
import com.epmet.dao.*; import com.epmet.dao.*;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.region.LogOperationResultDTO;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerDepartmentEntity; import com.epmet.entity.CustomerDepartmentEntity;
@ -136,12 +134,16 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
return ConvertUtils.sourceToTarget(entityList, CustomerAgencyDTO.class); return ConvertUtils.sourceToTarget(entityList, CustomerAgencyDTO.class);
} }
private QueryWrapper<CustomerAgencyEntity> getWrapper(Map<String, Object> params) { private LambdaQueryWrapper<CustomerAgencyEntity> getWrapper(Map<String, Object> map) {
String id = (String) params.get(FieldConstant.ID_HUMP); String id = map.containsKey(FieldConstant.ID_HUMP) ? (String) map.get(FieldConstant.ID_HUMP) : null;
String customerId = map.containsKey("CUSTOMER_ID") ? (String) map.get("CUSTOMER_ID") : null;
QueryWrapper<CustomerAgencyEntity> wrapper = new QueryWrapper<>(); String level = map.containsKey("LEVEL") ? (String) map.get("LEVEL") : null;
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); String pid = map.containsKey("PID") ? (String) map.get("PID") : null;
LambdaQueryWrapper<CustomerAgencyEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), CustomerAgencyEntity::getId, id)
.eq(StringUtils.isNotBlank(customerId), CustomerAgencyEntity::getCustomerId, customerId)
.eq(StringUtils.isNotBlank(level), CustomerAgencyEntity::getLevel, level)
.eq(StringUtils.isNotBlank(pid), CustomerAgencyEntity::getPid, pid);
return wrapper; return wrapper;
} }
@ -1244,7 +1246,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
/** /**
* 递归查询子节点 * 递归查询子节点
* @param root 根节点 * @param root 根节点
* @param all 所有节点 * @param 所有节点
* @return 根节点信息 * @return 根节点信息
*/ */
private void convert2AgencyTreeResult(AgencyTreeResultDTO root, List<ExtStaffPermissionResultDTO> agencyList, List<ExtGridResultDTO> gridList) { private void convert2AgencyTreeResult(AgencyTreeResultDTO root, List<ExtStaffPermissionResultDTO> agencyList, List<ExtGridResultDTO> gridList) {

Loading…
Cancel
Save