Quick Start - Access Control
2023-09-10
This section will introduce how to restrict interface access through annotations and learn related parameters for more precise control.
Step 1: Add Maven Dependency#
Step 2: Add Annotations to Controller#
Annotations can be added to the entire Controller or to individual functions within the Controller. If the access exceeds the limit, an AccessIsRestrictedException
will be thrown.
Other Examples#
Use Case 1: Determine Whether to Record the Operation Based on the Return Value#
Record the operation only when "success" is returned; do not record the operation when other content is returned, and do not restrict access.
Use Case 2: Different Operation Records for the Same Interface with Different Parameters#
Different access restrictions for different parameters passed (for example, wanting to restrict each resource to be liked only N times within a specified time period).
Or you can use the predefined DiffParameterSign
strategy to achieve the same effect.