后端模块修改
This commit is contained in:
parent
1a65dfd58e
commit
2c7e87daa7
@ -45,7 +45,7 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
|
|||||||
|
|
||||||
// 更新userId 字段
|
// 更新userId 字段
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
var loginUserId = String.valueOf(SecurityFrameworkUtils.getLoginUserId());
|
var loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||||
if (metaObject.hasSetter("userId")) { // 检查是否存在 userId 字段
|
if (metaObject.hasSetter("userId")) { // 检查是否存在 userId 字段
|
||||||
Object userIdValue = metaObject.getValue("userId");
|
Object userIdValue = metaObject.getValue("userId");
|
||||||
// 仅当 userId 为 null 时设置新值,防止覆盖已存在的值
|
// 仅当 userId 为 null 时设置新值,防止覆盖已存在的值
|
||||||
|
@ -2,12 +2,14 @@ package cn.yskj.linghe.module.acdr.controller.app.address.controller;
|
|||||||
|
|
||||||
import cn.yskj.linghe.module.acdr.api.AuthApi;
|
import cn.yskj.linghe.module.acdr.api.AuthApi;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.yskj.linghe.module.acdr.controller.app.address.service.ChinaAddressService;
|
import cn.yskj.linghe.module.acdr.controller.app.address.service.ChinaAddressService;
|
||||||
import cn.yskj.linghe.module.acdr.controller.app.address.entity.ChinaAddress;
|
import cn.yskj.linghe.module.acdr.controller.app.address.entity.ChinaAddress;
|
||||||
import cn.yskj.linghe.module.acdr.controller.app.address.mapper.ChinaAddressMapper;
|
import cn.yskj.linghe.module.acdr.controller.app.address.mapper.ChinaAddressMapper;
|
||||||
import cn.yskj.linghe.module.acdr.common.response.GlobalResponse;
|
import cn.yskj.linghe.module.acdr.common.response.GlobalResponse;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -71,20 +73,23 @@ public class ChinaAddressController {
|
|||||||
String address = param.getProvince() + param.getCity() + param.getDetailAddress();
|
String address = param.getProvince() + param.getCity() + param.getDetailAddress();
|
||||||
String res = HttpUtil.get(urlGeo+"?key=%s&address=%s".formatted(amapkey, address));
|
String res = HttpUtil.get(urlGeo+"?key=%s&address=%s".formatted(amapkey, address));
|
||||||
// 解析res json 数据
|
// 解析res json 数据
|
||||||
JSONObject resMap = JSONUtil.parseObj(res);
|
JSONObject resMap = JSON.parseObject(res);
|
||||||
if(resMap.isEmpty()) {
|
if(resMap.isEmpty()) {
|
||||||
return GlobalResponse.failure("服务错误,请联系管理人员修复!");
|
return GlobalResponse.failure("服务错误,请联系管理人员修复!");
|
||||||
}
|
}
|
||||||
if(resMap.get("status", Integer.class) == 1) {
|
if(resMap.getString("status").equals("1")) {
|
||||||
|
JSONArray geocodes = resMap.getJSONArray("geocodes");
|
||||||
|
JSONObject obj = geocodes.getJSONObject(0);
|
||||||
|
String location = obj.getString("location");
|
||||||
// 获取经纬度信息
|
// 获取经纬度信息
|
||||||
String[] locations = resMap.get("location", String.class).split(",");
|
String[] locations = location.split(",");
|
||||||
param.setLongitude(Long.parseLong(locations[0]));
|
param.setLongitude(locations[0]);
|
||||||
param.setLatitude(Long.parseLong(locations[1]));
|
param.setLatitude(locations[1]);
|
||||||
} else {
|
} else {
|
||||||
return GlobalResponse.failure("错误地址信息无法添加,"+resMap.get("info")+"!");
|
return GlobalResponse.failure("错误地址信息无法添加,"+resMap.get("info")+"!");
|
||||||
}
|
}
|
||||||
service.save(param);
|
service.save(param);
|
||||||
return GlobalResponse.success("中国地址表新增成功!");
|
return GlobalResponse.success("新增地址成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "中国地址表修改")
|
@ApiOperation(value = "中国地址表修改")
|
||||||
|
@ -96,11 +96,11 @@ public class ChinaAddress extends ExtendEntity implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty("经度")
|
@ApiModelProperty("经度")
|
||||||
@TableField(value = "latitude")
|
@TableField(value = "latitude")
|
||||||
private Long latitude;
|
private String latitude;
|
||||||
|
|
||||||
@ApiModelProperty("纬度")
|
@ApiModelProperty("纬度")
|
||||||
@TableField(value = "longitude")
|
@TableField(value = "longitude")
|
||||||
private Long longitude;
|
private String longitude;
|
||||||
|
|
||||||
@ApiModelProperty("是否为默认地址")
|
@ApiModelProperty("是否为默认地址")
|
||||||
@TableField("is_default")
|
@TableField("is_default")
|
||||||
|
Loading…
Reference in New Issue
Block a user