package com.crm.custom.controller;

import com.crm.custom.service.activity.ActivityRaceRankingFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.login.InfoEntity;
import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingProfitCoverDto;
import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingMyEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 比赛排名api
 *
 * @author y
 * @create 2022/7/21
 */
@RestController
@RequestMapping("/activity/race/ranking")
public class ActivityRaceRankingController {

    @Autowired
    private ActivityRaceRankingFeignService activityRaceRankingFeignService;

//    @PostMapping("/search/list")
//    public BaseResultWithPagerDto<List<ActivityRaceRankingDto>>
//    searchList(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
//        return activityRaceRankingFeignService.searchList(entity);
//    }

    @PostMapping("/search/list")
    public BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>>
    searchList(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
        return activityRaceRankingFeignService.searchListCover(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto<ActivityRaceRankingDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
        return activityRaceRankingFeignService.searchSingle(entity);
    }

    @PostMapping("/search/my")
    public BaseResultDto<ActivityRaceRankingDto> searchMy(@RequestBody ActivityRaceRankingMyEntity entity, InfoEntity infoEntity) throws Exception {
        entity.setCustomId(infoEntity.getId());
        return activityRaceRankingFeignService.searchMy(entity);
    }

}
