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.CorpFormServiceI;
import com.zcloud.basic.info.dto.CorpFormAddCmd;
import com.zcloud.basic.info.dto.CorpFormPageQry;
import com.zcloud.basic.info.dto.CorpFormUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.CorpFormCO;
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:26
 */
@Api(tags = "企业信息详情")
@RequestMapping("/${application.gateway}/corpForm")
@RestController
@AllArgsConstructor
public class CorpFormController {
    private final CorpFormServiceI corpFormService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<CorpFormCO> add(@Validated @RequestBody CorpFormAddCmd cmd) {
        SSOUser ssoUser = AuthContext.getCurrentUser();
        return corpFormService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<CorpFormCO> page(@RequestBody CorpFormPageQry qry) {
        return corpFormService.listPage(qry);
    }

    @ApiOperation("所有数据")
    @GetMapping("/listAll")
    public MultiResponse<CorpFormCO> listAll() {
        return MultiResponse.of(new ArrayList<CorpFormCO>());
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<CorpFormCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(new CorpFormCO());
    }

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

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

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody CorpFormUpdateCmd corpFormUpdateCmd) {
        corpFormService.edit(corpFormUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

