配置筛选机

在文章中,比较多的灵感来源于筛选谷物花生,筛选机等筛选机的结构

比较多的开发工作中,涉及业务分支和同一业务不同逻辑的,会比较适合下面模型:从大到小(漏斗结构) 或从小到大(倒漏斗结构) 或一次性选择(选择维度,获取维度参数)

 维度:可以统一看成一个关键的参数或者多个参数组成的参数

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;
    }

以上文章读懂不是很简单也不是很难;能够理解对于开发会是非常便捷的,不仅能优化别人同时也能优化自己(毕竟在实际项目中运用)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安恒堡垒机是一种基于堡垒原理的网络安全设备,用于对服务器进行远程管理和安全监控。配置syslog样本可以帮助我们实现日志的收集和分析,以便及时发现和应对安全事件。 首先,我们需要登录到安恒堡垒机的管理界面。在“系统配置”菜单下,点击“日志管理”选项。 接下来,我们需要创建一个syslog样本。点击“新建样本”按钮,在弹出的窗口中填写配置信息。首先,在“样本名称”栏中填写样本的名称,例如“服务器日志”。 然后,在“远程IP地址”栏中填写用于接收日志的远程服务器的IP地址。确保远程服务器已经启用syslog服务,并且开放了相应的接收端口。 接着,选择日志级别。安恒堡垒机支持不同的日志级别,包括 DEBUG、INFO、WARN、ERROR 和 ALERT 等。根据需求,选择适当的级别,一般建议选择INFO级别。 在“日志样本”栏中,我们可以定义需要收集的日志内容。安恒堡垒机提供了多种内置的日志样本模板,包括系统命令、操作文件、登录记录和审计日志等。可以根据需要勾选相应的样本内容进行收集。 最后,点击“确定”按钮保存样本配置。此时,安恒堡垒机会根据样本配置开始收集远程服务器的syslog日志。 在完成样本配置后,我们可以通过点击“查看日志”按钮来查看收集到的日志内容。在弹出的窗口中,可以筛选特定的时间段和日志级别,方便我们进行日志分析和排查。 总之,通过配置syslog样本,安恒堡垒机可以方便地收集和分析服务器的日志,为网络安全管理提供重要支持。同时,通过合理的样本配置,可以实现对关键日志内容的集中管理和监控。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值