package org.qinan.safetyeval.adapter.web;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.qinan.safetyeval.app.change.service.QualFilingMaterialChangeServiceI;
import org.qinan.safetyeval.client.change.request.QualFilingMaterialChangeAddCmd;
import org.qinan.safetyeval.client.change.request.QualFilingMaterialChangePageQry;
import org.qinan.safetyeval.client.change.request.QualFilingMaterialChangeUpdateCmd;
import org.qinan.safetyeval.client.change.response.QualFilingMaterialChangeCo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 备案申请材料-变更
 *
 * @Author: ltq
 * @Date: 2026-07-02 10:04:07
 */
@RestController
@AllArgsConstructor
@Api(tags = "备案申请材料-变更")
@RequestMapping("/safetyEval/qual-filing-material-change")
public class QualFilingMaterialChangeController implements Serializable {
    private static final long serialVersionUID = 1L;

    private final QualFilingMaterialChangeServiceI qualFilingMaterialChangeServiceI;

    @GetMapping
    @ApiOperation("查询备案申请材料-变更列表-分页")
    public PageResponse<QualFilingMaterialChangeCo> list(@Validated QualFilingMaterialChangePageQry qry) {
        return qualFilingMaterialChangeServiceI.listQualFilingMaterialChangePage(qry);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询备案申请材料-变更详情页面")
    public SingleResponse<QualFilingMaterialChangeCo> getInfo(@PathVariable("id") Long id) {
        return SingleResponse.of(qualFilingMaterialChangeServiceI.getQualFilingMaterialChangeById(id));
    }

    @PostMapping
    @ApiOperation("新增备案申请材料-变更")
    public Response save(@Validated @RequestBody QualFilingMaterialChangeAddCmd qualFilingMaterialChangeAddCmd) {
        qualFilingMaterialChangeServiceI.saveQualFilingMaterialChange(qualFilingMaterialChangeAddCmd);
        return Response.buildSuccess();
    }

    @PutMapping
    @ApiOperation("修改备案申请材料-变更")
    public Response update(@Validated @RequestBody QualFilingMaterialChangeUpdateCmd qualFilingMaterialChangeUpdateCmd) {
        qualFilingMaterialChangeServiceI.updateQualFilingMaterialChange(qualFilingMaterialChangeUpdateCmd);
        return Response.buildSuccess();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除备案申请材料-变更（单个）")
    public Response deletedById(@PathVariable("id") Long id) {
        qualFilingMaterialChangeServiceI.deletedQualFilingMaterialChangeById(id);
        return Response.buildSuccess();
    }

    @DeleteMapping("/ids")
    @ApiOperation("删除备案申请材料-变更（多个）")
    public Response deletedByIds(@RequestParam Long[] ids) {
        qualFilingMaterialChangeServiceI.deletedQualFilingMaterialChangeByIds(ids);
        return Response.buildSuccess();
    }

}
