package com.pollex.pam.aop.logging.audit.strategy; import com.google.gson.Gson; import com.pollex.pam.aop.logging.audit.AuditLoggingType; import com.pollex.pam.domain.AuditLogging; import com.pollex.pam.repository.AuditLoggingRepository; import com.pollex.pam.web.rest.vm.VerifyOtpVM; import org.aspectj.lang.ProceedingJoinPoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import static com.pollex.pam.aop.logging.audit.AuditLoggingType.CUSTOMER_LOGIN; @Component @Transactional public class LoggingCustomerLoginStrategy implements AuditLoggingStrategy{ @Autowired AuditLoggingRepository auditLoggingRepository; @Override public AuditLoggingType getType() { return CUSTOMER_LOGIN; } @Override public void auditLogging(ProceedingJoinPoint joinPoint) { VerifyOtpVM verifyOtpVM = (VerifyOtpVM) joinPoint.getArgs()[0]; AuditLogging logging = new AuditLogging(); logging.setContent(new Gson().toJson(verifyOtpVM)); logging.setFunctionalType(getType()); logging.setCreatedBy(verifyOtpVM.getAccount()); auditLoggingRepository.save(logging); } }