浏览代码

客户页面报错bug修复

wucl 2 年之前
父节点
当前提交
49efc8069a
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      service/src/main/java/com/dayou/service/impl/CustomerServiceImpl.java

+ 8 - 2
service/src/main/java/com/dayou/service/impl/CustomerServiceImpl.java

@@ -107,7 +107,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
     @Override
     public Boolean add(CustomerDTO customer){
         customer.setUserId(LoginContext.getUserId());
-        customer.setCity(JSON.toJSONString(customer.getCitys()));
+        List<Long> citys = customer.getCitys();
+        if (CollectionUtils.isNotEmpty(citys)){
+            customer.setCity(JSON.toJSONString(citys));
+        }
         return  this.save(customer);
     }
 
@@ -118,7 +121,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
     }
     @Override
     public Boolean update(CustomerDTO customer){
-        customer.setCity(JSON.toJSONString(customer.getCitys()));
+        List<Long> citys = customer.getCitys();
+        if (CollectionUtils.isNotEmpty(citys)){
+            customer.setCity(JSON.toJSONString(citys));
+        }
         return  this.updateById(customer);
     }