package com.ruoyi.cai.controller.app;

import com.fasterxml.jackson.databind.ser.std.CollectionSerializer;
import com.ruoyi.cai.dto.app.vo.rank.RankNodeLove;
import com.ruoyi.cai.rank.RankManager;
import com.ruoyi.cai.rank.RankNode;
import com.ruoyi.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/api/rank")
@Tag(name = "排行榜接口")
public class RankController {

    @Autowired
    private RankManager rankManager;

    @GetMapping("/love")
    @Operation(summary = "魅力榜")
    public R<List<RankNodeLove>> loveRank(
            @Parameter(description = "类型 1-上周 2-昨日 3-日榜 4-周榜 5-月榜 6-总榜") Integer type){
        if(type == null){
            return R.ok(Collections.emptyList());
        }
        List<RankNode> rankNodeList = null;
        if(type == 1){
            rankNodeList = rankManager.getLoveRankDayLastWeek(10);
        }else if(type == 2){
            rankNodeList = rankManager.getLoveRankDayLastDay(10);
        }else if(type == 3){
            rankNodeList = rankManager.getLoveRankDayToday(30);
        }else if(type == 4){
            rankNodeList = rankManager.getLoveRankDayWeek(30);
        }else if(type == 5){
            rankNodeList = rankManager.getLoveRankDayMonth(30);
        }else if(type == 6){
            rankNodeList = rankManager.getLoveRankTotal(30);
        }else{
            rankNodeList = Collections.emptyList();
        }

        return R.ok();
    }
}
