Skip to content

接口名称

职级管理 - (FeishuTenantV3JobLevel)

功能描述

职级是用户属性之一,可以根据企业组织架构的需要,添加职级,例如 P1、P2、P3、P4。使用职级 API,可以创建、更新、删除或查询职级。后续在创建用户或者更新用户时,可以为用户设置指定的职级属性。当前接口使用租户令牌访问,适应于租户应用场景。

参考文档

飞书官方API文档

函数列表

函数名称功能描述认证方式HTTP 方法
CreateJobLevelAsync创建职级租户令牌POST
UpdateJobLevelAsync更新职级信息租户令牌PUT
GetJobLevelByIdAsync获取指定职级信息租户令牌GET
GetJobLevelListAsync获取职级列表租户令牌GET
DeleteJobLevelByIdAsync删除指定职级租户令牌DELETE

函数详细内容

创建职级

函数签名

csharp
Task<FeishuApiResult<JobLevelResult>?> CreateJobLevelAsync(
   [Body] JobLevelCreateUpdateRequest levelCreateRequest,
   CancellationToken cancellationToken = default);

认证 租户令牌

参数

参数名类型必填说明示例值
levelCreateRequestJobLevelCreateUpdateRequest创建职级请求体-

请求体参数 (JobLevelCreateUpdateRequest)

参数名类型必填说明示例值
namestring职级名称。通用名称,如果未设置多语言名称,则默认展示该名称"高级专家"
descriptionstring职级描述。字符长度上限 5,000"公司内部中高级职称,有一定专业技术能力的人员"
orderint职级排序。数值越小,排序越靠前200
statusbool是否启用该职级true
i18n_nameList<I18nContent>多语言职级名称-

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "job_level_id": "jl_xxxxxxxxx",
    "name": "高级专家",
    "description": "公司内部中高级职称,有一定专业技术能力的人员",
    "order": 200,
    "status": true,
    "i18n_name": [],
    "i18n_description": [],
    "create_time": "2024-01-01 00:00:00",
    "update_time": "2024-01-01 00:00:00"
  }
}

错误码

错误码错误信息说明
99991663job_level already exist职级已存在
99991664invalid job_level name无效的职级名称

说明

  • 职级名称不能重复
  • 职级名称长度不能超过100个字符
  • 描述长度不能超过5000个字符

代码示例

typescript
import { FeishuTenantV3JobLevel } from 'mud-feishu';

const jobLevelApi = new FeishuTenantV3JobLevel();

// 创建职级
const result = await jobLevelApi.createJobLevel({
  name: "高级专家",
  description: "公司内部中高级职称,有一定专业技术能力的人员",
  order: 200,
  status: true
});

if (result.code === 0) {
  console.log(`职级创建成功,ID: ${result.data.job_level_id}`);
} else {
  console.error(`职级创建失败: ${result.msg}`);
}

更新职级信息

函数签名

csharp
Task<FeishuApiResult<JobLevelResult>?> UpdateJobLevelAsync(
   [Path] string job_level_id,
   [Body] JobLevelCreateUpdateRequest levelCreateRequest,
   CancellationToken cancellationToken = default);

认证 租户令牌

参数

参数名类型必填说明示例值
job_level_idstring职级ID"jl_xxxxxxxxx"
levelCreateRequestJobLevelCreateUpdateRequest更新职级请求体-

请求体参数 (JobLevelCreateUpdateRequest)

参数名类型必填说明示例值
namestring职级名称。通用名称,如果未设置多语言名称,则默认展示该名称"高级专家"
descriptionstring职级描述。字符长度上限 5,000"公司内部中高级职称,有一定专业技术能力的人员"
orderint职级排序。数值越小,排序越靠前200
statusbool是否启用该职级true
i18n_nameList<I18nContent>多语言职级名称-

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "job_level_id": "jl_xxxxxxxxx",
    "name": "高级专家",
    "description": "公司内部中高级职称,有一定专业技术能力的人员",
    "order": 200,
    "status": true,
    "i18n_name": [],
    "i18n_description": [],
    "create_time": "2024-01-01 00:00:00",
    "update_time": "2024-01-01 00:00:00"
  }
}

错误码

错误码错误信息说明
99991663job_level not found职级不存在
99991664invalid job_level name无效的职级名称

说明

  • 更新职级时,名称不能与现有其他职级重复
  • 未传递的参数不会进行更新

代码示例

typescript
import { FeishuTenantV3JobLevel } from 'mud-feishu';

const jobLevelApi = new FeishuTenantV3JobLevel();

