package cn.stylefeng.team.portal.modular.management.factory;

import cn.stylefeng.team.portal.modular.management.entity.PortalDesignPermission;
import cn.stylefeng.team.portal.modular.management.pojo.request.PermissionUpdateRequest;

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

public class PermissionFactory {

    public static List<PortalDesignPermission> createPermission(PermissionUpdateRequest permissionUpdateRequest) {
        List<PortalDesignPermission> result = new ArrayList<>();
        for (Long linkBusinessId : permissionUpdateRequest.getLinkBusinessIdList()) {
            PortalDesignPermission portalDesignPermission = new PortalDesignPermission();
            portalDesignPermission.setDesignId(permissionUpdateRequest.getDesignId());
            portalDesignPermission.setLinkScopeType(permissionUpdateRequest.getLinkScopeType());
            portalDesignPermission.setLinkBusinessId(linkBusinessId);
            portalDesignPermission.setScopeType(permissionUpdateRequest.getScopeType());
            result.add(portalDesignPermission);
        }
        return result;
    }

}
