package com.yuchen.saas.park.service.service.door.communication.impl;

import com.yuchen.saas.park.service.service.door.communication.domain.CallResult;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Slf4j
@Component
public class DoorAccessControlCommandServiceAspect {
    @Around("execution(* com.yuchen.saas.park.service.service.door.communication.DoorAccessControlCommandService.*(..))")
    public Object wrapException(ProceedingJoinPoint o) {
        try {
            return o.proceed(o.getArgs());
        } catch (Throwable e) {
            return CallResult.error(e.getMessage());
        }
    }
}