// 更新职级信息
const result = await jobLevelApi.updateJobLevel(
  "jl_xxxxxxxxx",
  {
    name: "资深专家",
    description: "公司内部高级职称,具有丰富专业技术能力的人员",
    order: 210,
    status: true
  }
);

if (result.code === 0) {
  console.log("职级信息更新成功");
} else {
  console.error(`职级信息更新失败: ${result.msg}`);
}

获取指定职级信息

函数签名

csharp
Task<FeishuApiResult<JobLevelResult>?> GetJobLevelByIdAsync(
       [Path] string job_level_id,
       CancellationToken cancellationToken = default);

认证 租户令牌

参数

参数名类型必填说明示例值
job_level_idstring职级ID"jl_xxxxxxxxx"

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "job_level_id": "jl_xxxxxxxxx",
    "name": "高级专家",
    "description": "公司内部中高级职称,有一定专业技术能力的人员",
    "order": 200,
    "status": true,
    "i18n_name": [],
    "i18n_description": [],
    "create_time": "2024-01-01 00:00:00",
    "update_time": "2024-01-01 00:00:00"
  }
}

错误码

错误码错误信息说明
99991663job_level not found职级不存在

说明

  • 返回指定职级的详细信息,包括名称、描述、排序、状态以及多语言等

代码示例

typescript
import { FeishuTenantV3JobLevel } from 'mud-feishu';

const jobLevelApi = new FeishuTenantV3JobLevel();

// 获取职级信息
const result = await jobLevelApi.getJobLevelById("jl_xxxxxxxxx");

if (result.code === 0) {
  console.log(`职级名称: ${result.data.name}`);
  console.log(`职级描述: ${result.data.description}`);
} else {
  console.error(`获取职级信息失败: ${result.msg}`);
}

获取职级列表

函数签名

csharp
Task<FeishuApiPageListResult<JobLevelResult>?> GetJobLevelListAsync(
     [Query("name")] string name,
     [Query("page_size")] int? page_size = 10,
     [Query("page_token")] string? page_token = null,
     CancellationToken cancellationToken = default);

认证 租户令牌

参数

参数名类型必填说明示例值
namestring职级名称"高级专家"
page_sizeint分页大小,即本次请求所返回的用户信息列表内的最大条目数。默认值:1020
page_tokenstring分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果"page_token_xxx"

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "items": [
      {
        "job_level_id": "jl_xxxxxxxxx",
        "name": "高级专家",
        "description": "公司内部中高级职称,有一定专业技术能力的人员",
        "order": 200,
        "status": true,
        "i18n_name": [],
        "i18n_description": [],
        "create_time": "2024-01-01 00:00:00",
        "update_time": "2024-01-01 00:00:00"
      }
    ],
    "page_token": "page_token_xxx",
    "has_more": true
  }
}

错误码

错误码错误信息说明
99991665invalid page_size无效的分页大小

说明

  • 支持按名称模糊查询职级
  • 返回结果按order字段升序排序
  • page_size最大值为100

代码示例

typescript
import { FeishuTenantV3JobLevel } from 'mud-feishu';

const jobLevelApi = new FeishuTenantV3JobLevel();

// 获取职级列表
let pageToken: string | undefined = undefined;
do {
  const result = await jobLevelApi.getJobLevelList(
    "专家", // 查询包含"专家"的职级
    20,     // 每页20条记录
    pageToken
  );

  if (result.code === 0) {
    result.data.items.forEach(item => {
      console.log(`职级ID: ${item.job_level_id}, 名称: ${item.name}`);
    });

    pageToken = result.data.has_more ? result.data.page_token : undefined;
  } else {
    console.error(`获取职级列表失败: ${result.msg}`);
    break;
  }
} while (pageToken);

删除指定职级

函数签名

csharp
Task<FeishuNullDataApiResult?> DeleteJobLevelByIdAsync(
        [Path] string job_level_id,
        CancellationToken cancellationToken = default);

认证 租户令牌

参数

参数名类型必填说明示例值
job_level_idstring职级ID"jl_xxxxxxxxx"

响应

json
{
  "code": 0,
  "msg": "success"
}

错误码

错误码错误信息说明
99991663job_level not found职级不存在
99991666cannot delete job_level in use无法删除正在使用的职级

说明

  • 如果职级已被用户使用,则无法删除
  • 删除职级后,无法恢复

代码示例

typescript
import { FeishuTenantV3JobLevel } from 'mud-feishu';

const jobLevelApi = new FeishuTenantV3JobLevel();

// 删除职级
const result = await jobLevelApi.deleteJobLevelById("jl_xxxxxxxxx");

if (result.code === 0) {
  console.log("职级删除成功");
} else {
  console.error(`职级删除失败: ${result.msg}`);
}