阿超
>
bean-searcher整合mybatis-plus逻辑删除
人死像熟透的梨,离树而落,梨者,离也。——《活着》
需要用到参数过滤器:
https://bs.zhxu.cn/guide/latest/advance.html#参数过滤器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| @Bean public ParamFilter logicDeleteFilter() { return new ParamFilter() { @Override public <T> Map<String, Object> doFilter(BeanMeta<T> beanMeta, Map<String, Object> paraMap) { TableInfo tableInfo = TableInfoHelper.getTableInfo(beanMeta.getBeanClass()); Opt.ofNullable(tableInfo).ifPresent(info -> { TableFieldInfo logicDelField = tableInfo.getLogicDeleteFieldInfo(); String logicNoDelVal = logicDelField.getLogicNotDeleteValue(); if (StringPool.NULL.equalsIgnoreCase(logicNoDelVal)) { MapUtils.builder(paraMap).field(logicDelField.getProperty()).op(IsNull.class); } else { MapUtils.builder(paraMap).field(logicDelField.getProperty(), logicNoDelVal); } }); return paraMap; } }; }
|