Exemplo n.º 1
0
 // 删除
 public String delete() throws Exception {
   Json _json = new Json();
   try {
     if (this.getId() != null) { // 删除一条
       this.getCrudService().delete(this.getId());
     } else { // 删除一批
       if (this.getIds() != null && this.getIds().length() > 0) {
         Long[] ids = cn.bc.core.util.StringUtils.stringArray2LongArray(this.getIds().split(","));
         this.getCrudService().delete(ids);
       } else {
         throw new CoreException("must set property id or ids");
       }
     }
     _json.put("success", true);
     _json.put("msg", getText("form.delete.success"));
     json = _json.toString();
     return "json";
   } catch (PermissionDeniedException e) {
     // 执行没有权限的操作
     _json.put("msg", getDeleteExceptionMsg(e));
     _json.put("e", e.getClass().getSimpleName());
   } catch (InnerLimitedException e) {
     // 删除内置对象
     _json.put("msg", getDeleteExceptionMsg(e));
     _json.put("e", e.getClass().getSimpleName());
   } catch (NotExistsException e) {
     // 执行没有权限的操作
     _json.put("msg", getDeleteExceptionMsg(e));
     _json.put("e", e.getClass().getSimpleName());
   } catch (ConstraintViolationException e) {
     // 违反约束关联引发的异常
     _json.put("msg", getDeleteExceptionMsg(e));
     _json.put("e", e.getClass().getSimpleName());
   } catch (Exception e) {
     // 其他异常
     dealOtherDeleteException(_json, e);
   }
   _json.put("success", false);
   json = _json.toString();
   return "json";
 }