# API文档

## &#x20;公共请求

<mark style="color:green;">`POST`</mark> `/版本号/模块/接口名[query|/params]`

**这是所有请求的公共参数，所有的接口都遵循这个规律，**\
\
**所以后面的接口将只列出接口独有的入参和请求成功返回的业务数据（data属性）**

{% tabs %}
{% tab title="200 " %}

```
{
    success: true, // 成功状态，true是成功，false是失败
    data: {}, // 业务数据，当success为true时有这个属性
    error: { // 异常对象，当success为false时有这个属性
      code: 123,  // 错误码
      message: '' // 错误信息
    }
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    success: false,
    error: {
      code: 401,
      message: '未登录或已登录，请重新登录'
    }
}
```

{% endtab %}

{% tab title="402 " %}

```
{
    success: false,
    error: {
      code: 402,
      message: '越权操作，请联系管理员'
    }
}
```

{% endtab %}
{% endtabs %}

## CRUD相关接口

{% hint style="info" %}
以下5个接口是CRUD页面使用的接口，实际后端应该每一个实体后分别有这5个接口，将接口名里面的Modle替换成具体的实体名称，给前端调用。
{% endhint %}

## 查询实体列表

<mark style="color:green;">`POST`</mark> `/v1/page/searchModel`

用于查询动态CURD页面的数据列表的接口，这个接口的入参会包含页面上搜索表单中所有非空的字段和下面列表的参数

#### Request Body

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| pageSize | number | 每页显示条数，默认10 |
| pageNum  | number | 当前页码，默认1    |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```javascript
{
    success: true,
    data: {
      rows: any[],  // 当前页的数据
      total: number  // 总条数
    }
}
```

{% endtab %}
{% endtabs %}

## 查询单个实体

<mark style="color:green;">`POST`</mark> `/v1/page/getModel/:id`

查询单个实体，用于CRUD页面编辑表单的数据初始化

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | 实体的id       |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true,
    data: any // 查询到的实体
}
```

{% endtab %}
{% endtabs %}

## 保存实体

<mark style="color:green;">`POST`</mark> `/v1/page/saveModel`

&#x20;CRUD页面的新增和更新实体的操作

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | object | 需要新增/更新的实体  |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true,
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## &#x20;删除一条数据

<mark style="color:green;">`POST`</mark> `/v1/page/delModel/:id`

CRUD页面通过id删除一条数据的接口

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | 实体的id       |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true, 
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## &#x20;查看详情的

<mark style="color:green;">`POST`</mark> `/v1/page/viewModel/:id`

CRUD页面查看数据详情的接口

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | 实体id        |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true, // 成功状态，true是成功，false是失败
    data: any // 查询到的实体
}
```

{% endtab %}
{% endtabs %}

## 表单相关接口

## 获取选项

<mark style="color:green;">`POST`</mark> `/v1/base/getOptions`

获取选择型组件的选项数据<br>

#### Query Parameters

| Name | Type   | Description                    |
| ---- | ------ | ------------------------------ |
| code | string | 数据源的标识，后端根据这个标识返回不同的数据         |
| type | string | 数据源类型，后端根据这个类型返回不同的数据结构，如树、表格等 |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: any // 这里返回的数据根据入参type会有不同
}
```

{% endtab %}
{% endtabs %}

## &#x20;获取选项（dialog）

<mark style="color:green;">`POST`</mark> `/v1/base/getPageOptions/:code`

&#x20;获取弹窗选择器的选择项数据<br>

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| code | string | CRUD页面的code |

{% tabs %}
{% tab title="200 " %}

```
{
    success: true
    data: Page // page对象
}
```

{% endtab %}
{% endtabs %}

Dashboard相关接口

## &#x20;查找所有的Dashboard

<mark style="color:green;">`POST`</mark> `/v1/base/getAllDashboard`

&#x20;查找所有可以添加到首页的仪表盘

{% tabs %}
{% tab title="200 " %}

```
{
    success: true
    data: Dashboard[] // 仪表盘数组
}
```

{% endtab %}
{% endtabs %}

## &#x20;用户的DashBoard布局

<mark style="color:green;">`POST`</mark> `/v1/base/getUserDashboard`

&#x20;查找用户已经添加到首页的仪表盘布局，如果用户没有配置过，则返回所有仪表盘的前8个

{% tabs %}
{% tab title="200 " %}

```
{
    success: true
    data: Array<Dashboard | UserDashboard> // 仪表盘数组或用户的仪表盘布局
}
```

{% endtab %}
{% endtabs %}

## &#x20;保存用户的Dashboard布局

<mark style="color:green;">`POST`</mark> `/v1/base/saveUserDashboard`

#### Request Body

| Name           | Type  | Description |
| -------------- | ----- | ----------- |
| userDashboards | array | 用户仪表盘配置数组   |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## 其他业务接口

## &#x20;用户登录

<mark style="color:green;">`POST`</mark> `/v1/public/login`

#### Request Body

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| name     | string | 用户名         |
| password | string | 密码          |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## &#x20;获取权限数据

<mark style="color:green;">`POST`</mark> `/v1/base/getAuth`

&#x20;获取用户的权限数据

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {
      user: User, // 用户数据
      auth: {
        menus: Menu[], // 有权限的菜单数组
        resources: string[] // 有权限的资源code数组
      }
    }
}
```

{% endtab %}
{% endtabs %}

## &#x20;退出登录

<mark style="color:green;">`POST`</mark> `/v1/public/logout`

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## &#x20;查询表单/页面列表

<mark style="color:green;">`POST`</mark> `/v1/page/searchPage`

&#x20;查询系统配置好的动态表单和页面的分页数据

#### Request Body

| Name     | Type   | Description   |
| -------- | ------ | ------------- |
| pageSize | number | 每页显示数据条数，默认10 |
| pageNum  | number | 当前页，默认1       |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {
      rows: Page[], // 当前页数据
      total: number // 总条数
    }
}
```

{% endtab %}
{% endtabs %}

## &#x20;获取表单/页面数据

<mark style="color:green;">`POST`</mark> `/v1/page/getPage/:code`

&#x20;通过页面代码获取页面数据

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| code | string | 页面代码        |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: Page // 页面数据
}
```

{% endtab %}
{% endtabs %}

## &#x20;保存表单/页面数据

<mark style="color:green;">`POST`</mark> `/v1/page/savePage`

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | object | page对象      |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## &#x20;删除表单/页面

<mark style="color:green;">`POST`</mark> `/v1/page/delPage/:id`

&#x20;根据id删除表单或页面

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | 要删除的页面id    |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## 获取菜单树

<mark style="color:green;">`POST`</mark> `/v1/system/menuTree`

&#x20;以树形结构查询所有的菜单

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: Array<{
      id: string, // 菜单id
      name: string, // 菜单名称
      url?: string, // 菜单的URL
      icon?: string, // 菜单的图标
      children: Menu[] // 子菜单
    }>
}
```

{% endtab %}
{% endtabs %}

## &#x20;保存菜单

<mark style="color:green;">`POST`</mark> `/v1/system/saveMenu`

&#x20;新增或修改菜单

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | object | 菜单对象        |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}

## &#x20;删除菜单

<mark style="color:green;">`POST`</mark> `/v1/system/delMenu/:id`

&#x20;通过id删除菜单

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | 菜单id        |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    success: true
    data: {} // 空
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ccqiuqiu.gitbook.io/iface/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
