*/
@SuppressWarnings("unchecked")
@RequestMapping(params = "saveOrUpdateMore")
@ResponseBody
public AjaxJson saveOrUpdateMore(HttpServletRequest request) throws Exception{
AjaxJson j = new AjaxJson();
Map data = request.getParameterMap();
if(data!=null){
data = CommUtils.mapConvert(data);
String tableName = (String)data.get("tableName");
String id = (String)data.get("id");
//打印测试
Iterator it=data.entrySet().iterator();
while(it.hasNext()){
Map.Entry entry=(Map.Entry)it.next();
Object ok=entry.getKey();
Object ov=entry.getValue()==null?"":entry.getValue();
logger.debug("name:"+ok.toString()+";value:"+ov.toString());
}
Map<String,List<Map<String,Object>>> mapMore =CommUtils.mapConvertMore(data, tableName);
if(StringUtils.isEmpty(id)){
logger.info("一对多添加!!!!!");
try {
Map<String, Object> result = dataBaseService.insertTableMore(mapMore, tableName);
data.put("id", result.get("id"));
j.setSuccess(true);
message = "添加成功";
} catch (BusinessException e) {
e.printStackTrace();
j.setSuccess(false);
message = e.getMessage();
}
}else{
logger.info("一对多修改!!!!!");
try {
dataBaseService.updateTableMore(mapMore, tableName);
j.setSuccess(true);
message = "更新成功";
} catch (BusinessException e) {
e.printStackTrace();
j.setSuccess(false);
message = e.getMessage();
}
}
}
j.setMsg(message);
j.setObj(data);
return j;
}