package com.centreproject.web.controller.kpi;

import com.centreproject.common.constant.KeyConstants;
import com.centreproject.common.core.domain.R;
import com.centreproject.system.domain.vo.RevenueTrackingVo;
import com.centreproject.system.domain.vo.VisitorSegmentationVo;
import com.centreproject.system.service.revenueAttendance.IKpiRevenueAttendanceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Revenue & Attendance Management
 * @author zhonglei.xu
 */
@Tag(name = "kpi_revenue_attendance")
@RestController
@RequestMapping("/kpi/revenue_attendance")
public class RevenueAttendanceController {
    @Resource
    private IKpiRevenueAttendanceService revenueAttendanceService;
    /**
     *  Revenue Tracking last 60 days kpi
     */
    @GetMapping("/Revenue_Tracking")
    @Operation(summary = "Revenue Tracking")
    public R<RevenueTrackingVo> getRevenueTracking() {
        RevenueTrackingVo result=revenueAttendanceService.getRevenueTracking();
        if(ObjectUtils.isEmpty(result)){
            R.ok(null, KeyConstants.REVENUE_TRACKING);
        }
        return R.ok(result, KeyConstants.REVENUE_TRACKING);
    }

    /**
     * Attendance & Visitor Segmentation last 60 days kpi
     */
    @GetMapping("/Visitor_Segmentation")
    @Operation(summary = "Visitor Segmentation")
    public R<VisitorSegmentationVo> getVisitorSegmentation() {
        VisitorSegmentationVo result=revenueAttendanceService.getVisitorSegmentation();
        if(ObjectUtils.isEmpty(result)){
            R.ok(null, KeyConstants.ATTENDANCE_VISITOR_SEGMENTATION);
        }
        return R.ok(result, KeyConstants.ATTENDANCE_VISITOR_SEGMENTATION);
    }

}
