I want to create a custom annotation (method scoped) that will insert in database. This annotation will be attached to every method in my rest controller so that when an api call is made, the annotation saves the action made in a track-user table in database
so far i created the annotation interface, i think i need to add a method that saves the action&author in the track-user table but i don't know where or how:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ActionLog {
String action() default "UNDEFINED";
String author() default "UNDEFINED";
}
I want to use it like that:
@ActionLog(author="John",action="get all users")
public List<User> getAllUsers() { return repo.findAll(); }
Then in my database i should have a new insert of the action with its author