package com.ffii.fhsmsc.modules.user.web;

import java.util.Map;

import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ffii.core.response.RecordsRes;
import com.ffii.core.utils.CriteriaArgsBuilder;
import com.ffii.fhsmsc.modules.common.service.AuditLogService;

import jakarta.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/auditLog")
public class AuditLogController{

    private AuditLogService auditLogService;
	
    public AuditLogController(AuditLogService auditLogService) {
		this.auditLogService = auditLogService;
	}
    
	@GetMapping
	public RecordsRes<Map<String, Object>> list(HttpServletRequest request) throws ServletRequestBindingException {
		return new RecordsRes<>(auditLogService.arsSearch(
				CriteriaArgsBuilder.withRequest(request)
						.addInteger("modifiedBy")
						.addString("tableName")
						.addStringLike("recordName")
						.addDate("fromDate")
						.addDateTo("toDate")
						.build()));
	}

}
