Commit bd14e7b3 by 涂亚平

拦截器先验证时间

1 parent 858a7caf
...@@ -57,6 +57,16 @@ public class AuthenticationInterceptor implements HandlerInterceptor { ...@@ -57,6 +57,16 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod(); Method method = handlerMethod.getMethod();
TimeRequired timeRequired = method.getAnnotation(TimeRequired.class);
if (timeRequired !=null){
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour<6){
throw new HttpException(17001);
}
}
LoginRequired methodAnnotation = method.getAnnotation(LoginRequired.class); LoginRequired methodAnnotation = method.getAnnotation(LoginRequired.class);
if (methodAnnotation != null) { if (methodAnnotation != null) {
String authorization = request.getHeader("Authorization"); String authorization = request.getHeader("Authorization");
...@@ -102,14 +112,7 @@ public class AuthenticationInterceptor implements HandlerInterceptor { ...@@ -102,14 +112,7 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
throw new HttpException(1010); throw new HttpException(1010);
} }
TimeRequired timeRequired = method.getAnnotation(TimeRequired.class);
if (timeRequired !=null){
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour<6){
throw new HttpException(17001);
}
}
return true; return true;
} }
......
...@@ -63,14 +63,12 @@ public class MemberController { ...@@ -63,14 +63,12 @@ public class MemberController {
@PostMapping(value = "/login") @PostMapping(value = "/login")
@ApiOperation("手机端:登录:telephone/手机号, verifyCode/验证码") @ApiOperation("手机端:登录:telephone/手机号, verifyCode/验证码")
@TimeRequired
public ResponseVO login(@RequestBody VerifyCodeDTO verifyCodeDTO) { public ResponseVO login(@RequestBody VerifyCodeDTO verifyCodeDTO) {
return ResponseData.generateCreatedResponse(0, memberService.login(verifyCodeDTO)); return ResponseData.generateCreatedResponse(0, memberService.login(verifyCodeDTO));
} }
@PostMapping("passwordLogin") @PostMapping("passwordLogin")
@ApiOperation("手机端:密码登录 { companyId accountName password}") @ApiOperation("手机端:密码登录 { companyId accountName password}")
@TimeRequired
public ResponseVO passwordLogin(@RequestBody PasswordLoginDTO passwordLoginDTO){ public ResponseVO passwordLogin(@RequestBody PasswordLoginDTO passwordLoginDTO){
return ResponseData.generateCreatedResponse(0,memberService.passwordLogin(passwordLoginDTO)); return ResponseData.generateCreatedResponse(0,memberService.passwordLogin(passwordLoginDTO));
} }
...@@ -89,7 +87,6 @@ public class MemberController { ...@@ -89,7 +87,6 @@ public class MemberController {
return ResponseData.generateCreatedResponse(0,memberService.kunchiLogin(qingxuetangLoginDTO)); return ResponseData.generateCreatedResponse(0,memberService.kunchiLogin(qingxuetangLoginDTO));
} }
@PostMapping("updatePassword") @PostMapping("updatePassword")
@ApiOperation("修改密码 {id password}") @ApiOperation("修改密码 {id password}")
@LoginRequired @LoginRequired
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!