Commit 2e46df87 authored by hezhen's avatar hezhen

修改商品审核

parent 1e381bf7
package com.github.wxiaoqi.security.common.util;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
/**
* <p>Description: 判断对象是否为空,进一步判断对象中的属性是否都为空 </p>
* @author duanfeixia
* @date 2018年11月12日
*/
public class CheckObjectIsNullUtils {
/**
* 判断对象是否为空,且对象的所有属性都为空
* ps: boolean类型会有默认值false 判断结果不会为null 会影响判断结果
* 序列化的默认值也会影响判断结果
* @param object
* @return
*/
public static boolean objCheckIsNull(Object object){
Class clazz = (Class)object.getClass(); // 得到类对象
Field fields[] = clazz.getDeclaredFields(); // 得到所有属性
boolean flag = true; //定义返回结果,默认为true
for(Field field : fields){
field.setAccessible(true);
Object fieldValue = null;
try {
fieldValue = field.get(object); //得到属性值
Type fieldType =field.getGenericType();//得到属性类型
String fieldName = field.getName(); // 得到属性名
System.out.println("属性类型:"+fieldType+",属性名:"+fieldName+",属性值:"+fieldValue);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if(fieldValue != null){ //只要有一个属性值不为null 就返回false 表示对象不为null
flag = false;
break;
}
}
return flag;
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.CheckObjectIsNullUtils;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
......@@ -1602,9 +1603,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
throw new BaseException("公司名称不能重复", ResultCode.FAILED_CODE);
}
Vehicle vehicle= JSONUtil.toBean(vehicleApply.getChangeJson(),Vehicle.class);
if (StringUtils.isNotBlank(vehicleApply.getVehicleId())){
vehicle.setId(vehicleId);
updateSelectiveById(vehicle);
if (!StringUtils.isNotBlank(vehicleApply.getVehicleId())){
if (CheckObjectIsNullUtils.objCheckIsNull(vehicle)){
vehicle.setId(vehicleId);
updateSelectiveById(vehicle);
}
}else {
vehicle.setId(UUID.randomUUID().toString());
insertSelective(vehicle);
......@@ -1637,4 +1640,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment