当前位置:网站首页>BeanSearcher接收数组参数、以及逻辑删除
BeanSearcher接收数组参数、以及逻辑删除
2022-07-23 01:18:00 【苍穹之跃】
import cn.hutool.core.lang.PatternPool;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import com.ejlchina.searcher.BeanMeta;
import com.ejlchina.searcher.ParamFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.regex.Pattern;
@Component
public class BeanSearchConfig {
@Bean
public ParamFilter myParamFilter() {
return new ParamFilter() {
@Override
public <T> Map<String, Object> doFilter(BeanMeta<T> beanMeta, Map<String, Object> paraMap) {
/**
* 将前端传过来的数组转成_0_1_2...形式
* 注:博主separator采用的是下划线,框架默认是中划线。读者根据自己情况修改一下
*/
Map<String, Object> map = ObjectUtil.clone(paraMap);
map.forEach((k, v) -> {
//如果匹配到了以[数字]结尾,则认为是数组
List<String> allGroups = ReUtil.getAllGroups(PatternPool.get("(.*)\\[(\\d*)\\]$", Pattern.DOTALL), k);
if (allGroups.size() > 0) {
paraMap.remove(k);
paraMap.putIfAbsent(allGroups.get(1) + "_op", "il");
paraMap.put(allGroups.get(1) + "_" + allGroups.get(2), v);
}
});
/**
* 逻辑删除:
* 删除标识:deleted 0未删除、1已删除
*/
paraMap.put("deleted", 0);
return paraMap;
}
};
}
}
边栏推荐
猜你喜欢

【MySQL从入门到精通】【高级篇】(七)设计一个索引&InnoDB中的索引方案

Software testing interview ideas, skills and methods to share, learn is to earn

setup中的props和context

开发者必看 | DevWeekly 第1期:什么是时间复杂度?
![[C language] file operation](/img/d3/5e5ce369dd3315089b529cf69b36c0.png)
[C language] file operation

La fosse Piétinée par l'homme vous dit d'éviter les 10 erreurs courantes dans les tests automatisés
![[try to hack] awvs installation and simple use](/img/58/4259e35a04e9435873ed984f884761.png)
[try to hack] awvs installation and simple use

. net to develop cloud native applications, you only need to add oil to yourself

Props and context in setup

C语言实战之猜数游戏
随机推荐
Amplitude limiting and deblocking filtering of botu PLC signal processing series
我是新手,听说开户有保本的理财产品,是什么?
Emmet 语法简结
一文带你了解如何用SQL处理周报数据
【C语言】文件操作
Solve the greatest common divisor and the least common multiple
网站建设开始前要考虑的7个问题
2302. Count the number of subarrays with a score less than k - sliding array - double hundred code
727. 最小窗口子序列 滑动窗口
PyG利用MessagePassing搭建GCN实现节点分类
FasterRCNN示例代码测试1:令anchor_generator = None
【无标题】
【管理篇 / 升级】* 02. 查看升级路径 * FortiGate 防火墙
2022.7.22-----leetcode.757
小白股票开户安全吗?网上可以办理吗?
[wechat applet] Introduction to development (2)
砥砺前行新征程,城链科技狂欢庆典在厦门隆重举行
教育机器人对学生学习效果的实际影响
推荐系统专题 | 推荐系统架构与单域跨域召回模型
rust allow dead_code