package com.ningdatech.carapi.driver.controller;


import com.ningdatech.carapi.driver.manage.CertificateManage;
import com.ningdatech.carapi.driver.model.po.ReqUploadCertificatePO;
import com.ningdatech.carapi.driver.model.vo.ResCertificateVO;
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-24
 */
@RequestMapping("/api/v1/certificate")
@RestController
@Api(tags = "合格证管理")
@Validated
@RequiredArgsConstructor
public class CertificateController {

    private final CertificateManage certificateManage;

    @PostMapping("/upload")
    @ApiOperation("上传合格证书")
    public void uploadCertificate(@Valid @RequestBody ReqUploadCertificatePO request) {
        certificateManage.uploadCertificate(request);
    }

    @PostMapping("/get")
    @ApiOperation("登陆者获取合格证书（移动端使用）")
    public ResCertificateVO getCertificate() {
        return certificateManage.getCertificate();
    }

    @PostMapping("/get/web/{driverId}")
    @ApiOperation("根据驾驶员id获取合格证书")
    public ResCertificateVO getCertificate(@PathVariable("driverId") Long driverId) {
        return certificateManage.getCertificate(driverId);
    }

}
