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.QualFilingCommitmentChangeServiceI;
import org.qinan.safetyeval.client.change.request.QualFilingCommitmentChangeAddCmd;
import org.qinan.safetyeval.client.change.request.QualFilingCommitmentChangePageQry;
import org.qinan.safetyeval.client.change.request.QualFilingCommitmentChangeUpdateCmd;
import org.qinan.safetyeval.client.change.response.QualFilingCommitmentChangeCo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 法定代人承诺书-变更
 *
 * @Author: ltq
 * @Date: 2026-07-02 09:38:30
 */
@RestController
@AllArgsConstructor
@Api(tags = "法定代人承诺书-变更")
@RequestMapping("/safetyEval/qual-filing-commitment-change")
public class QualFilingCommitmentChangeController implements Serializable {
    private static final long serialVersionUID = 1L;

    private final QualFilingCommitmentChangeServiceI qualFilingCommitmentChangeServiceI;

    @GetMapping
    @ApiOperation("查询法定代人承诺书-变更列表-分页")
    public PageResponse<QualFilingCommitmentChangeCo> list(@Validated QualFilingCommitmentChangePageQry qry) {
        return qualFilingCommitmentChangeServiceI.listQualFilingCommitmentChangePage(qry);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询法定代人承诺书-变更详情页面")
    public SingleResponse<QualFilingCommitmentChangeCo> getInfo(@PathVariable("id") Long id) {
        return SingleResponse.of(qualFilingCommitmentChangeServiceI.getQualFilingCommitmentChangeById(id));
    }

    @PostMapping
    @ApiOperation("新增法定代人承诺书-变更")
    public Response save(@Validated @RequestBody QualFilingCommitmentChangeAddCmd qualFilingCommitmentChangeAddCmd) {
        qualFilingCommitmentChangeServiceI.saveQualFilingCommitmentChange(qualFilingCommitmentChangeAddCmd);
        return Response.buildSuccess();
    }

    @PutMapping
    @ApiOperation("修改法定代人承诺书-变更")
    public Response update(@Validated @RequestBody QualFilingCommitmentChangeUpdateCmd qualFilingCommitmentChangeUpdateCmd) {
        qualFilingCommitmentChangeServiceI.updateQualFilingCommitmentChange(qualFilingCommitmentChangeUpdateCmd);
        return Response.buildSuccess();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除法定代人承诺书-变更（单个）")
    public Response deletedById(@PathVariable("id") Long id) {
        qualFilingCommitmentChangeServiceI.deletedQualFilingCommitmentChangeById(id);
        return Response.buildSuccess();
    }

    @DeleteMapping("/ids")
    @ApiOperation("删除法定代人承诺书-变更（多个）")
    public Response deletedByIds(@RequestParam Long[] ids) {
        qualFilingCommitmentChangeServiceI.deletedQualFilingCommitmentChangeByIds(ids);
        return Response.buildSuccess();
    }

}
