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.OrgPersonnelCertApi;
import org.qinan.safetyeval.client.co.OrgPersonnelCertCO;
import org.qinan.safetyeval.client.dto.OrgPersonnelCertAddCmd;
import org.qinan.safetyeval.client.dto.OrgPersonnelCertModifyCmd;
import org.qinan.safetyeval.client.dto.OrgPersonnelCertPageQuery;
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/org-personnel-cert")
public class OrgPersonnelCertController {

    @Resource
    private OrgPersonnelCertApi orgPersonnelCertApi;

    @ApiOperation("新增人员证书")
    @PostMapping("/save")
    public SingleResponse<OrgPersonnelCertCO> add(@Validated @RequestBody OrgPersonnelCertAddCmd cmd) {
        return orgPersonnelCertApi.add(cmd);
    }

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

    @ApiOperation("修改人员证书")
    @PostMapping("/modify")
    public SingleResponse<OrgPersonnelCertCO> modify(@Validated @RequestBody OrgPersonnelCertModifyCmd cmd) {
        return orgPersonnelCertApi.modify(cmd);
    }

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

    @ApiOperation("分页查询人员证书")
    @GetMapping("/page")
    public PageResponse<OrgPersonnelCertCO> page(@Validated OrgPersonnelCertPageQuery query) {
        return orgPersonnelCertApi.page(query);
    }
}
