package cn.iocoder.yudao.module.system.api.dept; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; import java.util.Collection; import java.util.List; import java.util.Map; /** * 岗位 API 接口 * * @author 超级管理员 */ public interface PostApi { /** * 校验岗位们是否有效。如下情况,视为无效: * 1. 岗位编号不存在 * 2. 岗位被禁用 * * @param ids 岗位编号数组 */ void validPostList(Collection ids); List getPostList(Collection ids); /** * 获得全部岗位列表 * * @return 岗位信息数组 */ List getPostList(); /** * 按名称获得岗位编号,不存在时自动创建 * *

用于 Excel 导入等「只有名称没有编号」的场景,避免因岗位尚未建立导致整批导入失败。 * * @param name 岗位名称 * @return 岗位编号;名称为空时返回 {@code null} */ Long getOrCreatePostByName(String name); default Map getPostMap(Collection ids) { if (CollUtil.isEmpty(ids)) { return MapUtil.empty(); } List list = getPostList(ids); return CollectionUtils.convertMap(list, PostRespDTO::getId); } }