/**
  * 保存或更新
  *
  * @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 tableName
   * @return
   */
  @RequestMapping(params = "delTemplate")
  @ResponseBody
  public SuccessMsg delTemplate(String tableName, String templateName) {

    SuccessMsg json = new SuccessMsg();
    String logType = Globals.LOG_DEL;
    json.setSuccess(basePrintTemplateService.delTemplate(tableName, templateName));
    if (json.isSuccess()) json.setMsg("删除成功!");
    else json.setMsg("删除失败!");
    systemService.addLog(BasePrintTemplateEntity.class.getSimpleName() + json.getMsg(), logType);
    return json;
  }
 /**
  * 删除
  *
  * @param id
  * @return
  */
 @RequestMapping(params = "del")
 @ResponseBody
 public SuccessMsg del(String id) {
   SuccessMsg j = new SuccessMsg();
   BasePrintTemplateEntity d = new BasePrintTemplateEntity();
   d.setId(id);
   j.setSuccess(basePrintTemplateService.delete(d));
   if (j.isSuccess()) j.setMsg("删除成功!");
   else j.setMsg("删除失败!");
   systemService.addLog(
       BasePrintTemplateEntity.class.getSimpleName() + j.getMsg(), Globals.LOG_DEL);
   return j;
 }
 /**
  * 保存或更新
  *
  * @param jsonData
  * @return
  */
 @RequestMapping(params = "jsonSave")
 @ResponseBody
 public SuccessMsg jsonSave(String jsonData) {
   Assert.notNull(jsonData);
   List<BasePrintTemplateEntity> entitys =
       JsonUtil.getGson()
           .fromJson(jsonData, new TypeToken<List<BasePrintTemplateEntity>>() {}.getType());
   SuccessMsg json = new SuccessMsg();
   String logType = Globals.LOG_INSERT;
   if (entitys != null && entitys.size() > 0) {
     json.setSuccess(basePrintTemplateService.bulkSave(entitys.get(0).getMTablename(), entitys));
   }
   if (json.isSuccess()) json.setMsg("保存成功!");
   else json.setMsg("保存失败!");
   systemService.addLog(BasePrintTemplateEntity.class.getSimpleName() + json.getMsg(), logType);
   return json;
 }