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.QualFilingPersonnelChangeServiceI;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelChangeAddCmd;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelChangePageQry;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelChangeUpdateCmd;
import org.qinan.safetyeval.client.change.response.QualFilingPersonnelChangeCo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

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

    private final QualFilingPersonnelChangeServiceI qualFilingPersonnelChangeServiceI;

    @GetMapping
    @ApiOperation("查询备案申请人员-变更列表-分页")
    public PageResponse<QualFilingPersonnelChangeCo> list(@Validated QualFilingPersonnelChangePageQry qry) {
        return qualFilingPersonnelChangeServiceI.listQualFilingPersonnelChangePage(qry);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询备案申请人员-变更详情页面")
    public SingleResponse<QualFilingPersonnelChangeCo> getInfo(@PathVariable("id") Long id) {
        return SingleResponse.of(qualFilingPersonnelChangeServiceI.getQualFilingPersonnelChangeById(id));
    }

    @PostMapping
    @ApiOperation("新增备案申请人员-变更")
    public Response save(@Validated @RequestBody QualFilingPersonnelChangeAddCmd qualFilingPersonnelChangeAddCmd) {
        qualFilingPersonnelChangeServiceI.saveQualFilingPersonnelChange(qualFilingPersonnelChangeAddCmd);
        return Response.buildSuccess();
    }

    @PutMapping
    @ApiOperation("修改备案申请人员-变更")
    public Response update(@Validated @RequestBody QualFilingPersonnelChangeUpdateCmd qualFilingPersonnelChangeUpdateCmd) {
        qualFilingPersonnelChangeServiceI.updateQualFilingPersonnelChange(qualFilingPersonnelChangeUpdateCmd);
        return Response.buildSuccess();
    }

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

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

}
