package cn.axzo.workflow.server.controller.web.business;

import cn.axzo.workflow.client.feign.manage.ProcessConfigApi;
import cn.axzo.workflow.common.enums.BpmnButtonEnum;
import cn.axzo.workflow.common.model.request.bpmn.BpmnButtonMetaInfo;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


/**
 * ProcessConfigController
 *
 * @author zuoqinbo
 * @version V1.0
 * @date 2023/11/9 14:01
 */
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
public class ProcessConfigController implements ProcessConfigApi {

    @Override
    public CommonResponse<List<BpmnButtonMetaInfo>> getDefaultButtons() {
        return CommonResponse.success(Arrays.stream(BpmnButtonEnum.values())
                .map(buttonEnum -> new BpmnButtonMetaInfo()
                        .setOrder(buttonEnum.getOrder())
                        .setBtnKey(buttonEnum.getBtnKey())
                        .setBtnName(buttonEnum.getBtnName())
                        .setChecked(false)
                        .setDisabled(false)).collect(Collectors.toList()));
    }
}
