tuqin
2 天以前 ffec90c897e9bd78e88b9fa590a5dd75d26b82c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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<Long> ids);
 
    List<PostRespDTO> getPostList(Collection<Long> ids);
 
    /**
     * 获得全部岗位列表
     *
     * @return 岗位信息数组
     */
    List<PostRespDTO> getPostList();
 
    /**
     * 按名称获得岗位编号,不存在时自动创建
     *
     * <p>用于 Excel 导入等「只有名称没有编号」的场景,避免因岗位尚未建立导致整批导入失败。
     *
     * @param name 岗位名称
     * @return 岗位编号;名称为空时返回 {@code null}
     */
    Long getOrCreatePostByName(String name);
 
    default Map<Long, PostRespDTO> getPostMap(Collection<Long> ids) {
        if (CollUtil.isEmpty(ids)) {
            return MapUtil.empty();
        }
 
        List<PostRespDTO> list = getPostList(ids);
        return CollectionUtils.convertMap(list, PostRespDTO::getId);
    }
 
}