package cn.stylefeng.workflow.design.modular.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.workflow.api.pojo.variable.VariableCategory;
import cn.stylefeng.workflow.design.modular.pojo.request.VariableRequest;
import cn.stylefeng.workflow.design.modular.service.VariableService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "流程变量，定义流程中用到的属性")
public class VariableController {

    @Resource
    private VariableService variableService;

    @GetResource(name = "获取流程条件上字段的下拉列表", path = "/variable/getConditionSelectList")
    public ResponseData<List<VariableCategory>> getConditionSelectList(
            @Validated(VariableRequest.getModelVariables.class) VariableRequest variableRequest) {

        List<VariableCategory> modelVariables = variableService.getModelVariables(variableRequest.getDefinitionId());

        return new SuccessResponseData<>(modelVariables);
    }

}
