Sfoglia il codice sorgente

地址进行校验为空字符的情况

zhangxin 1 giorno fa
parent
commit
234bbf416c

+ 7 - 1
yami-shop-api/src/main/java/com/yami/shop/api/controller/AddrController.java

@@ -18,6 +18,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import ma.glasnost.orika.MapperFacade;
 import ma.glasnost.orika.MapperFacade;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
@@ -70,6 +71,9 @@ public class AddrController {
         if (addrParam.getAddrId() != null && addrParam.getAddrId() != 0) {
         if (addrParam.getAddrId() != null && addrParam.getAddrId() != 0) {
             return ResponseEntity.badRequest().body("该地址已存在");
             return ResponseEntity.badRequest().body("该地址已存在");
         }
         }
+        if (StringUtils.isEmpty(addrParam.getAddress())){
+            return ResponseEntity.badRequest().body("腾讯address不能为空");
+        }
         int addrCount = userAddrService.count(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId));
         int addrCount = userAddrService.count(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId));
         UserAddr userAddr = new UserAddr();
         UserAddr userAddr = new UserAddr();
         BeanUtils.copyProperties(addrParam, userAddr);
         BeanUtils.copyProperties(addrParam, userAddr);
@@ -105,7 +109,9 @@ public class AddrController {
         if (dbUserAddr == null) {
         if (dbUserAddr == null) {
             return ResponseEntity.badRequest().body("该地址已被删除");
             return ResponseEntity.badRequest().body("该地址已被删除");
         }
         }
-
+        if (StringUtils.isEmpty(addrParam.getAddress())){
+            return ResponseEntity.badRequest().body("腾讯address不能为空");
+        }
         UserAddr userAddr = mapperFacade.map(addrParam, UserAddr.class);
         UserAddr userAddr = mapperFacade.map(addrParam, UserAddr.class);
         userAddr.setUserId(userId);
         userAddr.setUserId(userId);
         userAddr.setUpdateTime(new Date());
         userAddr.setUpdateTime(new Date());