List<Map<String, Object>> infos = (List<Map<String, Object>>)JSONUtils.fromJSON(modelJson, List.class);
List<DBTypesBean> beans = new ArrayList<DBTypesBean>();
boolean ret = false;
Map<String, List<String>> errors = null;
for (Map<String, Object> info: infos) {
DBTypesBean bean = mapper.mapFromRow(info, DBTypesBean.class);
if (bean.getCreateDateLong() != null) {
bean.setCreateDate(new Timestamp(bean.getCreateDateLong()));
}
if (emptyValidator.validate(bean) == null) {
data = "[]";
} else if ("update/".equals(pattern)) {
if (bean.getTypeId() == null) {
// insert
if ((errors = validator.validate(bean)) == null) {
DbAccess.typesAccess.insert(bean);
ret = true;
} else {
break;
}
} else {
if ((errors = validator.validate(bean)) == null) {
// update
DbAccess.typesAccess.updateByPrimaryKey(bean, bean.getTypeId());
ret = true;
} else {
break;
}
}
} else if (bean.getTypeId() != null) {
// delete
DbAccess.typesAccess.deleteByPrimaryKey(bean.getTypeId());
ret = true;
}
if (ret) {
beans.add(bean);
}