新增站点json文件校验逻辑补充,查询项目详情接口修改等
This commit is contained in:
@ -148,11 +148,11 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
}
|
||||
JSONArray jsonArray = JSONUtil.parseArray(coordinates);
|
||||
//判断数组每个元素必须为经度或纬度
|
||||
// for (Object o : jsonArray) {
|
||||
// if (!(o instanceof Double)) {
|
||||
// throw new ServiceException("coordinates必须只包含经纬度数据!");
|
||||
// }
|
||||
// }
|
||||
for (Object o : jsonArray) {
|
||||
if(isLongitudeOrLatitude(o.toString())){
|
||||
throw new ServiceException("coordinates数组元素必须为经度或纬度!");
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex = space.indexOf("/profile/upload/");
|
||||
String relativeUrl = space.substring(startIndex);
|
||||
@ -161,6 +161,25 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是不是经度或者纬度
|
||||
* @param str 经纬度字符串
|
||||
* @return true or false
|
||||
*/
|
||||
private boolean isLongitudeOrLatitude(String str) {
|
||||
String regex = "^[-+]?\\d{1,3}\\.\\d+$";
|
||||
double value = Double.parseDouble(str);
|
||||
//满足经度值
|
||||
if (value >= -180 && value <= 180) {
|
||||
return true;
|
||||
}
|
||||
//满足纬度值
|
||||
else if (value >= -90 && value <= 90) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改站点
|
||||
|
Reference in New Issue
Block a user