Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the design of sql rule engine?

Shulou Source: shulou.com Published: 2022-06-02 10:08:42 10月04日 Update

This article introduces the knowledge of "what is the design of sql rule engine". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Recently, I used the rule engine to make a simple summary. The rule, to put it bluntly, is, what is the status quo (fact), if (condition), then (action). The rule engine uses the rete algorithm, and I use drools here. In short, I wrap around a core to generate drl files, and the rest are executed by drools.

In order to facilitate the design, the business is uniformly encapsulated with OP (input parameter: param, entity: body, output parameter: res) and executor Exector, so that class can be introduced less. A label table, a rule engine table. There are all kinds of data, variables, instance variables, relational operations, instructions in the tag.

Conditional direct generation

Behavior

Sql padding: give sql to the rules engine. Sql can take parameters, using parameters from the variable library.

$op.setBody

{

"$op.setBody": "select lock_on_active from t_rule_engine where id='$ {id}'"

}

Query array: query sql to get an array.

Executor.sqlList ($op)

{"Executor.sqlList ($op);": "}

Query value: query sql to get the number

Executor.sqlLong ($op)

{"Executor. SqlLong ($op);": "}

Query map: query sql to get map

Executor.sqlMap ($op)

{"Executor. SqlMap ($op);": "}

Query character: query sql to get a string.

Executor.sqlStr ($op)

{"Executor. SqlStr ($op);": "}

Trigger rules: re-execute in the rules file.

Update ($op)

{"update ($op);": "}

Variable copy: put the result of execution into the reference condition.

Executor.paramCopy

{"Executor.paramCopy": ["data", "data1"]} / / assign the value of the query result data to the parameter data1

Variable assignment: assign a constant value to a variable, which can also be a value in the instance variable library.

Executor.let

{"Executor.let": ["data", "cheitemContent"]} / / assign data to cheitemContent in the reference

At present, only "sql fill" and "variable copy" are parameters, and the others are non-parameter actions.

Finally generate the rule file drl

This is the end of the content of "what is the design of the sql rules engine". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Rules queries variables engines designs parameters files generation content characters instances constants arrays more conditions tags knowledge results libraries utility Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Linux Shulou Tech Info vpn