package com.crm.activity.controller.manager;

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.entity.activity.ActivityRaceRankingListEntity;
import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingManualEntity;
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;

/**
 *
 * @author y
 * @create 2022/7/21
 */
@RestController
@RequestMapping("/manager/service/activity/race/ranking")
public class ActivityRaceRankingMsController {

    @Autowired
    private ActivityRaceRankingService activityRaceRankingService;

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

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

    @PostMapping("/update/manual")
    public BaseResultDto<Boolean> updateManual(@RequestBody ActivityRaceRankingManualEntity entity) throws Exception {
        activityRaceRankingService.updateManual(entity);
        return BaseResultDto.success(true);
    }

}
