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.QualFilingChangeDetailApi;
import org.qinan.safetyeval.client.co.QualFilingChangeDetailCO;
import org.qinan.safetyeval.client.dto.QualFilingChangeDetailAddCmd;
import org.qinan.safetyeval.client.dto.QualFilingChangeDetailModifyCmd;
import org.qinan.safetyeval.client.dto.QualFilingChangeDetailPageQuery;
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-change-detail")
public class QualFilingChangeDetailController {

    @Resource
    private QualFilingChangeDetailApi qualFilingChangeDetailApi;

    @ApiOperation("新增备案变更明细")
    @PostMapping("/save")
    public SingleResponse<QualFilingChangeDetailCO> add(@Validated @RequestBody QualFilingChangeDetailAddCmd cmd) {
        return qualFilingChangeDetailApi.add(cmd);
    }

    @ApiOperation("查询备案变更明细详情")
    @GetMapping("/get")
    public SingleResponse<QualFilingChangeDetailCO> get(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingChangeDetailApi.get(id);
    }

    @ApiOperation("修改备案变更明细")
    @PostMapping("/modify")
    public SingleResponse<QualFilingChangeDetailCO> modify(@Validated @RequestBody QualFilingChangeDetailModifyCmd cmd) {
        return qualFilingChangeDetailApi.modify(cmd);
    }

    @ApiOperation("删除备案变更明细")
    @PostMapping("/delete")
    public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam Long id) {
        return qualFilingChangeDetailApi.delete(id);
    }

    @ApiOperation("分页查询备案变更明细")
    @GetMapping("/page")
    public PageResponse<QualFilingChangeDetailCO> page(@Validated QualFilingChangeDetailPageQuery query) {
        return qualFilingChangeDetailApi.page(query);
    }
}
