Przeglądaj źródła

年检代办订单增加经纬度字段、增强校验参数

Qchen 2 lat temu
rodzic
commit
0af6cbbc62

+ 23 - 0
src/main/java/com/ydtech/modules/ser/model/SerAnnualAuditOrder.java

@@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
@@ -29,6 +30,7 @@ public class SerAnnualAuditOrder implements Serializable {
      */
     @TableField(value = "car_info_id")
     @ApiModelProperty(value = "车辆信息id")
+    @NotNull
     private String carInfoId;
 
     /**
@@ -36,6 +38,7 @@ public class SerAnnualAuditOrder implements Serializable {
      */
     @TableField(value = "licenseno")
     @ApiModelProperty(value = "车牌号")
+    @NotNull
     private String licenseNo;
 
 
@@ -44,6 +47,7 @@ public class SerAnnualAuditOrder implements Serializable {
      */
     @TableField(value = "contact_person")
     @ApiModelProperty(value = "联系人")
+    @NotNull
     private String contactPerson;
 
     /**
@@ -51,6 +55,7 @@ public class SerAnnualAuditOrder implements Serializable {
      */
     @TableField(value = "mobile")
     @ApiModelProperty(value = "联系人电话")
+    @NotNull
     private String mobile;
 
     /**
@@ -58,6 +63,7 @@ public class SerAnnualAuditOrder implements Serializable {
      */
     @TableField(value = "address")
     @ApiModelProperty(value = "地址")
+    @NotNull
     private String address;
 
     /**
@@ -65,8 +71,25 @@ public class SerAnnualAuditOrder implements Serializable {
      */
     @TableField(value = "detail_address")
     @ApiModelProperty(value = "详细地址")
+    @NotNull
     private String detailAddress;
 
+    /**
+     * 经度
+     */
+    @TableField(value = "longitude")
+    @ApiModelProperty(value = "经度")
+    @NotNull
+    private Double longitude;
+
+    /**
+     * 纬度
+     */
+    @TableField(value = "latitude")
+    @ApiModelProperty(value = "纬度")
+    @NotNull
+    private Double latitude;
+
     /**
      * 服务价格(不包含检测费用)
      */

+ 14 - 0
src/main/java/com/ydtech/modules/ser/service/impl/SerAnnualAuditOrderServiceImpl.java

@@ -13,15 +13,29 @@ import com.ydtech.utils.idgen.IdGenerate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
 import java.time.LocalDateTime;
+import java.util.Set;
 
 @Service
 public class SerAnnualAuditOrderServiceImpl implements SerAnnualAuditOrderService {
     @Autowired
     SerAnnualAuditOrderMapper serAnnualAuditOrderMapper;
 
+    @Autowired
+    private Validator validator;
+
     @Override
     public HttpResult addAnnualAuditOrder(SerAnnualAuditOrder serAnnualAuditOrder) {
+        Set<ConstraintViolation<SerAnnualAuditOrder>> violations = validator.validate(serAnnualAuditOrder);
+        if (!violations.isEmpty()) {
+            StringBuilder errorMessage = new StringBuilder("参数校验失败:");
+            for (ConstraintViolation<SerAnnualAuditOrder> violation : violations) {
+                errorMessage.append(violation.getPropertyPath()).append(" ").append(violation.getMessage()).append("; ");
+            }
+            return HttpResult.error(errorMessage.toString());
+        }
         serAnnualAuditOrder.setId(IdGenerate.nextId());
         LocalDateTime date = LocalDateTime.now();
         serAnnualAuditOrder.setCreateTime(date);