package com.eactive.eai.rms.common.acl.audit.adapter.in.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.eactive.eai.rms.common.acl.audit.domain.AuditLog;
import com.eactive.eai.rms.common.acl.audit.port.in.SelectDetailAuditLogUseCase;

import lombok.RequiredArgsConstructor;

@Controller
@RequiredArgsConstructor
class AuditLogManDetailController {

	private final SelectDetailAuditLogUseCase selectDetailAuditLogUseCase;

	private final AuditLogManMapper auditLogManDetailUIMapper;

	@GetMapping(value = "/common/acl/audit/auditLogMan.view", params = "cmd=DETAIL")
	public String viewDetail(HttpServletRequest request) {
		return "/common/acl/audit/auditLogManDetail";
	}

	@PostMapping(value = "/common/acl/audit/auditLogMan.json", params = "cmd=DETAIL")
	public ResponseEntity<AuditLogManDetailUI> selectDetail(@RequestParam("logSeqNo") Long id) {
		AuditLog auditLog = selectDetailAuditLogUseCase.selectDetail(id);
		AuditLogManDetailUI auditLogManDetailUI = auditLogManDetailUIMapper.toUi(auditLog);
		return ResponseEntity.ok(auditLogManDetailUI);
	}

}
