package com.zcloud.basic.info.web;


import com.zcloud.basic.info.api.UserQualificationInfoServiceI;
import com.zcloud.basic.info.dto.UserQualificationInfoAddCmd;
import com.zcloud.basic.info.dto.UserQualificationInfoPageQry;
import com.zcloud.basic.info.dto.UserQualificationInfoRemoveCmd;
import com.zcloud.basic.info.dto.UserQualificationInfoUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.UserQualificationInfoCO;
import com.alibaba.cola.dto.MultiResponse;
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.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* web-adapter
* @Author SondonYong
* @Date 2025-10-31 09:50:26
*/
@Api(tags = "人员资格证书管理1-特种,2-安全")
@RequestMapping("/${application.gateway}/userQualificationInfo")
@RestController
@AllArgsConstructor
public class UserQualificationInfoController {
    private final UserQualificationInfoServiceI userQualificationInfoService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<UserQualificationInfoCO> add(@Validated @RequestBody UserQualificationInfoAddCmd cmd) {
        return userQualificationInfoService.add(cmd);
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody UserQualificationInfoUpdateCmd cmd) {
        userQualificationInfoService.edit(cmd);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<UserQualificationInfoCO> page(@Validated @RequestBody UserQualificationInfoPageQry qry) {
        return userQualificationInfoService.listPage(qry);
    }

    @ApiOperation("所有数据")
    @PostMapping("/listAll")
    public MultiResponse<UserQualificationInfoCO> listAll(@Validated @RequestBody UserQualificationInfoPageQry qry) {
        return userQualificationInfoService.list(qry);
    }

    @ApiOperation("详情")
    @GetMapping("/getInfoById")
    public SingleResponse<UserQualificationInfoCO> getInfoById(@RequestParam(value = "id") Long id) {
        return userQualificationInfoService.getInfoById(id);
    }

    @ApiOperation("删除")
    @PutMapping("/remove")
    public Response remove(@RequestParam(value = "id") Long id) {
        userQualificationInfoService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("删除多个")
    @PutMapping("/removeBatch")
        public Response removeBatch(@Validated @RequestBody UserQualificationInfoRemoveCmd cmd) {
        userQualificationInfoService.removeBatch(cmd.getIds());
        return SingleResponse.buildSuccess();
    }

}

