package org.jeecg.modules.adweb.seo.controller;

import io.swagger.v3.oas.annotations.tags.Tag;

import lombok.extern.slf4j.Slf4j;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
import org.jeecg.modules.adweb.site.entity.AdwebSite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @Description: seo_keywords_rank @Author: jeecg-boot @Date: 2024-10-09 @Version: V1.0
 */
@Tag(name = "seo_keywords_rank")
@RestController
@RequestMapping("/seo/seoKeywordsRank")
@Slf4j
public class SeoKeywordsRankController {
    @Autowired private ISeoKeywordsRankService seoKeywordsRankService;

    /** 获取当前用户管理的 父 站点信息 @CopyFrom: getAllSites */
    @GetMapping("/getAllSites")
    public Result<List<AdwebSite>> getAllSites() {
        final List<AdwebSite> allSites = seoKeywordsRankService.getAllSites();
        return Result.OK(allSites);
    }

    /**
     * 获得综合统计信息
     */
    @GetMapping(value = "/comprehensiveInfo")
    public Result<?> getComprehensiveInfo(@RequestParam String siteCode, @RequestParam String planId) throws ParseException {
        ComprehensiveStatistics statistics = seoKeywordsRankService.getComprehensiveInfo(siteCode, planId);
        return Result.OK(statistics);
    }

    /**
     * 获取关键字排名信息
     */
    @GetMapping(value = "/getRankInfo")
    public Result<?> getRankInfo(@RequestParam("siteCode") String siteCode, @RequestParam("subscriptionId") String subscriptionId) throws ParseException {
        Map map = seoKeywordsRankService.getRankInfo(siteCode, subscriptionId);
        return Result.OK(map);
    }
}
