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.socialMedia.GoogleReviewsPost;
import com.centreproject.system.domain.vo.SocialVo;
import com.centreproject.system.service.guestExperience.IKpiGoogleReviewsPostService;
import com.centreproject.system.service.guestExperience.IKpiSocialMediaSentimentalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
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;

/**
 * Social Media Sentimental Analysis query last 60 days data
 * @author zhonglei.xu
 */
@Tag(name = "kpi_social_media_sentimental_analysis")
@RestController
@RequestMapping("/kpi/social-media")
public class SocialMediaController {

    @Resource
    private IKpiSocialMediaSentimentalService socialMediaSentimentalService;
    @Resource
    private IKpiGoogleReviewsPostService googleReviewsPostService;

    /**
     * Social Media Sentimental Analysis
     * @return Social Media Sentimental Analysis
     */
    @GetMapping("/analysis")
    @Operation(summary = "analysis")
    public R<SocialVo> getAnalysis() {
        SocialVo result= socialMediaSentimentalService.getAnalysis();
        return R.ok(result, KeyConstants.SOCIAL_MEDIA_SENTIMENTAL);
    }

    /**
     *
     * GoogleReviewsPost
     * @return GoogleReviewsPost
     */
    @GetMapping("/googleReviewsPost")
    @Operation(summary = "GoogleReviewsPost")
    public R<List<GoogleReviewsPost>> getGoogleReviewsPost() {
        List<GoogleReviewsPost> results=googleReviewsPostService.getGoogleReviewsPost();
        return R.ok(results, KeyConstants.GOOGLE_REVIEWS);
    }

    /**
     *
     * todo ： 需要确认词云的数据格式
     * World Cloud
     * @Param type : Google Evaluation Word Cloud/TripAdvisor Evaluation Word Cloud
     * @return World Cloud
     */
    @GetMapping("/worldCloud/{type}")
    @Operation(summary = "worldCloud")
    public R<String> getWorldCloud(@PathVariable("type") String type) {
        String worldCloud=socialMediaSentimentalService.getWorldCloud(type);
        return R.ok(worldCloud, KeyConstants.WORLD_CLOUD);
    }
}
