package com.jy.flow.adapter;

import cn.hutool.core.util.ObjectUtil;
import com.jy.framework.satoken.LoginContext;
import jakarta.annotation.Resource;
import org.dromara.warm.flow.core.enums.CooperateType;
import org.dromara.warm.flow.core.service.TaskService;
import org.springframework.stereotype.Service;

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

@Service
public abstract class AbstractWarmFlowAdapter {

    @Resource
    protected TaskService taskService;

    /**
     * 获取权限
     *
     * @return 权限列表
     */
    public static List<String> permissionList() {
        List<String> permissionList = new ArrayList<>();
        permissionList.add(LoginContext.getUserId().toString());
        if (ObjectUtil.isNotEmpty(LoginContext.getDeptId())) {
            permissionList.add("dept:" + LoginContext.getDeptId());
        }
        for (Long roleId : LoginContext.getRoleIdSet()) {
            permissionList.add("role:" + roleId);
        }
        return permissionList;
    }

    /**
     * 根据类型获取描述
     *
     * @param type 流程类型
     * @return value
     */
    protected String type(Integer type) {
        return CooperateType.getValueByKey(type);
    }

}
