Skip to content

Permission Control @Power ​

The @Power annotation gives fine-grained control over which CRUD operations are enabled on an Erupt UI — add, delete, edit, query, import, and export.

Controls the capabilities of an Erupt class: add, edit, delete, import, export, and more.

Usage ​

java
@Erupt(
       name = "Erupt",
       power = @Power(add = true, delete = true, 
                      edit = true, query = true, 
                      importable = false, export = false)
)
public class EruptTest extends BaseModel {
    
}

Attributes ​

AttributeTypeDefaultDescription
addbooleantrueWhether adding data is allowed
deletebooleantrueWhether deleting data is allowed
editbooleantrueWhether editing data is allowed
querybooleantrueWhether querying data is allowed
viewDetailsbooleantrueWhether viewing record details is allowed
exportbooleanfalseWhether exporting data is allowed
importablebooleanfalseWhether importing data is allowed
powerHandlerClass-Implement this interface to control permissions dynamically

Annotation Definition ​

java
public @interface Power {
    boolean add() default true; // add data

    boolean delete() default true; // delete data

    boolean edit() default true; // edit data

    boolean query() default true; // query data

    boolean viewDetails() default true; // view record details

    boolean export() default false; // export data

    boolean importable() default false; // import data

    // implement this interface to control permissions dynamically
    Class<? extends PowerHandler> powerHandler() default PowerHandler.class;
}
java
public interface PowerHandler {

    /**
     * Dynamically control feature permissions
     * @param power  a simple POJO representing add/delete/edit/query capabilities
     */
    void handler(PowerObject power);

}

Notes ​

When a user accesses the page, both menu permissions and annotation values are checked. If a feature is enabled in @Power but still not visible, verify that the corresponding menu permission is complete — any missing permissions must be added manually.

Contributors

The avatar of contributor named as YuePeng YuePeng

Changelog

Released under the Apache-2.0 License.