/**
  * 保存或更新
  *
  * @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;
 }
 /**
  * 批量删除
  *
  * @param ids
  * @return
  */
 @RequestMapping(params = "muldel")
 @ResponseBody
 public SuccessMsg mulDel(String[] ids) {
   SuccessMsg j = new SuccessMsg();
   if (ids != null) {
     j.setSuccess(true);
     j.setMsg("成功删除" + ids.length + "条记录");
     for (int i = 0; i < ids.length; i++) {
       if (!basePrintTemplateService.delete(new BasePrintTemplateEntity(ids[i]))) {
         j.setSuccess(false);
         j.setMsg("删除失败!");
       }
       systemService.addLog(
           BasePrintTemplateEntity.class.getSimpleName() + j.getMsg(), Globals.LOG_DEL);
     }
   }
   return j;
 }