/**
  * 保存或更新
  *
  * @param bean
  * @return
  */
 @RequestMapping(params = "save")
 @ResponseBody
 public SuccessMsg save(BasePrintTemplateEntity bean) {
   SuccessMsg json = new SuccessMsg();
   String logType = Globals.LOG_INSERT;
   Map<String, Object> dataMap = new HashMap<>();
   if (StringUtils.isBlank(bean.getId())) {
     bean.setId(null);
     Serializable id = basePrintTemplateService.saveReturnId(bean);
     json.setSuccess(id != null);
     try {
       BeanUtils.setProperty(bean, "id", id);
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     } catch (InvocationTargetException e) {
       e.printStackTrace();
     }
   } else {
     BasePrintTemplateEntity basePrintTemplateEntity =
         basePrintTemplateService.getEntity(BasePrintTemplateEntity.class, bean.getId());
     if (basePrintTemplateEntity != null) basePrintTemplateEntity = new BasePrintTemplateEntity();
     BeanUtil.copyNotNull2Bean(bean, basePrintTemplateEntity);
     json.setSuccess(basePrintTemplateService.update(basePrintTemplateEntity));
     logType = Globals.LOG_UPDATE;
   }
   dataMap.put("bean", bean);
   json.setDataMap(dataMap);
   if (json.isSuccess()) json.setMsg("保存成功!");
   else json.setMsg("保存失败!");
   systemService.addLog(BasePrintTemplateEntity.class.getSimpleName() + json.getMsg(), logType);
   return json;
 }
 /**
  * 获取数据列表
  *
  * @param
  * @return
  */
 @RequestMapping(params = "datagrid")
 @ResponseBody
 public DataGrid datagrid(DataGrid d, HttpServletRequest request) {
   List<Criterion> list =
       BeanUtil.generateCriterions(BasePrintTemplateEntity.class, request, false);
   basePrintTemplateService.fillDataGrid(BasePrintTemplateEntity.class, list, d);
   return d;
 }