feat: 更新数据库字段名称
All checks were successful
Egg CI/CD / build-image (push) Successful in 27s
Egg CI/CD / deploy (push) Successful in 22s

This commit is contained in:
zhaoyingbo 2024-07-11 08:45:22 +00:00
parent 490c6ea3e5
commit 2c2810277f
4 changed files with 7 additions and 12 deletions

View File

@ -9,7 +9,7 @@ import { DB } from "../../types";
*/
const get = async (appName: string) =>
managePb404<DB.AppInfo>(() =>
pbClient.collection("app_info").getFirstListItem(`code_name='${appName}'`)
pbClient.collection("app_info").getFirstListItem(`name='${appName}'`)
);
/**

View File

@ -12,11 +12,7 @@ export const resetAccessToken = async () => {
app_id: app.app_id,
app_secret: app.app_secret,
});
await db.tenantAccessToken.update(
app.id,
app.code_name,
tenant_access_token
);
await db.tenantAccessToken.update(app.id, app.name, tenant_access_token);
}
} catch (error) {
console.error("🚀 ~ resetAccessToken ~ error", error);

View File

@ -1,5 +1,3 @@
import db from "../../db";
import { DB } from "../../types";
import { LarkServer } from "../../types/larkServer";
import larkNetTool from "./larkNetTool";
@ -19,7 +17,8 @@ const code2Login = (appName?: string) => async (code: string) => {
* @returns
*/
const get =
(appName?: string) => async (user_id: string, user_id_type: string) => {
(appName?: string) =>
async (user_id: string, user_id_type: "open_id" | "user_id") => {
const URL = `https://open.f.mioffice.cn/open-apis/contact/v3/users/${user_id}`;
return larkNetTool.get(appName)<LarkServer.UserInfoRes>(URL, {
user_id_type,
@ -37,11 +36,11 @@ const batchGet =
const URL = `https://open.f.mioffice.cn/open-apis/contact/v3/users/batch`;
// 如果user_id长度超出50需要分批请求,
const user_idsLen = user_ids.length;
const userCount = user_ids.length;
const maxLen = 50;
const requestMap = Array.from(
{ length: Math.ceil(user_idsLen / maxLen) },
{ length: Math.ceil(userCount / maxLen) },
(_, index) => {
const start = index * maxLen;
const user_idsSlice = user_ids.slice(start, start + maxLen);

View File

@ -2,7 +2,7 @@ import { RecordModel } from "pocketbase";
export namespace DB {
export interface AppInfo extends RecordModel {
code_name: string;
name: string;
app_id: string;
app_secret: string;
app_name: string;