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.QualFilingPersonnelCertChangeServiceI;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelCertChangeAddCmd;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelCertChangePageQry;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelCertChangeUpdateCmd;
import org.qinan.safetyeval.client.change.response.QualFilingPersonnelCertChangeCo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 备案申请人员证书
 *
 * @Author: ltq
 * @Date: 2026-07-02 10:04:23
 */
@RestController
@AllArgsConstructor
@Api(tags = "备案申请人员证书")
@RequestMapping("/safetyEval/qual-filing-personnel-cert-change")
public class QualFilingPersonnelCertChangeController implements Serializable {
    private static final long serialVersionUID = 1L;

    private final QualFilingPersonnelCertChangeServiceI qualFilingPersonnelCertChangeServiceI;

    @GetMapping
    @ApiOperation("查询备案申请人员证书列表-分页")
    public PageResponse<QualFilingPersonnelCertChangeCo> list(@Validated QualFilingPersonnelCertChangePageQry qry) {
        return qualFilingPersonnelCertChangeServiceI.listQualFilingPersonnelCertChangePage(qry);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询备案申请人员证书详情页面")
    public SingleResponse<QualFilingPersonnelCertChangeCo> getInfo(@PathVariable("id") Long id) {
        return SingleResponse.of(qualFilingPersonnelCertChangeServiceI.getQualFilingPersonnelCertChangeById(id));
    }

    @PostMapping
    @ApiOperation("新增备案申请人员证书")
    public Response save(@Validated @RequestBody QualFilingPersonnelCertChangeAddCmd qualFilingPersonnelCertChangeAddCmd) {
        qualFilingPersonnelCertChangeServiceI.saveQualFilingPersonnelCertChange(qualFilingPersonnelCertChangeAddCmd);
        return Response.buildSuccess();
    }

    @PutMapping
    @ApiOperation("修改备案申请人员证书")
    public Response update(@Validated @RequestBody QualFilingPersonnelCertChangeUpdateCmd qualFilingPersonnelCertChangeUpdateCmd) {
        qualFilingPersonnelCertChangeServiceI.updateQualFilingPersonnelCertChange(qualFilingPersonnelCertChangeUpdateCmd);
        return Response.buildSuccess();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除备案申请人员证书（单个）")
    public Response deletedById(@PathVariable("id") Long id) {
        qualFilingPersonnelCertChangeServiceI.deletedQualFilingPersonnelCertChangeById(id);
        return Response.buildSuccess();
    }

    @DeleteMapping("/ids")
    @ApiOperation("删除备案申请人员证书（多个）")
    public Response deletedByIds(@RequestParam Long[] ids) {
        qualFilingPersonnelCertChangeServiceI.deletedQualFilingPersonnelCertChangeByIds(ids);
        return Response.buildSuccess();
    }

}
