Skip to content

查询用户空间列表

接口信息

接口地址:/api/v1/space/list

请求方式:GET

请求数据类型:

响应数据类型:*/*

接口描述:

查询当前用户所在的空间列表

请求示例:

GET /api/v1/space/list

请求参数

请求头

参数名类型必填描述示例值
AuthorizationstringAPI KeyBearer ak-xxxxeyJhbGciOiJIUzI1NiJ9

响应参数:

参数名称参数说明类型schema
code业务状态码,0000 表示成功,其余失败string
displayCode源系统状态码,用于问题跟踪string
message错误描述信息string
data空间列表arraySpaceDto
  id空间IDinteger(int64)
  tenantId租户IDinteger(int64)
  name空间名称string
  description空间描述string
  icon空间图标string
  type空间类型,可用值: Personal, Team, Classstring
  creatorId创建者IDinteger(int64)
  creatorName创建者名称string
  modified更新时间string(date-time)
  created创建时间string(date-time)
  currentUserRole当前用户在空间的角色,可用值: Owner, Admin, Userstring
  receivePublish空间是否接收来自外部的发布integer(int32)
  allowDevelop空间是否开启开发功能integer(int32)
tid跟踪唯一标识string
successboolean

响应示例:

javascript
{
	"code": "0000",
	"displayCode": "0000",
	"message": "success",
	"data": [
		{
			"id": 21,
			"tenantId": 1,
			"name": "ceshi2334",
			"description": null,
			"icon": null,
			"type": "Team",
			"creatorId": 1,
			"creatorName": "fei",
			"modified": "2026-04-13T12:13:46.000+00:00",
			"created": "2025-12-10T06:30:00.000+00:00",
			"currentUserRole": "Owner",
			"receivePublish": 0,
			"allowDevelop": 0
		}
	],
	"tid": "123456",
	"success": true
}

CURL示例

shell
curl 'http://127.0.0.1:8081/api/v1/space/list' \
  -H 'Authorization: Bearer ak-d1f2129c4ba24629b8448af3354f9dd0'

{"code":"0000","displayCode":"0000","message":"success","data":[...],"tid":"123456","success":true}

测试用例

#场景状态码结果
1查询用户空间列表0000成功,返回用户所在的全部空间

TS模板示例

ts
// 空间信息
export interface SpaceDto {
  /* 空间ID */
  id: number;
  /* 租户ID */
  tenantId: number;
  /* 空间名称 */
  name: string;
  /* 空间描述 */
  description: string | null;
  /* 空间图标 */
  icon: string | null;
  /* 空间类型: Personal, Team, Class */
  type: 'Personal' | 'Team' | 'Class';
  /* 创建者ID */
  creatorId: number;
  /* 创建者名称 */
  creatorName: string;
  /* 更新时间 */
  modified: string;
  /* 创建时间 */
  created: string;
  /* 当前用户在空间的角色: Owner, Admin, User */
  currentUserRole: 'Owner' | 'Admin' | 'User' | null;
  /* 是否接收来自外部的发布 */
  receivePublish: number;
  /* 是否开启开发功能 */
  allowDevelop: number;
}

// 响应接口
export interface SpaceListRes {
  code: string;
  displayCode: string;
  message: string;
  data: SpaceDto[];
  tid: string;
  success: boolean;
}

/** 
 * 查询用户空间列表
 * @returns
 */
export function getSpaceList(): Promise<SpaceListRes> {
  return request.get(`/api/v1/space/list`);
}