package com.centreproject.web.controller.kpi;

import com.centreproject.common.constant.KeyConstants;
import com.centreproject.common.core.domain.R;
import com.centreproject.system.domain.kpi.guestExperience.KpiJourneyTouchPoint;
import com.centreproject.system.domain.kpi.guestExperience.KpiParkGuestExperience;
import com.centreproject.system.domain.kpi.guestExperience.KpiVisitorCountryBreakdown;
import com.centreproject.system.domain.kpi.guestExperience.KpiYasIslandCampaigns;
import com.centreproject.system.domain.vo.KpiTransportVo;
import com.centreproject.system.service.guestExperience.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Guest Experience Management
 * @author zhonglei.xu
 */
@Tag(name = "kpi_guest_experience")
@RestController
@RequestMapping("/kpi/guest_experience")
public class GuestExperienceController {
    @Resource
    private IKpiYasIslandCampaignsService campaignsService;
    @Resource
    private IKpiJourneyTouchPointService journeyTouchPointService;
    @Resource
    private IKpiParkGuestExperienceService parkGuestExperienceService;
    @Resource
    private IKpiVisitorCountryBreakdownService kpiGuestExperienceService;
    @Resource
    private IKpiTransportService transportService;

    /**
     * Yas_Island_Campaigns last 60 days
     * @return Yas_Island_Campaigns
     */
    @GetMapping("/Yas_Island_Campaigns")
    @Operation(summary = "Yas_Island_Campaigns")
    public R<KpiYasIslandCampaigns> getYasIslandCampaigns() {
        KpiYasIslandCampaigns result=campaignsService.getYasIslandCampaigns();
        if(ObjectUtils.isEmpty(result)){
            R.ok(null, KeyConstants.YAS_ISLAND_CAMPAIGNS);
        }
        return R.ok(result, KeyConstants.YAS_ISLAND_CAMPAIGNS);
    }


    /**
     * Journey_Touch_Point last 60 days
     * @return Journey_Touch_Point
     */
    @GetMapping("/Journey_Touch_Point/{parkCode}")
    @Operation(summary = "Journey_Touch_Point")
    public R<List<KpiJourneyTouchPoint>> getJourneyTouchPoint(@PathVariable("parkCode") String parkCode) {
        List<KpiJourneyTouchPoint> result=journeyTouchPointService.getJourneyTouchPoint(parkCode);
        if(CollectionUtils.isEmpty(result)){
            R.ok(null, KeyConstants.JOURNEY_TOUCH_POINT);
        }
        return R.ok(result, KeyConstants.JOURNEY_TOUCH_POINT);
    }

    /**
     * Happiness_Meters last 60 days
     * @return Happiness_Meters
     */
    @GetMapping("/Happiness_Meters/{park_code}")
    @Operation(summary = "Happiness_Meters")
    public R<List<KpiParkGuestExperience>> getHappinessMeters(@PathVariable("park_code") String parkCode) {
        List<KpiParkGuestExperience> result=parkGuestExperienceService.getHappinessMeters(parkCode);
        if(CollectionUtils.isEmpty(result)){
            R.ok(null, KeyConstants.HAPPINESS_METERS);
        }
        return R.ok(result, KeyConstants.HAPPINESS_METERS);
    }


    /**
     * Queue Time last 60 days
     * @return Queue Time
     */
    @GetMapping("/Queue_Time/{park_code}")
    @Operation(summary = "Queue_Time")
    public R<List<KpiParkGuestExperience>> getQueueTime(@PathVariable("park_code") String parkCode) {
        List<KpiParkGuestExperience> result=parkGuestExperienceService.getQueueTime(parkCode);
        if(CollectionUtils.isEmpty(result)){
            R.ok(null, KeyConstants.QUEUE_TIME);
        }
        return R.ok(result, KeyConstants.QUEUE_TIME);
    }

    /**
     *  Visitor_Breakdown_By_Country_Of_Residence last 60 days
     * @return Visitor_Breakdown_By_Country_Of_Residence Time
     */
    @GetMapping("/Visitor_Breakdown_By_Country_Of_Residence")
    @Operation(summary = "Visitor_Breakdown_By_Country_Of_Residence")
    public R<List<KpiVisitorCountryBreakdown>> getVisitorBreakdownByCountryOfResidence() {
        List<KpiVisitorCountryBreakdown> result=kpiGuestExperienceService.getVisitorBreakdownByCountryOfResidence();
        if(CollectionUtils.isEmpty(result)){
            R.ok(null, KeyConstants.VISITOR_BREAKDOWN_BY_COUNTRY_OF_RESIDENCE);
        }
        return R.ok(result, KeyConstants.VISITOR_BREAKDOWN_BY_COUNTRY_OF_RESIDENCE);
    }

    /**
     *  transport kpi  last 60 days
     * @return transport kpi  last 60 days
     */
    @GetMapping("/transport")
    @Operation(summary = "transport")
    public R<KpiTransportVo> getTransport() {
        KpiTransportVo result=transportService.getTransport();
        if(ObjectUtils.isEmpty(result)){
            R.ok(null, KeyConstants.TRANSPORT);
        }
        return R.ok(result, KeyConstants.TRANSPORT);
    }

}
