package com.ningdatech.carapi.driver.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.driver.manage.DriverScoreRecordManage;
import com.ningdatech.carapi.driver.model.po.ReqScoreBonusPO;
import com.ningdatech.carapi.driver.model.po.ReqScoreListPO;
import com.ningdatech.carapi.driver.model.vo.ResDriverScoreRecordListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Liuxinxin
 * @since 2022-10-27
 */
@Controller
@RequestMapping("/api/v1/score")
@RestController
@Api(tags = "驾驶员分数记录列表")
@Validated
@RequiredArgsConstructor
public class DriverScoreRecordController {

    private final DriverScoreRecordManage driverScoreRecordManage;

    @PostMapping("/list")
    @ApiOperation("驾驶员分数记录")
    public List<ResDriverScoreRecordListVO> list() {
        return driverScoreRecordManage.list();
    }

    @PostMapping("/page-list")
    @ApiOperation("驾驶员分页分数记录")
    public PageVo<ResDriverScoreRecordListVO> pageList(@Valid @RequestBody ReqScoreListPO request) {
        return driverScoreRecordManage.pageList(request);
    }

    @PostMapping("/score/{driverId}")
    @ApiOperation("获取驾驶员分数")
    public Integer getScore(@PathVariable("driverId") Long driverId) {
        return driverScoreRecordManage.getScore(driverId);
    }

    @PostMapping("/score/bonus")
    @ApiOperation("培训奖励分数")
    public void bonus(@Valid @RequestBody ReqScoreBonusPO request) {
        driverScoreRecordManage.bonus(request);
    }
}
