package com.jy.flow.adapter;


import com.jy.flow.model.vo.WarmFlowInteractiveTypeVo;
import com.jy.framework.satoken.LoginContext;
import org.dromara.warm.flow.core.dto.FlowParams;
import org.dromara.warm.flow.core.enums.CooperateType;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * 转办适配器
 */
@Component
public class TransferAdapter extends AbstractWarmFlowAdapter implements WarmFlowAdapter {

    @Override
    public boolean isAdapter(Integer warmFlowType) {
        return Objects.equals(CooperateType.TRANSFER.getKey(), warmFlowType);
    }

    @Override
    public boolean adapter(WarmFlowInteractiveTypeVo obj) {
        FlowParams flowParams = new FlowParams()
                .handler(LoginContext.getUserId().toString())
                .permissionFlag(permissionList())
                .addHandlers(obj.getAddHandlers())
                .message(this.type(obj.getOperatorType()));

        return super.taskService.addSignature(obj.getTaskId(), flowParams);
    }

}
