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.QualFilingEquipmentChangeServiceI;
import org.qinan.safetyeval.client.change.request.QualFilingEquipmentChangeAddCmd;
import org.qinan.safetyeval.client.change.request.QualFilingEquipmentChangePageQry;
import org.qinan.safetyeval.client.change.request.QualFilingEquipmentChangeUpdateCmd;
import org.qinan.safetyeval.client.change.response.QualFilingEquipmentChangeCo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

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

    private final QualFilingEquipmentChangeServiceI qualFilingEquipmentChangeServiceI;

    @GetMapping
    @ApiOperation("查询备案申请装备-变更列表-分页")
    public PageResponse<QualFilingEquipmentChangeCo> list(@Validated QualFilingEquipmentChangePageQry qry) {
        return qualFilingEquipmentChangeServiceI.listQualFilingEquipmentChangePage(qry);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询备案申请装备-变更详情页面")
    public SingleResponse<QualFilingEquipmentChangeCo> getInfo(@PathVariable("id") Long id) {
        return SingleResponse.of(qualFilingEquipmentChangeServiceI.getQualFilingEquipmentChangeById(id));
    }

    @PostMapping
    @ApiOperation("新增备案申请装备-变更")
    public Response save(@Validated @RequestBody QualFilingEquipmentChangeAddCmd qualFilingEquipmentChangeAddCmd) {
        qualFilingEquipmentChangeServiceI.saveQualFilingEquipmentChange(qualFilingEquipmentChangeAddCmd);
        return Response.buildSuccess();
    }

    @PutMapping
    @ApiOperation("修改备案申请装备-变更")
    public Response update(@Validated @RequestBody QualFilingEquipmentChangeUpdateCmd qualFilingEquipmentChangeUpdateCmd) {
        qualFilingEquipmentChangeServiceI.updateQualFilingEquipmentChange(qualFilingEquipmentChangeUpdateCmd);
        return Response.buildSuccess();
    }

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

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

}
