package org.qinan.safetyeval.adapter.web;

import io.swagger.annotations.Api;
import org.qinan.safetyeval.client.dto.PageResponse;
import org.qinan.safetyeval.client.dto.SingleResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.qinan.safetyeval.client.api.QualFilingPersonnelCertApi;
import org.qinan.safetyeval.client.co.QualFilingPersonnelCertCO;
import org.qinan.safetyeval.client.dto.QualFilingPersonnelCertAddCmd;
import org.qinan.safetyeval.client.dto.QualFilingPersonnelCertModifyCmd;
import org.qinan.safetyeval.client.dto.QualFilingPersonnelCertPageQuery;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 备案申请人员证书适配层（Controller）
 *
 * @author safety-eval
 */
@Api(tags = "备案申请人员证书管理")
@RestController
@RequestMapping("/safetyEval/qual-filing-personnel-cert")
public class QualFilingPersonnelCertController {

    @Resource
    private QualFilingPersonnelCertApi qualFilingPersonnelCertApi;

    @ApiOperation("新增备案申请人员证书")
    @PostMapping("/save")
    public SingleResponse<QualFilingPersonnelCertCO> add(@Validated @RequestBody QualFilingPersonnelCertAddCmd cmd) {
        return qualFilingPersonnelCertApi.add(cmd);
    }

    @ApiOperation("查询备案申请人员证书详情")
    @GetMapping("/get")
    public SingleResponse<QualFilingPersonnelCertCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingPersonnelCertApi.get(id);
    }

    @ApiOperation("修改备案申请人员证书")
    @PostMapping("/modify")
    public SingleResponse<QualFilingPersonnelCertCO> modify(@Validated @RequestBody QualFilingPersonnelCertModifyCmd cmd) {
        return qualFilingPersonnelCertApi.modify(cmd);
    }

    @ApiOperation("删除备案申请人员证书")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingPersonnelCertApi.delete(id);
    }

    @ApiOperation("分页查询备案申请人员证书")
    @GetMapping("/page")
    public PageResponse<QualFilingPersonnelCertCO> page(@Validated QualFilingPersonnelCertPageQuery query) {
        return qualFilingPersonnelCertApi.page(query);
    }
}
