package org.qinan.safetyeval.adapter.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.qinan.safetyeval.client.api.QualFilingExpertApi;
import org.qinan.safetyeval.client.co.QualFilingExpertCO;
import org.qinan.safetyeval.client.dto.PageResponse;
import org.qinan.safetyeval.client.dto.QualFilingExpertAddCmd;
import org.qinan.safetyeval.client.dto.QualFilingExpertModifyCmd;
import org.qinan.safetyeval.client.dto.QualFilingExpertPageQuery;
import org.qinan.safetyeval.client.dto.SingleResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 审核专家适配层（Controller）
 *
 * @author safety-eval
 */
@Api(tags = "审核专家管理")
@RestController
@RequestMapping("/safetyEval/qual-filing-expert")
public class QualFilingExpertController {

    @Resource
    private QualFilingExpertApi qualFilingExpertApi;

    @ApiOperation("新增审核专家")
    @PostMapping("/save")
    public SingleResponse<QualFilingExpertCO> add(@Validated @RequestBody QualFilingExpertAddCmd cmd) {
        return qualFilingExpertApi.add(cmd);
    }

    @ApiOperation("查询审核专家详情")
    @GetMapping("/get")
    public SingleResponse<QualFilingExpertCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingExpertApi.get(id);
    }

    @ApiOperation("修改审核专家")
    @PostMapping("/modify")
    public SingleResponse<QualFilingExpertCO> modify(@Validated @RequestBody QualFilingExpertModifyCmd cmd) {
        return qualFilingExpertApi.modify(cmd);
    }

    @ApiOperation("删除审核专家")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingExpertApi.delete(id);
    }

    @ApiOperation("分页查询审核专家")
    @GetMapping("/page")
    public PageResponse<QualFilingExpertCO> page(@Validated QualFilingExpertPageQuery query) {
        return qualFilingExpertApi.page(query);
    }
}
