Joke Collection Website - Public benefit messages - Policy mode-SMS template business scenario

Policy mode-SMS template business scenario

This paper mainly introduces the policy mode, and only focuses on the handling of rejection policy logic when sending short messages, so irrelevant codes are not introduced.

Implementation categories of three refusal policies

SMS template is in the configuration file

Unit test class

Change the rejection policy. When sending a short message, the log is as follows:

It can be seen that when the rejection policy is SmsSendAnyMatchStrategy, as long as the placeholders in the participating SMS templates match, it can be sent successfully.

When the placeholder parameter completely matches the template placeholder, the transmission is successful.

Code example: /li-cube/share/tree/master/sms.

After all, business logic is if-else. Using design pattern can make the code easier to maintain and expand, and the code is more readable. Although business can be realized without design patterns, only a few more layers of if-else are added, people always have something to pursue when they are alive. Only by doing things other than business and code can they become programmers who break away from low-level CRUD.