行政区划根据ID反向获取全称,包括省、市、县区,返回结果为json结构
This commit is contained in:
parent
0fb6c60a30
commit
4c41dbc24a
@ -1,6 +1,7 @@
|
|||||||
package com.cdzy.ebikeoperate.controller;
|
package com.cdzy.ebikeoperate.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.cdzy.common.enums.Code;
|
import com.cdzy.common.enums.Code;
|
||||||
import com.cdzy.common.model.JsonResult;
|
import com.cdzy.common.model.JsonResult;
|
||||||
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeComponentTypeInfoDto;
|
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeComponentTypeInfoDto;
|
||||||
@ -148,6 +149,18 @@ public class EbikeOperateSystemInfoController {
|
|||||||
return JsonResult.success(list);
|
return JsonResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据行政区划id获取行政区划全称。
|
||||||
|
*
|
||||||
|
* @param zoneId 行政区划id
|
||||||
|
* @return 行政区划全称
|
||||||
|
*/
|
||||||
|
@GetMapping("ebikeAdministrationZoneFullName")
|
||||||
|
public JsonResult<?> ebikeAdministrationZoneFullName(@RequestParam(name = "zoneId") String zoneId) {
|
||||||
|
JSONObject fullName = ebikeAdministrationZoneService.getFullNameByZoneId(zoneId);
|
||||||
|
return fullName == null?JsonResult.failed("获取行政区划全称失败") :JsonResult.success(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成二维码 (png图像base64串)。
|
* 生成二维码 (png图像base64串)。
|
||||||
* @param content 二维码内容
|
* @param content 二维码内容
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.cdzy.ebikeoperate.service.impl;
|
package com.cdzy.ebikeoperate.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.cdzy.ebikeoperate.mapper.EbikeAdministrationZoneMapper;
|
import com.cdzy.ebikeoperate.mapper.EbikeAdministrationZoneMapper;
|
||||||
import com.cdzy.ebikeoperate.model.dto.response.EbikeAdministrationZoneDto;
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeAdministrationZoneDto;
|
||||||
import com.cdzy.ebikeoperate.model.pojo.EbikeAdministrationZone;
|
import com.cdzy.ebikeoperate.model.pojo.EbikeAdministrationZone;
|
||||||
@ -40,4 +41,34 @@ public class EbikeAdministrationZoneServiceImpl extends ServiceImpl<EbikeAdminis
|
|||||||
return dto;
|
return dto;
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getFullNameByZoneId(String zoneId) {
|
||||||
|
switch (zoneId.length()){
|
||||||
|
case 2:
|
||||||
|
EbikeAdministrationZone province = this.getById(zoneId);
|
||||||
|
if(province != null){
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("province", province.getFullname());
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
EbikeAdministrationZone city = this.getById(zoneId);
|
||||||
|
if(city!= null){
|
||||||
|
JSONObject jsonObject = getFullNameByZoneId(zoneId.substring(0, 2));
|
||||||
|
jsonObject.put("city", city.getFullname());
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
EbikeAdministrationZone county = this.getById(zoneId);
|
||||||
|
if(county!= null){
|
||||||
|
JSONObject jsonObject = getFullNameByZoneId(zoneId.substring(0, 4));
|
||||||
|
jsonObject.put("county", county.getFullname());
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user