# 文档模板

# 添加自定义模板

功能:添加自定义模板,仅添加用户可使用。

路径:fs/bs/template。

请求方法:POST。

请求参数:

参数 必须 类型 备注
fid 是 string 文档 ID
type 是 string 模板类型,取值为 sheet 或 note
name 是 string 模板名称
file 否 file 模板封面文件
appUserId 是 number 业务用户 ID

请求示例:

点击查看
export async function POST(
  fid: string,
  type: DocType,
  name: string,
  appUserId: string,
  file?: File
): Promise<ResponseBody<IflydocsTemplate>> {
  const method = 'POST'
  const path = '/fs/bs/template'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const data = new FormData()
  data.append('fid', fid)
  data.append('type', type)
  data.append('name', name)
  data.append('appUserId', appUserId)
  if (file) {
    data.append('file', file)
  }

  const headers = {
    Authorization,
    nonce,
    timestamp,
    ...data.getHeaders(),
  }

  const resp = await axios.post(path, data, {
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": {
    "id": "10tdg",
    "categoryId": "0",
    "type": "note",
    "name": "测试模板2",
    "ctime": "2022-10-27 16:29:03",
    "mtime": "2022-10-27 16:29:03",
    "uid": 1657589576821,
    "img": "",
    "heat": 0,
    "v": "0",
    "status": 1,
    "recommend": 0,
    "appId": "6da37dd3"
  }
}

# 查询模板

功能:查询模板。

路径:fs/bs/template。

请求方法:GET。

请求参数:

参数 必须 类型 备注
status 否 number 模板状态。1 为正常状态,2 为包含未上架的模板
appUserId 是 string 业务用户 ID

请求示例:

点击查看
type TemplateList = {
  type: DocType
  customTemplates: Array<IflydocsTemplate>
  templateCategoryDto: Array<{
    id: string
    name: string
    type: DocType
    icon: string | null
    publicTemplates: Array<IflydocsTemplate>
  }>
}

/**
 * 查询模板
 * @param status 模板状态, 1为正常,2为包含未启用的模板
 * @param appUserId 业务用户 ID
 */
export async function GET(
  status: number,
  appUserId: string
): Promise<ResponseBody<TemplateList[]>> {
  const method = 'GET'
  const path = '/fs/bs/template'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const params = {
    status,
    appUserId,
  }

  const resp = await axios.get(path, {
    params,
    paramsSerializer: (params) => qs.stringify(params),
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": [
    {
      "type": "sheet",
      "customTemplates": [],
      "templateCategoryDto": [
        {
          "id": "fbc0f056-75f4-49f9-9699-87de43aed519",
          "name": "模板类别 ",
          "type": "sheet",
          "icon": null,
          "publicTemplates": []
        }
      ]
    },
    {
      "type": "note",
      "customTemplates": [
        {
          "id": "10tdf",
          "categoryId": "0",
          "type": "note",
          "name": "新测试模板",
          "ctime": "2022-10-27 16:29:03",
          "mtime": "2022-10-27 16:29:03",
          "uid": 1657589576821,
          "img": "",
          "heat": 0,
          "v": "0",
          "status": 1,
          "recommend": 0,
          "appId": "6da37dd3"
        },
        {
          "id": "10tdg",
          "categoryId": "0",
          "type": "note",
          "name": "测试模板2",
          "ctime": "2022-10-27 16:29:03",
          "mtime": "2022-10-27 16:29:03",
          "uid": 1657589576821,
          "img": "",
          "heat": 0,
          "v": "0",
          "status": 1,
          "recommend": 0,
          "appId": "6da37dd3"
        }
      ],
      "templateCategoryDto": [
        {
          "id": "58eb604e-766f-4273-8b1a-9eedf798a0b5",
          "name": "234234",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "f0c3ae73-18c0-45ab-8b1e-4c6cc0d13211",
          "name": "234234",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "206daa9d-8c18-467d-aad0-0ebcb62add04",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "bc4f4c09-6c06-4020-925b-b2d955f0ab39",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "3e632de1-68f1-4e9c-846a-0e8a401b97e2",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "205f8f6f-7f14-42d4-ab2c-86d3b6e89bde",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "b8626da0-2627-4204-8a28-f2600d0d0dee",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "513a2450-bfa0-4a43-bdfe-1cbae52131f5",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "3ade5039-eb57-44bb-8464-c4054ed1c727",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "f3630b36-360e-45a5-b738-9fcb44986119",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "b5d0f18f-718a-4604-9378-5c3300702d7c",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "28ed9145-53ed-49ae-992a-cc8ec32911a6",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "10c534ed-ec62-4e1e-ac4d-1ed4545e9fb6",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "98bcce5b-78ab-4f0b-bac9-a7ede738b92c",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "a43d2826-3ebd-404d-ad9a-c21799a46fe2",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "e498f3f1-e277-409d-8366-8aa5157700c1",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "9e8771b1-526d-4809-bf8d-a08e843c5ed2",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "9737118b-a187-47a7-b710-49c83a39f888",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "ceda4bb2-6ce8-41dd-bfac-f6e2b5cc6d08",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "c3ff3e4d-3d90-4ead-a155-2554a4c8169a",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "a088d271-2147-4b1b-8a41-261ca62d5264",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "d1909380-33e1-46d9-adae-7141a2d0662e",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "cc127644-0127-4f02-a03c-f3b3b2a7b645",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "4a342e70-1fee-48b5-9806-68c4fbb73164",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "9cbba7be-0eac-47da-a8f9-785988ff9145",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "3c5ca26c-01c3-419c-a7e1-5e1b36a25c82",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "220dc325-ca78-4bc3-8304-536066c19413",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "7d1d9e5e-d22d-49e1-87c1-08d3a9778568",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "afa0eb01-664b-4f01-ac3e-b7ab9634a444",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "c88ed734-6411-411d-97ca-0c275c58058c",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "7f092b01-52ab-483c-9dfc-f2e8ddcccb87",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "0a3ba1bc-f2a8-445c-b198-9ef62ff0bffc",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": []
        },
        {
          "id": "d3a7138b-889c-4d61-9bb4-d0b703748d5c",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": [
            {
              "id": "10t2D",
              "categoryId": "d3a7138b-889c-4d61-9bb4-d0b703748d5c",
              "type": "note",
              "name": "测试公共模板",
              "ctime": "2022-10-25 10:24:20",
              "mtime": "2022-10-25 10:24:20",
              "uid": 0,
              "img": null,
              "heat": 0,
              "v": "0",
              "status": 1,
              "recommend": 0,
              "appId": "6da37dd3"
            }
          ]
        },
        {
          "id": "c883a5d9-4759-4694-b88c-d0ece9efbb38",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": [
            {
              "id": "10t2F",
              "categoryId": "c883a5d9-4759-4694-b88c-d0ece9efbb38",
              "type": "note",
              "name": "测试公共模板",
              "ctime": "2022-10-25 10:25:00",
              "mtime": "2022-10-25 10:25:00",
              "uid": 0,
              "img": null,
              "heat": 0,
              "v": "0",
              "status": 1,
              "recommend": 0,
              "appId": "6da37dd3"
            }
          ]
        },
        {
          "id": "be922892-f05f-457b-a33f-575376fb51e9",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": [
            {
              "id": "10t6E",
              "categoryId": "be922892-f05f-457b-a33f-575376fb51e9",
              "type": "note",
              "name": "测试公共模板",
              "ctime": "2022-10-26 10:58:59",
              "mtime": "2022-10-26 10:58:59",
              "uid": 0,
              "img": null,
              "heat": 0,
              "v": "0",
              "status": 1,
              "recommend": 0,
              "appId": "6da37dd3"
            }
          ]
        },
        {
          "id": "95dd870b-8402-40f1-858a-38cacf4ede78",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": [
            {
              "id": "10t8s",
              "categoryId": "95dd870b-8402-40f1-858a-38cacf4ede78",
              "type": "note",
              "name": "测试公共模板",
              "ctime": "2022-10-26 11:32:49",
              "mtime": "2022-10-26 11:32:49",
              "uid": 0,
              "img": null,
              "heat": 0,
              "v": "0",
              "status": 1,
              "recommend": 0,
              "appId": "6da37dd3"
            }
          ]
        },
        {
          "id": "c968b535-125c-4671-8c52-7bb8e377b4c3",
          "name": "test-public-category",
          "type": "note",
          "icon": null,
          "publicTemplates": [
            {
              "id": "10tbb",
              "categoryId": "c968b535-125c-4671-8c52-7bb8e377b4c3",
              "type": "note",
              "name": "测试公共模板",
              "ctime": "2022-10-27 12:05:02",
              "mtime": "2022-10-27 12:05:02",
              "uid": 0,
              "img": null,
              "heat": 0,
              "v": "0",
              "status": 1,
              "recommend": 0,
              "appId": "6da37dd3"
            }
          ]
        },
        {
          "id": "e903512f-5caa-4ed0-ba75-90c5534a344a",
          "name": "推荐模板",
          "type": "note",
          "icon": null,
          "publicTemplates": [
            {
              "id": "1ulR",
              "categoryId": "e903512f-5caa-4ed0-ba75-90c5534a344a",
              "type": "note",
              "name": "推荐模板",
              "ctime": "2021-11-07 20:48:52",
              "mtime": "2021-11-07 20:48:52",
              "uid": 0,
              "img": "https://bjb.openstorage.cn/v1/agji/public/templateCover/1ulR_608009.png",
              "heat": 0,
              "v": "0",
              "status": 1,
              "recommend": 0,
              "appId": "DOCS_TEST"
            }
          ]
        }
      ]
    }
  ]
}

