当前位置:网站首页>配置筛选机
配置筛选机
2022-07-01 21:45:00 【haohaounique】
在文章中,比较多的灵感来源于筛选谷物花生,筛选机等筛选机的结构
比较多的开发工作中,涉及业务分支和同一业务不同逻辑的,会比较适合下面模型:从大到小(漏斗结构) 或从小到大(倒漏斗结构) 或一次性选择(选择维度,获取维度参数)
维度:可以统一看成一个关键的参数或者多个参数组成的参数
1.基于A维度下,做选择或者在维度下设计维度参数
2.不做维度配置,但根据维度来做相同业务逻辑的不同操作
具体表设计如下:
配置同一业务的顶级类-->具体业务类--->获取具体的处理模型--->获取具体的参数表达式
create table check_expression
(
id int auto_increment
primary key,
business_type varchar(20) null comment '业务类型',
check_model varchar(20) null comment '校验模型',
check_expression text null comment '表达式',
check_expression_name varchar(200) null comment '表达式名称',
status tinyint default 1 null comment '0-失效 1-生效',
create_time datetime null comment '创建时间',
create_by varchar(60) null comment '创建人',
update_time datetime null comment '更新时间',
update_by varchar(60) null comment '更新建人'
)
comment '校验表达式';
create table check_config
(
id int auto_increment
primary key,
business_key varchar(100) null comment '业务key',
business_type varchar(20) null comment '业务类型',
business_name varchar(100) null comment '业务名称',
check_word varchar(100) null comment '校验关键字',
check_word_name varchar(100) null comment '校验关键字名称',
check_model varchar(20) null comment '校验模型',
check_model_name varchar(200) null comment '校验模型名称',
check_class varchar(500) null comment '业务类',
check_expression text null comment '校验表达式',
check_order tinyint default 1 null comment '校验顺序',
check_msg text null comment '提示语',
status tinyint default 1 null comment '0-无效 1-生效',
fresh_status tinyint default 0 null comment '0-未刷新 1-刷新中,2-已刷新',
try_times tinyint default 0 null comment '刷新次数,线程池处理',
fresh_time datetime default CURRENT_TIMESTAMP null comment '上次刷新时间',
create_time datetime null comment '创建时间',
create_by varchar(60) not null comment '创建人',
update_time datetime null comment '更新时间',
update_by varchar(60) null comment '更新建人'
)
comment '校验配置' auto_increment = 9;
create index id_business_key
on check_config (business_key);
create index id_business_type
on check_config (business_type);
create index id_check_model
on check_config (check_model);
create index id_create_by
on check_config (create_by);
create index id_fresh_status
on check_config (fresh_status);
create index id_status
on check_config (status);
create table business_class
(
id int auto_increment
primary key,
business_type varchar(20) null comment '001-校验',
business_model varchar(20) null comment '业务模型',
business_name varchar(200) null comment '业务名称',
business_class varchar(500) null comment '业务类',
status tinyint default 1 null comment '生效状态',
create_time datetime null comment '创建时间',
create_by varchar(60) null comment '创建人',
update_time datetime null comment '更新时间',
update_by varchar(60) null comment '更新建人'
)
comment '业务配置类' auto_increment = 9;
create index id_business_model
on business_class (business_model);
create index id_business_type
on business_class (business_type);
create index id_status
on business_class (status);
核心代码(此处仅展示配置化校验代码):
思想:第一步获取核心配置
第二步:根据配置做业务处理
List<CheckConfig> checkList = checkConfigService.getCheckList(map, map.get("business_key")); boolean checkResult = checkConfigService.checkConfigList(checkList, map);
public boolean checkConfigList(List<CheckConfig> checkList, Map<String, String> map) {
if (CollectionUtils.isNotEmpty(checkList)) {
for (CheckConfig checkConfig : checkList) {
ICheckService checkService = CACHE_CHECK_CLASS.getIfPresent(checkConfig.getCheckClass());
if (checkService == null) {
checkService = SpringBeanUtils.getBeanByName(checkConfig.getCheckClass(), ICheckService.class);
if (checkService == null) {
throw new BusinessException(500, CommonUtils.getStringBuilder().append("checkConfigList bean未配置:").append(checkConfig.getCheckClass()).toString());
}
CACHE_CHECK_CLASS.put(checkConfig.getCheckClass(), checkService);
}
boolean param = checkService.checkParam(checkConfig, map);
if (param) {
map.put("check_code", CODE_500);
map.put("check_result", Boolean.FALSE.toString());
map.put("check_msg", checkConfig.getCheckMsg());
map.put("remark", CHECK_NOTICE_MSG);
return true;
}
}
}
return false;
}
以上文章读懂不是很简单也不是很难;能够理解对于开发会是非常便捷的,不仅能优化别人同时也能优化自己(毕竟在实际项目中运用)
边栏推荐
- PyTorch磨刀篇|argmax和argmin函数
- Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
- Why must digital transformation strategies include continuous testing?
- require与import的区别和使用
- 黑马程序员-软件测试--06阶段2-linux和数据库-01-08第一章-linux操作系统阶段内容说明,linux命令基本格式以及常见形式的说明,操作系统的常见的分类,查看命令帮助信息方法,
- Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
- 【MySQL】索引的创建、查看和删除
- 辅音和声母的区别?(声母与辅音的区别)
- flink sql-client 使用 对照并熟悉官方文档
- [intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial
猜你喜欢
MySQL learning notes - SQL optimization of optimization
BlocProvider 为什么感觉和 Provider 很相似?
Is PMP certificate really useful?
Recent public ancestor offline practice (tarjan)
Introduction and download of the latest version of airserver2022
从MLPerf谈起:如何引领AI加速器的下一波浪潮
Manually implement function isinstanceof (child, parent)
Go — 相关依赖对应的exe
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
Business visualization - make your flowchart'run'up
随机推荐
Introduction and download of the latest version of airserver2022
Little p weekly Vol.11
leetcode - 287. 寻找重复数
GaussDB(DWS)主动预防排查
对象内存布局
Separate the letters and numbers in the string so that the letters come first and the array comes last
Electron学习(三)之简单交互操作
MQ learning notes
Smart micro mm32 multi-channel adc-dma configuration
【MySQL】数据库优化方法
小 P 周刊 Vol.11
Flume interview questions
Sonic云真机学习总结6 - 1.4.1服务端、agent端部署
Go — 相关依赖对应的exe
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
从零开始学 MySQL —数据库和数据表操作
信标委云原生专题组组长,任重道远!
Copy ‘XXXX‘ to effectively final temp variable
按照功能对Boost库进行分类
[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial