package com.ningdatech.carapi.driver.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.driver.manage.TrainingMaterialManage;
import com.ningdatech.carapi.driver.model.po.ReqSaveTrainingMaterialPO;
import com.ningdatech.carapi.driver.model.po.ReqTrainingMaterialListPO;
import com.ningdatech.carapi.driver.model.vo.ResSaveTrainingMaterialVO;
import com.ningdatech.carapi.driver.model.vo.ResTrainingMaterialListVO;
import com.ningdatech.carapi.driver.model.vo.ResTrainingMaterialVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author LiuXinXin
 * @since 2022-10-09
 */
@RequestMapping("/api/v1/driver/training-materials")
@RestController
@Api(tags = "驾驶员管理-培训管理-培训材料")
@Validated
@RequiredArgsConstructor
public class TrainingMaterialController {

    private final TrainingMaterialManage trainingMaterialManage;

    @PostMapping("/list")
    @ApiOperation("培训材料-列表查询（新接口）")
    public PageVo<ResTrainingMaterialListVO> trainingMaterialsList(@Valid @RequestBody ReqTrainingMaterialListPO po) {
        return trainingMaterialManage.trainingMaterialsList(po);
    }

    @PostMapping("/save")
    @ApiOperation("保存培训材料（新接口）")
    public ResSaveTrainingMaterialVO saveTrainingMaterial(@Valid @RequestBody ReqSaveTrainingMaterialPO request) {
        return trainingMaterialManage.saveTrainingMaterial(request);
    }

    @PostMapping("/detail/{trainingMaterialId}")
    @ApiOperation("培训材料详情")
    public ResTrainingMaterialVO getTrainingMaterialDetail(@PathVariable("trainingMaterialId") Long trainingMaterialId) {
        return trainingMaterialManage.getTrainingMaterialDetail(trainingMaterialId);
    }

    @PostMapping("remove/{trainingMaterialId}")
    @ApiOperation("删除培训材料")
    public void removeTrainingMaterial(@PathVariable("trainingMaterialId") Long trainingMaterialId) {
        trainingMaterialManage.removeTrainingMaterial(trainingMaterialId);
    }

}
