feat(service): 修改获取企事业单位列表接口

- 将接口参数从行政区划代码和等级改为公安单位机构代码
- 更新了企事业单位类型的枚举值
- 优化了 Web 配置中的跨域设置
This commit is contained in:
luozhun 2024-11-11 14:15:50 +08:00
parent c6b0c638c5
commit b3f0227b40
5 changed files with 41 additions and 26 deletions

View File

@ -5,6 +5,9 @@ import com.changhu.common.db.BaseEnum;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import java.util.Arrays;
import java.util.stream.Collectors;
/** /**
* @author 20252 * @author 20252
* @createTime 2024/11/5 下午4:22 * @createTime 2024/11/5 下午4:22
@ -14,12 +17,28 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
public enum EnterprisesUnitType implements BaseEnum<String>, IEnum<String> { public enum EnterprisesUnitType implements BaseEnum<String>, IEnum<String> {
school("school", "学校"), PARTY_GOVERNMENT("party_government", "党政机关 "),
hospital("hospital", "医院"), MEDICAL("medical", "医疗机构"),
community("community", "社区/小区"), RESIDENTIAL("residential", "小区"),
bank("bank", "银行"), HIGHER_LEARNING("higher_learning", "高等院校"),
; PRIMARY_AND_SECONDARY("primary_and_secondary", "中小学幼儿园"),
SHOPPING_SUPERMARKETS("shopping_supermarkets", "商场超市"),
FINANCIAL("financial", "金融机构"),
HYDROPOWER("hydropower", "水电油气"),
KEY_PROJECTS("key_projects", "重点工程建设单位"),
DELIVERY_LOGISTICS("delivery_logistics", "寄递物流"),
MILITARY("military", "军工、科研单位"),
WEN_BO("wen_bo", "文博单位"),
IMPORTANT_NEWS("important_news ", "重要新闻单位"),
LARGE_SCALE_MATERIAL("large_scale_material ", "大型物资储备"),
TRANSPORTATION("transportation", "交通运输企业"),
INDUSTRIAL_PARK("industrial_park", "工业园区企业"),
COMPLEX_PUBLIC_SECURITY("complex_public_security", "治安复杂场所"),
MAKING_EXPLOSIVE_EASILY("making_explosive_easily ", "易制爆"),
hazardous_materials("hazardous_materials ", "危化物品存放场所"),
other("other", "其他单位");
private final String value; private final String value;
private final String label; private final String label;
} }

View File

@ -63,16 +63,16 @@ public class WebConfig implements WebMvcConfigurer {
.addPathPatterns("/open/**"); .addPathPatterns("/open/**");
} }
// @Override @Override
// public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
// registry.addMapping("/**") registry.addMapping("/**")
// .allowedOriginPatterns("*") .allowedOriginPatterns("*")
// .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE") .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE")
// .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
// "Access-Control-Request-Headers", "Authorization","Token","*") "Access-Control-Request-Headers", "Authorization", "Token", "*")
// .allowCredentials(true) .allowCredentials(true)
// .maxAge(3600); .maxAge(3600);
// } }
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {

View File

@ -33,9 +33,8 @@ public class OpenController {
@Operation(summary = "获取企事业单位列表") @Operation(summary = "获取企事业单位列表")
@CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions)
@GetMapping("/getEnterprisesUnit") @GetMapping("/getEnterprisesUnit")
public List<SelectNodeVo<Long>> getEnterprisesUnit(@Schema(description = "行政区划代码") @RequestParam String code, public List<SelectNodeVo<Long>> getEnterprisesUnit(@Schema(description = "公安单位机构代码") @RequestParam String policeCode) {
@Schema(description = "行政区划等级") @RequestParam Integer level) { return openApiService.getEnterprisesUnit(policeCode);
return openApiService.getEnterprisesUnit(code, level);
} }
@Operation(summary = "企事业单位详情") @Operation(summary = "企事业单位详情")

View File

@ -15,11 +15,10 @@ public interface OpenApiService {
/** /**
* 获取企事业单位列表 * 获取企事业单位列表
* *
* @param code 行政区划代码 * @param policeCode 公安机构代码
* @param level 行政区划等级
* @return 企事业单位列表 * @return 企事业单位列表
*/ */
List<SelectNodeVo<Long>> getEnterprisesUnit(String code, Integer level); List<SelectNodeVo<Long>> getEnterprisesUnit(String policeCode);
/** /**
* 企事业单位详情 * 企事业单位详情

View File

@ -32,12 +32,10 @@ public class OpenApiServiceImpl implements OpenApiService {
private ServiceProjectService serviceProjectService; private ServiceProjectService serviceProjectService;
@Override @Override
public List<SelectNodeVo<Long>> getEnterprisesUnit(String code, Integer level) { public List<SelectNodeVo<Long>> getEnterprisesUnit(String policeCode) {
PoliceUnit policeUnit = Db.lambdaQuery(PoliceUnit.class).eq(PoliceUnit::getCode, policeCode).oneOpt().orElseThrow(() -> new MessageException("当前系统没有该派出所"));
return Db.lambdaQuery(EnterprisesUnit.class) return Db.lambdaQuery(EnterprisesUnit.class)
.eq(level == 1, EnterprisesUnit::getProvince, code) .eq(EnterprisesUnit::getPoliceUnitId, policeUnit.getSnowFlakeId())
.eq(level == 2, EnterprisesUnit::getCity, code)
.eq(level == 3, EnterprisesUnit::getDistricts, code)
.eq(level == 4, EnterprisesUnit::getStreet, code)
.list() .list()
.stream() .stream()
.map(item -> SelectNodeVo.<Long>builder() .map(item -> SelectNodeVo.<Long>builder()