package cd.casic.ci.api;


import cd.casic.ci.process.dto.req.variable.VariableReq;
import cd.casic.ci.process.dto.resp.variable.VariableResp;
import cd.casic.ci.process.process.service.variable.VariableService;
import cd.casic.framework.commons.pojo.CommonResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.*;

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

/**
 * @pi.protocol: http
 * @pi.groupName: 流水线变量控制器
 */
@RestController
@RequestMapping("/pipelineVariable")
public class VariableController {
    @Resource
    private VariableService variableService;
    @GetMapping("/getPipelineContextGlobalVariable/{pipelineId}/{varName}")
    public CommonResult<Object> getPipelineContextGlobalVariable(@PathVariable("pipelineId") String pipelineId,@PathVariable("varName") String varName){
        Object variable = variableService.getPipelineContextGlobalVariable(pipelineId, varName);
        return CommonResult.success(variable);
    }
    @GetMapping("/getPipelineContextGlobalVariables/{pipelineId}")
    public CommonResult<Map<String,Object>> getPipelineContextGlobalVariables(@PathVariable("pipelineId") String pipelineId){
        return CommonResult.success(variableService.getPipelineContextGlobalVariables(pipelineId));
    }
}
