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.QualFilingReviewApi;
import org.qinan.safetyeval.client.co.QualFilingReviewCO;
import org.qinan.safetyeval.client.dto.PageResponse;
import org.qinan.safetyeval.client.dto.QualFilingReviewAddCmd;
import org.qinan.safetyeval.client.dto.QualFilingReviewModifyCmd;
import org.qinan.safetyeval.client.dto.QualFilingReviewPageQuery;
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-review")
public class QualFilingReviewController {

    @Resource
    private QualFilingReviewApi qualFilingReviewApi;

    @ApiOperation("新增资质审核记录")
    @PostMapping("/save")
    public SingleResponse<QualFilingReviewCO> add(@Validated @RequestBody QualFilingReviewAddCmd cmd) {
        return qualFilingReviewApi.add(cmd);
    }

    @ApiOperation("查询资质审核记录详情")
    @GetMapping("/get")
    public SingleResponse<QualFilingReviewCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingReviewApi.get(id);
    }

    @ApiOperation("修改资质审核记录")
    @PostMapping("/modify")
    public SingleResponse<QualFilingReviewCO> modify(@Validated @RequestBody QualFilingReviewModifyCmd cmd) {
        return qualFilingReviewApi.modify(cmd);
    }

    @ApiOperation("删除资质审核记录")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingReviewApi.delete(id);
    }

    @ApiOperation("分页查询资质审核记录")
    @GetMapping("/page")
    public PageResponse<QualFilingReviewCO> page(@Validated QualFilingReviewPageQuery query) {
        return qualFilingReviewApi.page(query);
    }
}
