@@ -43,33 +43,29 @@ class ResubmitAspect extends AbstractAspect
4343 */
4444 public function process (ProceedingJoinPoint $ proceedingJoinPoint )
4545 {
46- try {
47- /* @var $resubmit Resubmit */
48- if (isset ($ proceedingJoinPoint ->getAnnotationMetadata ()->method [Resubmit::class])) {
49- $ resubmit = $ proceedingJoinPoint ->getAnnotationMetadata ()->method [Resubmit::class];
50- }
51-
52- $ request = container ()->get (MineRequest::class);
46+ /* @var $resubmit Resubmit */
47+ if (isset ($ proceedingJoinPoint ->getAnnotationMetadata ()->method [Resubmit::class])) {
48+ $ resubmit = $ proceedingJoinPoint ->getAnnotationMetadata ()->method [Resubmit::class];
49+ }
5350
54- $ key = md5 ( sprintf ( ' %s-%s-%s ' , $ request -> ip (), $ request -> getPathInfo (), $ request -> getMethod ()) );
51+ $ request = container ()-> get (MineRequest::class );
5552
56- $ lockRedis = new MineLockRedis (
57- make (Redis::class),
58- make (LoggerFactory::class)->get ('Mine Redis Lock ' )
59- );
60- $ lockRedis ->setTypeName ('resubmit ' );
53+ $ key = md5 (sprintf ('%s-%s-%s ' , $ request ->ip (), $ request ->getPathInfo (), $ request ->getMethod ()));
6154
62- if ($ lockRedis ->check ($ key )) {
63- $ lockRedis = null ;
64- throw new NormalStatusException ($ resubmit ->message ?: t ('mineadmin.resubmit ' ), 500 );
65- }
55+ $ lockRedis = new MineLockRedis (
56+ make (Redis::class),
57+ make (LoggerFactory::class)->get ('Mine Redis Lock ' )
58+ );
59+ $ lockRedis ->setTypeName ('resubmit ' );
6660
67- $ lockRedis ->lock ($ key, $ resubmit -> second );
61+ if ( $ lockRedis ->check ($ key)) {
6862 $ lockRedis = null ;
69-
70- return $ proceedingJoinPoint ->process ();
71- } catch (\Throwable $ e ) {
72- throw new MineException ($ e ->getMessage (), $ e ->getCode ());
63+ throw new NormalStatusException ($ resubmit ->message ?: t ('mineadmin.resubmit ' ), 500 );
7364 }
65+
66+ $ lockRedis ->lock ($ key , $ resubmit ->second );
67+ $ lockRedis = null ;
68+
69+ return $ proceedingJoinPoint ->process ();
7470 }
7571}
0 commit comments