スプリングブートにアノテーションを実装したい。パス変数を取得してアノテーションで使用するために必要です。
@PostMapping("/v1/{id}")
@HasZone(id = "#id")
@ResponseStatus(HttpStatus.NO_CONTENT)
fun createCompany( @PathVariable id: String) {
....
}
@Target(AnnotationTarget.FUNCTION)
annotation class HasZone(vararg val id: String)
@Before("@annotation(hasZone)")
fun checkZonePermissions(hasZone: HasZone) {
println(hasZone.id)
}
次のようにPreAuthorizeでパラメータを取得します: #id. ただし、この関数では、変数パスの名前を文字列として機能させます。
間違ったことをするのはどこですか?どうすれば問題を解決できますか?