package com.takensoft.cms.mber.web;

import com.takensoft.cms.mber.service.LgnHstryService;
import com.takensoft.common.util.ResponseData;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.nio.charset.Charset;
import java.util.HashMap;

/**
 * @author  : 박정하
 * @since   : 2024.05.24
 *
 * 로그인 이력 관련 컨트롤러
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/lgnHstry")
public class LgnHstryController {
    private final LgnHstryService lgnHstryService;

    /**
     * @author 박정하
     * @since 2024.05.13
     * @param params
     * @return
     * @throws Exception
     *
     * 로그인 이력 목록 조회
     */
    @PostMapping("/listProc.json")
    public ResponseEntity<?> listProc(@RequestBody HashMap<String, String> params) throws Exception {
        HashMap<String, Object> result = lgnHstryService.lgnHstryList(params);

        // 응답 처리
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
        ResponseData responseData = new ResponseData();
        responseData.setStatus(HttpStatus.OK);
        responseData.setMessage("정상적으로 조회가 처리되었습니다.");
        responseData.setData(result);
        return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
    }
}