Compare commits

..

4 Commits

Author SHA1 Message Date
e4a11a8a53 Merge branch 'main' into personal/heshunme/news 2024-07-03 14:14:06 +08:00
fc2c97b502 bugfix@JwtVerify 2024-07-03 14:13:20 +08:00
a532eaa89c 尝试@JwtVerify的新用法 2024-07-03 14:13:05 +08:00
c4f0b2348f bugfix@JwtVerify 2024-07-03 14:12:42 +08:00
2 changed files with 3 additions and 3 deletions

View File

@ -38,7 +38,7 @@ public class NewsController {
@PutMapping("/{id}") @PutMapping("/{id}")
@JwtVerify @JwtVerify
public ResponseEntity<MessageResponse> updateNews(@RequestBody NewsRequest request, @PathVariable Long id) { public ResponseEntity<MessageResponse> updateNews(@PathVariable Long id, @RequestBody NewsRequest request) {
try { try {
newsService.updateNews(id, request); newsService.updateNews(id, request);
} catch (DataIntegrityViolationException e) { } catch (DataIntegrityViolationException e) {

View File

@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
@Aspect @Aspect
@Component @Component
public class JwtVerifyAspect { public class JwtVerifyAspect {
@Before("@annotation(JwtVerify)") @Before("@annotation(JwtVerify)&&args(..)")
public void verifyJwtToken(JoinPoint joinPoint) throws JwtValidationException { public void verifyJwtToken(JoinPoint joinPoint) throws JwtValidationException {
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
for (Object arg : args) { for (Object arg : args) {
@ -17,9 +17,9 @@ public class JwtVerifyAspect {
if (!JwtUtil.isTokenValid(token)) { if (!JwtUtil.isTokenValid(token)) {
throw new JwtValidationException("JWT token is invalid"); throw new JwtValidationException("JWT token is invalid");
} }
}
break; break;
} }
} }
}
} }