egg_server/routes/sheet/insert.ts
2024-11-25 11:08:54 +00:00

28 lines
723 B
TypeScript

import { Context } from "../../types"
import { SheetProxy } from "../../types/sheetProxy"
/**
* 插入表格数据
* @param {Context.Data} ctx - 上下文数据,包含请求体和响应生成器
* @param {string} appName - 应用名称
* @returns {Promise<Response>} 返回响应对象
*/
const insertSheet = async (ctx: Context.Data) => {
const { genResp, larkService } = ctx
const body = ctx.body as SheetProxy.InsertData
const insertRes = await larkService.sheet.insertRows(
body.sheet_token,
body.range,
body.values
)
if (insertRes?.code !== 0) {
return genResp.serverError(insertRes?.message)
}
// 返回成功
return genResp.ok(insertRes?.data)
}
export default insertSheet