* @return
*/
@RequestMapping(params = "saveFiles", method = RequestMethod.POST)
@ResponseBody
public AjaxJson saveFiles(HttpServletRequest request, HttpServletResponse response, CgUploadEntity cgUploadEntity) {
AjaxJson j = new AjaxJson();
Map<String, Object> attributes = new HashMap<String, Object>();
String fileKey = oConvertUtils.getString(request.getParameter("fileKey"));// 文件ID
String id = oConvertUtils.getString(request.getParameter("cgFormId"));//动态表主键ID
String tableName = oConvertUtils.getString(request.getParameter("cgFormName"));//动态表名
String cgField = oConvertUtils.getString(request.getParameter("cgFormField"));//动态表上传控件字段
if(!StringUtil.isEmpty(id)){
cgUploadEntity.setCgformId(id);
cgUploadEntity.setCgformName(tableName);
cgUploadEntity.setCgformField(cgField);
}
if (StringUtil.isNotEmpty(fileKey)) {
cgUploadEntity.setId(fileKey);
cgUploadEntity = systemService.getEntity(CgUploadEntity.class, fileKey);
}
UploadFile uploadFile = new UploadFile(request, cgUploadEntity);
uploadFile.setCusPath("files");
uploadFile.setSwfpath("swfpath");
uploadFile.setByteField(null);//不存二进制内容
cgUploadEntity = systemService.uploadFile(uploadFile);
cgUploadService.writeBack(id, tableName, cgField, fileKey, cgUploadEntity.getRealpath());
attributes.put("fileKey", cgUploadEntity.getId());
attributes.put("viewhref", "commonController.do?objfileList&fileKey=" + cgUploadEntity.getId());
attributes.put("delurl", "commonController.do?delObjFile&fileKey=" + cgUploadEntity.getId());
j.setMsg("操作成功");
j.setAttributes(attributes);
return j;
}