package com.njcn.bpm.strategy;

import com.njcn.user.api.UserFeignClient;
import com.njcn.bpm.utils.StrUtils;
import org.flowable.engine.delegate.DelegateExecution;
import com.njcn.bpm.enums.BpmTaskCandidateStrategyEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 角色 {@link IBpmTaskCandidateStrategy} 实现类
 *
 * @author kyle
 */
@Component
public class BpmTaskCandidateRoleStrategy implements IBpmTaskCandidateStrategy {

    @Resource
    private UserFeignClient userFeignClient;


    @Override
    public BpmTaskCandidateStrategyEnum getStrategy() {
        return BpmTaskCandidateStrategyEnum.ROLE;
    }

    @Override
    public void validateParam(String param) {
//        Set<Long> roleIds = StrUtils.splitToLongSet(param);
//        roleApi.validRoleList(roleIds);
    }

    @Override
    public List<String> calculateUsers(DelegateExecution execution, String param) {
        List<String> roleIds = StrUtils.splitToStringList(param);
        return userFeignClient.getUserIdByRoleId(roleIds).getData();
    }

}