|
|
|
@ -4,27 +4,33 @@ import io.swagger.annotations.ApiModel;
|
|
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import javax.validation.constraints.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
@ApiModel(description = "当前位置实体")
|
|
|
|
|
public class LocationDTO {
|
|
|
|
|
|
|
|
|
|
private static final String LONGITUDE_REGEX = "/^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,6}|1[0-7]?\\d{1}\\.\\d{1,6}|180\\.0{1,6})$/";
|
|
|
|
|
private static final String LONGITUDE_REGEX = "^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,6}|1[0-7]?\\d{1}\\.\\d{1,6}|180\\.0{1,6})$";
|
|
|
|
|
|
|
|
|
|
private static final String LATITUDE_REGEX = "/^[\\-\\+]?([0-8]?\\d{1}\\.\\d{1,6}|90\\.0{1,6})$/";
|
|
|
|
|
private static final String LATITUDE_REGEX = "^[\\-\\+]?([0-8]?\\d{1}\\.\\d{1,6}|90\\.0{1,6})$";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiModelProperty(value = "当前经度", required = true, example = "121.404032")
|
|
|
|
|
@NotNull(message = "未知定位")
|
|
|
|
|
@Pattern(regexp = LONGITUDE_REGEX, message = "经度格式错误")
|
|
|
|
|
private String longitude;
|
|
|
|
|
|
|
|
|
|
@ApiModelProperty(value = "当前经度", required = true, example = "31.163973")
|
|
|
|
|
@ApiModelProperty(value = "当前纬度", required = true, example = "31.163973")
|
|
|
|
|
@NotNull(message = "未知定位")
|
|
|
|
|
@Pattern(regexp = LATITUDE_REGEX, message = "纬度格式错误")
|
|
|
|
|
private String latitude;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断经纬度是否有效
|
|
|
|
|
public boolean isValid() {
|
|
|
|
|
return Pattern.matches(LONGITUDE_REGEX, longitude) && Pattern.matches(LATITUDE_REGEX, latitude);
|
|
|
|
|
}
|
|
|
|
|
// // 判断经纬度是否有效
|
|
|
|
|
// public boolean isValid() {
|
|
|
|
|
// return Pattern.matches(/LONGITUDE_REGEX/, longitude) && Pattern.matches(/LATITUDE_REGEX/, latitude);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|