后端模块修改

This commit is contained in:
aiShuiJiaoDeXioShou 2024-09-19 08:02:21 +08:00
parent 1a65dfd58e
commit 2c7e87daa7
3 changed files with 15 additions and 10 deletions

View File

@ -45,7 +45,7 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
// 更新userId 字段
if (userId != null) {
var loginUserId = String.valueOf(SecurityFrameworkUtils.getLoginUserId());
var loginUserId = SecurityFrameworkUtils.getLoginUserId();
if (metaObject.hasSetter("userId")) { // 检查是否存在 userId 字段
Object userIdValue = metaObject.getValue("userId");
// 仅当 userId null 时设置新值防止覆盖已存在的值

View File

@ -2,12 +2,14 @@ package cn.yskj.linghe.module.acdr.controller.app.address.controller;
import cn.yskj.linghe.module.acdr.api.AuthApi;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
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.entity.ChinaAddress;
import cn.yskj.linghe.module.acdr.controller.app.address.mapper.ChinaAddressMapper;
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.ApiOperation;
import jakarta.annotation.Resource;
@ -71,20 +73,23 @@ public class ChinaAddressController {
String address = param.getProvince() + param.getCity() + param.getDetailAddress();
String res = HttpUtil.get(urlGeo+"?key=%s&address=%s".formatted(amapkey, address));
// 解析res json 数据
JSONObject resMap = JSONUtil.parseObj(res);
JSONObject resMap = JSON.parseObject(res);
if(resMap.isEmpty()) {
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(",");
param.setLongitude(Long.parseLong(locations[0]));
param.setLatitude(Long.parseLong(locations[1]));
String[] locations = location.split(",");
param.setLongitude(locations[0]);
param.setLatitude(locations[1]);
} else {
return GlobalResponse.failure("错误地址信息无法添加,"+resMap.get("info")+"!");
}
service.save(param);
return GlobalResponse.success("中国地址表新增成功!");
return GlobalResponse.success("新增地址成功!");
}
@ApiOperation(value = "中国地址表修改")

View File

@ -96,11 +96,11 @@ public class ChinaAddress extends ExtendEntity implements Serializable {
@ApiModelProperty("经度")
@TableField(value = "latitude")
private Long latitude;
private String latitude;
@ApiModelProperty("纬度")
@TableField(value = "longitude")
private Long longitude;
private String longitude;
@ApiModelProperty("是否为默认地址")
@TableField("is_default")