package cd.casic.ci.api;

import cd.casic.ci.process.dto.req.env.EnvQueryReq;
import cd.casic.ci.process.dto.req.env.EnvReq;
import cd.casic.ci.process.dto.resp.env.EnvResp;
import cd.casic.framework.commons.pojo.CommonResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.validation.Valid;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName EnvController
 * @Author hopeli
 * @Date 2025/5/10 10:57
 * @Version 1.0
 */

@RestController
@RequestMapping("/env")
public class EnvController {

    @PostMapping(path="/createEnv")
    public CommonResult<String> createEnv(@RequestBody @NotNull @Valid EnvReq envReq){

//        String pipelineAuthHostId = envService.createEnv(env);

        String envId = "1";
        return CommonResult.success(envId);
    }


    @PostMapping(path="/deleteEnv")
    public CommonResult<Void> deleteEnv(@NotNull String envId){

//        envService.deleteEnv(envId);

        return CommonResult.success();
    }

    @PostMapping(path="/findEnvList")
    public CommonResult<List<EnvResp>> findEnvList(@NotNull EnvQueryReq query){

//        List<Env> envList = envService.findEnvList(envQuery);
        List<EnvResp> envRespList = new ArrayList<>(0);
        EnvResp envResp = new EnvResp();
        envResp.setId("1");
        envResp.setEnvName("test数据交互测试");
        envRespList.add(envResp);

        return CommonResult.success(envRespList);
    }



    @PostMapping(path="/updateEnv")
    public CommonResult<Void> updateEnv(@RequestBody @NotNull @Valid EnvReq envReq){

//        this.envService.updateEnv(env);

        return CommonResult.success();
    }


    @PostMapping(path="/findEnvPage")
    public CommonResult<Page<EnvResp>> findEnvPage(@RequestBody @NotNull @Valid EnvQueryReq query){

//        Pagination<Env> envPage = envService.findEnvPage(envQuery);
        Page<EnvResp> envRespPage = new Page<>();
        List<EnvResp> envRespList = new ArrayList<>(0);
        EnvResp envResp = new EnvResp();
        envResp.setId("1");
        envResp.setEnvName("test数据交互测试");
        envRespList.add(envResp);
        envRespPage.setRecords(envRespList);
        return CommonResult.success(envRespPage);
    }

}
