feat(service): 修改获取企事业单位列表接口
- 将接口参数从行政区划代码和等级改为公安单位机构代码 - 更新了企事业单位类型的枚举值 - 优化了 Web 配置中的跨域设置
This commit is contained in:
parent
c6b0c638c5
commit
b3f0227b40
|
@ -5,6 +5,9 @@ import com.changhu.common.db.BaseEnum;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/11/5 下午4:22
|
||||
|
@ -14,12 +17,28 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
public enum EnterprisesUnitType implements BaseEnum<String>, IEnum<String> {
|
||||
|
||||
school("school", "学校"),
|
||||
hospital("hospital", "医院"),
|
||||
community("community", "社区/小区"),
|
||||
bank("bank", "银行"),
|
||||
;
|
||||
PARTY_GOVERNMENT("party_government", "党政机关 "),
|
||||
MEDICAL("medical", "医疗机构"),
|
||||
RESIDENTIAL("residential", "小区"),
|
||||
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 label;
|
||||
|
||||
}
|
||||
|
|
|
@ -63,16 +63,16 @@ public class WebConfig implements WebMvcConfigurer {
|
|||
.addPathPatterns("/open/**");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void addCorsMappings(CorsRegistry registry) {
|
||||
// registry.addMapping("/**")
|
||||
// .allowedOriginPatterns("*")
|
||||
// .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE")
|
||||
// .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
|
||||
// "Access-Control-Request-Headers", "Authorization","Token","*")
|
||||
// .allowCredentials(true)
|
||||
// .maxAge(3600);
|
||||
// }
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE")
|
||||
.allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
|
||||
"Access-Control-Request-Headers", "Authorization", "Token", "*")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
|
|
@ -33,9 +33,8 @@ public class OpenController {
|
|||
@Operation(summary = "获取企事业单位列表")
|
||||
@CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions)
|
||||
@GetMapping("/getEnterprisesUnit")
|
||||
public List<SelectNodeVo<Long>> getEnterprisesUnit(@Schema(description = "行政区划代码") @RequestParam String code,
|
||||
@Schema(description = "行政区划等级") @RequestParam Integer level) {
|
||||
return openApiService.getEnterprisesUnit(code, level);
|
||||
public List<SelectNodeVo<Long>> getEnterprisesUnit(@Schema(description = "公安单位机构代码") @RequestParam String policeCode) {
|
||||
return openApiService.getEnterprisesUnit(policeCode);
|
||||
}
|
||||
|
||||
@Operation(summary = "企事业单位详情")
|
||||
|
|
|
@ -15,11 +15,10 @@ public interface OpenApiService {
|
|||
/**
|
||||
* 获取企事业单位列表
|
||||
*
|
||||
* @param code 行政区划代码
|
||||
* @param level 行政区划等级
|
||||
* @param policeCode 公安机构代码
|
||||
* @return 企事业单位列表
|
||||
*/
|
||||
List<SelectNodeVo<Long>> getEnterprisesUnit(String code, Integer level);
|
||||
List<SelectNodeVo<Long>> getEnterprisesUnit(String policeCode);
|
||||
|
||||
/**
|
||||
* 企事业单位详情
|
||||
|
|
|
@ -32,12 +32,10 @@ public class OpenApiServiceImpl implements OpenApiService {
|
|||
private ServiceProjectService serviceProjectService;
|
||||
|
||||
@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)
|
||||
.eq(level == 1, EnterprisesUnit::getProvince, code)
|
||||
.eq(level == 2, EnterprisesUnit::getCity, code)
|
||||
.eq(level == 3, EnterprisesUnit::getDistricts, code)
|
||||
.eq(level == 4, EnterprisesUnit::getStreet, code)
|
||||
.eq(EnterprisesUnit::getPoliceUnitId, policeUnit.getSnowFlakeId())
|
||||
.list()
|
||||
.stream()
|
||||
.map(item -> SelectNodeVo.<Long>builder()
|
||||
|
|
Loading…
Reference in New Issue