package com.its.web.controller.common;

import com.its.web.dto.common.ConnStatisticsDto;
import com.its.web.dto.common.TbWwwOrgDto;
import com.its.web.service.common.CommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/common")
@Api(tags = "00.공통")
public class CommonController {

    private final CommonService service;

    @ApiOperation(value = "공공기관 웹사이트 조회(TB_WWW_ORGAN)", response = TbWwwOrgDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "/web-organ", produces = {"application/json; charset=utf8"})
    @ResponseBody
    public List<TbWwwOrgDto> findAllOrganization() { return this.service.findAllOrganization(); }

    @ApiOperation(value = "접속자 통계(TB_WWW_CONN_HS)", response = ConnStatisticsDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "/conn-statistics", produces = {"application/json; charset=utf8"})
    @ResponseBody
    public List<ConnStatisticsDto> getConnStatistics(@Nullable @RequestParam Map<String, String> paramMap) {return this.service.getConnStatistics(paramMap);}

}
