|
|
@@ -24,6 +24,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
@@ -166,10 +167,20 @@ public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements Ar
|
|
|
if (dto == null) {
|
|
|
throw new IllegalArgumentException("坐标信息不能为空");
|
|
|
}
|
|
|
- if (dto.getLongitude() < -180 || dto.getLongitude() > 180) {
|
|
|
+
|
|
|
+ // 1. 先判空
|
|
|
+ if (dto.getLongitude() == null || dto.getLatitude() == null) {
|
|
|
+ throw new IllegalArgumentException("经纬度数值不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 再比较(此时已经确定不为 null,可以安全拆箱)
|
|
|
+ double lon = dto.getLongitude().doubleValue();
|
|
|
+ double lat = dto.getLatitude().doubleValue();
|
|
|
+
|
|
|
+ if (lon < -180 || lon > 180) {
|
|
|
throw new IllegalArgumentException("经度必须在-180到180之间");
|
|
|
}
|
|
|
- if (dto.getLatitude() < -90 || dto.getLatitude() > 90) {
|
|
|
+ if (lat < -90 || lat > 90) {
|
|
|
throw new IllegalArgumentException("纬度必须在-90到90之间");
|
|
|
}
|
|
|
}
|