A solution for a variable text content replacement

According to different business types, different SMS messages are sent, and the content of the SMS contains replaceable elements, such as customer name and phone number, etc. The template is not fixed

To prevent repetitive processing of this messy logic at the code level, it can be controlled in the database

For example, create a new table: t_model_field (template field replacement table)

Field: modelNo template number, fieldName needs to replace field name, SQL script statement;

For example, business A wants to send a type B short message, and the content of the short message contains variable fields: customer name, phone number, and event number.

Three records can be added to t_model_field

insert into  t_model_field( modelNo, fieldName, SQL ) values ​​('Type1121','[customer name]', script to query customer name);

insert into  t_model_field( modelNo, fieldName, SQL ) values ​​('Type1121','[ Phone ]', the script to query the phone ); <!--EndFragment-->

insert into  t_model_field( modelNo, fieldName, SQL ) values ​​('Type1121','[ event number ]', script to query event number ); <!--EndFragment-->

 

If business type A wants to send another type of C-type short message, there are 4 variable fields, and it is enough to insert four records in the same way.

 

Then by writing a unified set of code in the background, this complex requirement can be realized

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326396450&siteId=291194637