# 修改模板名称

功能:修改模板名称。

路径:fs/bs/template。

请求方法:PUT。

请求参数:

参数 必须 类型 备注
id 是 string 模板 ID
name 是 string 模板名称
appUserId 是 string 业务用户 ID

请求示例:

点击查看
/**
 * 修改模板名称
 * @param id 模板 ID
 * @param name 模板名称
 * @param appUserId 业务用户 ID
 */
export async function PUT(
  id: string,
  name: string,
  appUserId: string
): Promise<ResponseBody<null>> {
  const method = 'PUT'
  const path = '/fs/bs/template'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const data = {
    id,
    name,
    appUserId,
  }

  const resp = await axios.put(path, null, {
    params: data,
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": null
}

# 删除模板

功能:删除指定模板。

路径:fs/bs/template。

请求方法:DELETE。

请求参数:

参数 必须 类型 备注
id 是 string 模板 ID
appUserId 是 string 业务用户 ID

请求示例:

点击查看
/**
 * 删除指定模板
 * @param id 模板 ID
 * @param appUserId 业务用户 ID
 */
export async function DELETE(
  id: string,
  appUserId: string
): Promise<ResponseBody<null>> {
  const method = 'DELETE'
  const path = '/fs/bs/template'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const params = {
    id,
    appUserId,
  }

  const resp = await axios.delete(path, {
    params,
    paramsSerializer: (params) => qs.stringify(params),
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": null
}

# 添加模板类别

功能:添加模板类别。

路径:fs/bs/template/category。

请求方法:POST。

请求参数:

参数 必须 类型 备注
id 是 string 模板类别 ID
icon 否 string 模板类别 icon url
type 是 string 模板类别类型。取值为 sheet, note
name 是 string 模板类别名称
sort 是 number 排序数值
appUserId 是 number 业务用户 ID

请求示例:

点击查看
type TemplateCategory = {
  id: string
  icon: string | null
  type: DocType
  name: string
  sort: number
}

/**
 * 创建模版类别
 * @param id 模板类别 ID
 * @param type 模板类别类型,note 或 sheet
 * @param name 模板类别名称
 * @param sort 排序数值,越小越靠前
 * @param appUserId 业务用户 ID
 * @param icon 模板类别图标 URL
 */
export async function POST(
  type: DocType,
  name: string,
  sort: number,
  appUserId: string,
  icon?: string
): Promise<ResponseBody<TemplateCategory>> {
  const method = 'POST'
  const path = '/fs/bs/template/category'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const data = {
    type,
    name,
    sort,
    appUserId,
    icon,
  }

  const resp = await axios.post(path, data, {
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": {
    "id": "c0649758-c237-4811-aa23-e7286339447a",
    "icon": null,
    "type": "note",
    "name": "测试分类",
    "sort": 100
  }
}

# 修改模板类别名称

功能:修改模板类别名称。

路径:fs/bs/template/category。

请求方法:PUT。

请求参数:

参数 必须 类型 备注
id 是 string 模板类别 ID
name 是 string 模板名称
appUserId 是 string 业务用户 ID

请求示例:

点击查看
/**
 * 修改模板类别名称
 * @param id 模板类别 ID
 * @param name 模板类别名称
 * @param appUserId 业务用户 ID
 */
export async function PUT(
  id: string,
  name: string,
  appUserId: string
): Promise<ResponseBody<null>> {
  const method = 'PUT'
  const path = '/fs/bs/template/category'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const data = {
    id,
    name,
    appUserId,
  }

  const resp = await axios.put(path, null, {
    params: data,
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": null
}

# 删除模板

功能:删除指定模板类别。

路径:fs/bs/template/category。

请求方法:DELETE。

请求参数:

参数 必须 类型 备注
id 是 string 模板类别 ID
appUserId 是 string 业务用户 ID

请求示例:

点击查看
/**
 * 删除指定模板类别
 * @param id 模板类别 ID
 * @param appUserId 业务用户 ID
 */
export async function DELETE(
  id: string,
  appUserId: string
): Promise<ResponseBody<null>> {
  const method = 'DELETE'
  const path = '/fs/bs/template/category'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const params = {
    id,
    appUserId,
  }

  const resp = await axios.delete(path, {
    params,
    paramsSerializer: (params) => qs.stringify(params),
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": null
}

# 添加公共模板

功能:添加公共模板,所有用户均可使用。

路径:fs/bs/template/public。

请求方法:POST。

请求参数:

参数 必须 类型 备注
fid 是 string 文档 ID
type 是 string 模板类型,取值为 sheet 或 note
name 是 string 模板名称
categoryId 是 string 模板类别 ID
recommend 是 number 是否设置为推荐。0 为默认,1 为推荐
file 否 file 模板封面文件
appUserId 是 number 业务用户 ID

请求示例:

点击查看
/**
 * 添加公共模板,所有用户均可使用。
 * 注意,添加后默认是未启用状态,需要调用 template/takeeffect 接口启用。
 * @param fid 模板对应的原始文档 ID
 * @param type 模板类型
 * @param name 模板名称
 * @param categoryId 模板分类 ID
 * @param recommend 是否设置为推荐。0为默认,1为推荐。
 * @param appUserId 业务用户 ID
 * @param file 模板封面
 */
export async function POST(
  fid: string,
  type: DocType,
  name: string,
  categoryId: string, // 模板类别 ID
  recommend: 0 | 1, // 是否推荐,默认为0,1为推荐
  appUserId: string,
  file?: File // 模板封面文件
): Promise<ResponseBody<IflydocsTemplate>> {
  const method = 'POST'
  const path = '/fs/bs/template/public'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const data = new FormData()
  data.append('fid', fid)
  data.append('type', type)
  data.append('categoryId', categoryId)
  data.append('recommend', recommend)
  data.append('name', name)
  data.append('appUserId', appUserId)
  if (file) {
    data.append('file', file)
  }

  const headers = {
    Authorization,
    nonce,
    timestamp,
    ...data.getHeaders(),
  }

  const resp = await axios.post(path, data, {
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": {
    "id": "10tdi",
    "categoryId": "cc5d250b-5adc-41ae-9fbb-d0ad1d78916c",
    "type": "note",
    "name": "测试公共模板",
    "ctime": "2022-10-27 16:29:05",
    "mtime": "2022-10-27 16:29:05",
    "uid": 0,
    "img": null,
    "heat": 0,
    "v": "0",
    "status": 2,
    "recommend": 0,
    "appId": "6da37dd3"
  }
}

# 查询模板内容

功能:查询模板内容,包含文档模板与表格模板。

路径:fs/bs/template/getJson。

请求方法:GET。

请求参数:

参数 必须 类型 备注
id 是 string 模板 ID
type 是 string 模板类别
appUserId 是 string 业务用户 ID

请求示例:

点击查看
/**
 * 获取模板内容
 * @param id 模板 ID
 * @param type 模板类型
 * @param appUserId 业务用户 ID
 */
export async function GET(
  id: string,
  type: DocType.NOTE,
  appUserId: string
): Promise<ResponseBody<Object>> {
  const method = 'GET'
  const path = '/fs/bs/template/getJson'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const params = {
    id,
    type,
    appUserId,
  }

  const resp = await axios.get(path, {
    params,
    paramsSerializer: (params) => qs.stringify(params),
    headers,
  })

  return resp.data
}

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": {
    "_id": "10tdg",
    "category_id": "0",
    "type": "note",
    "name": "测试模板2",
    "ctime": "2022-10-27T08:29:03.586Z",
    "mtime": "2022-10-27T08:29:03.586Z",
    "uid": 1657589576821,
    "img": "",
    "heat": 0,
    "v": "0",
    "status": 1,
    "recommend": 0,
    "appId": "6da37dd3",
    "ops": {
      "_id": "10tdg",
      "name": "测试模板2",
      "ops": [
        {
          "insert": "会议纪要"
        },
        {
          "attributes": {
            "header": 1
          },
          "insert": "\n"
        },
        {
          "insert": "填入会议内容\n"
        }
      ],
      "_m": {
        "ctime": 1666859343611
      },
      "uid": 1657589576821,
      "_type": "http://sharejs.org/types/rich-text/v1",
      "_v": 1
    }
  }
}

# 设置公共模板状态

功能:设置公共模板状态, 包含上架模板与下架模板。

路径:fs/bs/template/takeeffect。

请求方法:PUT。

请求参数:

参数 必须 类型 备注
tid 是 string 模板 ID
action 是 boolean 状态设置动作。true 表示上架,false 表示下架
appUserId 是 string 业务用户 ID

请求示例:

点击查看
import axios from 'axios'
import genNonce from '@src/nonce'
import sign from '@src/sign'
import authorization from '@src/authorization'
import { ResponseBody } from '@src/response'

//#region put
/**
 * 上架或下架公共模板
 * @param tid  模板 ID
 * @param action  上架或下架。true表示上架,false表示下架。
 * @param appUserId 业务用户 ID
 */
export async function PUT(
  tid: string,
  action: boolean,
  appUserId: string
): Promise<ResponseBody<null>> {
  const method = 'PUT'
  const path = '/fs/bs/template/takeeffect'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const data = {
    tid,
    action,
    appUserId,
  }

  const resp = await axios.put(path, null, {
    params: data,
    headers,
  })

  return resp.data
}
//#endregion get

响应示例:

点击查看
{
  "code": 0,
  "message": "success",
  "data": null
}