//TFieldCheckResList 是个实体类.
public void updateFieldCheck(TFieldCheckResList tFieldChecks){
Class<?> aClass = tFieldChecks.getClass(); //获取该类
Integer bizType = 1;
int count = tFieldCheckDAO.selectCount(Wrappers.<TFieldCheck>lambdaQuery().eq(TFieldCheck::getFlagDel,Constants.DEL_FLAG_OFF));//我自己的业务逻辑,不用管
//得到属性
Field field = null; //声明field,操作单一属性
try {
Field[] fields = null; //声明field数组,用来获取该类中所有属性
fields = aClass.getDeclaredFields(); //获取所有属性
for(int i = 0;i<fields.length;i++){
field = aClass.getDeclaredField(fields[i].getName());//getName 是属性名, 传入这个属性名,可能是这个field就相当于这个元素的啥啥了.
field.setAccessible(true);//打开私有访问
List<TFieldCheckRes> list = (List)field.get(tFieldChecks);//获取属性值
if(count>0){
List flagCheckTrue = new ArrayList();
List flagCheckfalse = new ArrayList();
for(TFieldCheckRes tFieldCheckRes : list){
if(tFieldCheckRes.getFlagCheck() == 1){
flagCheckTrue.add(tFieldCheckRes.getFieldLabel());
}else{
flagCheckfalse.add(tFieldCheckRes.getFieldLabel());
}
}
this.updateFieldCheck(flagCheckTrue,flagCheckfalse,bizType);
bizType++;
}else {
for(TFieldCheckRes tFieldCheckRes : list){
TFieldCheck tFieldCheck = new TFieldCheck();
BeanUtils.copyBeanProp(tFieldCheck,tFieldCheckRes);
tFieldCheckDAO.insert(tFieldCheck);
}
}
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}