package kr.co.accura.wbx.spring.audit;

import kr.co.accura.wbx.spring.common.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class AuditLogService {

    private final AuditLogRepository repository;

    public void log(String action, String resource, Long resourceId, String detail) {
        repository.save(WbxAuditLog.builder()
                .userId(SecurityUtils.getCurrentUserId())
                .username(SecurityUtils.getCurrentUsername())
                .action(action)
                .resource(resource)
                .resourceId(resourceId)
                .detail(detail)
                .build());
    }
}
