package com.zcloud.basic.info.web;


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 com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.basic.info.api.CorpQualificationInfoServiceI;
import com.zcloud.basic.info.dto.CorpQualificationInfoAddCmd;
import com.zcloud.basic.info.dto.CorpQualificationInfoPageQry;
import com.zcloud.basic.info.dto.CorpQualificationInfoUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.CorpQualificationInfoCO;
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.*;

import java.util.ArrayList;

/**
 * web-adapter
 *
 * @Author zhaokai
 * @Date 2025-10-29 16:02:45
 */
@Api(tags = "企业资质信息")
@RequestMapping("/${application.gateway}/corpQualificationInfo")
@RestController
@AllArgsConstructor
public class CorpQualificationInfoController {
    private final CorpQualificationInfoServiceI corpQualificationInfoService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<CorpQualificationInfoCO> add(@Validated @RequestBody CorpQualificationInfoAddCmd cmd) {
        return corpQualificationInfoService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<CorpQualificationInfoCO> page(@RequestBody CorpQualificationInfoPageQry qry) {
        return corpQualificationInfoService.listPage(qry);
    }

    @ApiOperation("详情")
    @PostMapping("/info/{id}")
    public SingleResponse<CorpQualificationInfoCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(corpQualificationInfoService.getInfoById(id));
    }

    @ApiOperation("删除")
    @PostMapping("/remove/{id}")
    public Response remove(@PathVariable("id") Long id) {
        corpQualificationInfoService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("删除多个")
    @PostMapping("/remove/ids")
    public Response removeBatch(@RequestParam Long[] ids) {
        corpQualificationInfoService.removeBatch(ids);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改")
    @PostMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody CorpQualificationInfoUpdateCmd corpQualificationInfoUpdateCmd) {
        corpQualificationInfoService.edit(corpQualificationInfoUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

