package com.crm.activity.controller.custom;

import com.crm.activity.service.ActivityRaceRankingService;
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.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("/custom/service/activity/race/ranking")
public class ActivityRaceRankingCsController {

    @Autowired
    private ActivityRaceRankingService activityRaceRankingService;

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

    @PostMapping("/search/list/cover")
    public BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>> searchListCover(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
        entity.setHide(true);
        return activityRaceRankingService.searchProfitCoverList(entity);
    }

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

    @PostMapping("/search/my")
    public BaseResultDto<ActivityRaceRankingDto> searchMy(@RequestBody ActivityRaceRankingMyEntity entity) throws Exception {
        return BaseResultDto.success(activityRaceRankingService.searchCustomRankingInfo(entity));
    }

}
