package com.sckw.fleet.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.core.web.response.HttpResult;
import com.sckw.core.web.response.result.PageDataResult;
import com.sckw.fleet.api.model.dto.DriverScoreQuery;
import com.sckw.fleet.api.model.dto.UpdateDriverScoreDto;
import com.sckw.fleet.model.request.DriverScorerDetailRequest;
import com.sckw.fleet.model.vo.DriverScorerDetailVO;
import com.sckw.fleet.service.KwfDriverScoreService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @Author: tangyishan
 * @CreateTime: 2025-12-11  11:24
 * @Description: 司机评分
 */
@RestController
@RequestMapping("/driverScore")
@Tag(name = "司机评分管理", description = "提供司机评分相关操作接口")
public class KwfDriverScoreController {

    @Autowired
    private KwfDriverScoreService kwfDriverScoreService;

    /**
     * 修改企业评分更新司机评分接口
     */
    @PostMapping("/update")
    public HttpResult update(@Validated @RequestBody UpdateDriverScoreDto updateDriverScoreDto) {
        kwfDriverScoreService.update(updateDriverScoreDto);
        return HttpResult.ok();
    }


    /**
     * @desc 分页查询司机评分明细
     * @author zk
     * @date 2023/7/6
     **/
    @Operation(summary = "分页查询司机评分明细", description = "根据条件分页查询司机评分明细信息")
    @PostMapping("/queryScoreDetailPage")
    public BaseResult<PageDataResult<DriverScorerDetailVO>> queryScoreDetailPage(@Validated @RequestBody DriverScorerDetailRequest request) {
        PageDataResult<DriverScorerDetailVO> ScorerDetailPageList = kwfDriverScoreService.queryScoreDetailPage(request);
        return BaseResult.success(ScorerDetailPageList);
    }

    @PostMapping("/countDriverScore")
    public HttpResult countDriverScore(@Validated @RequestBody DriverScoreQuery query) {
        BigDecimal driverScoreCount = kwfDriverScoreService.countDriverScore(query);
        return HttpResult.ok(driverScoreCount);
    }

}
