Skip to content

Commit

Permalink
Support link jump
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <[email protected]>
  • Loading branch information
zjy365 committed Apr 22, 2024
1 parent 17aa4b8 commit 66f4c72
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions frontend/providers/workorder/src/api/platform.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FeishuNotificationParams } from '@/pages/api/platform/feishu';
import { SystemEnvResponse } from '@/pages/api/platform/getEnv';
import { GET, POST } from '@/services/request';
import { AppSession } from '@/types/user';
import { WorkOrderEditForm } from '@/types/workorder';
import { AxiosProgressEvent } from 'axios';

export const getSystemEnv = () => GET<SystemEnvResponse>('/api/platform/getEnv');
Expand Down Expand Up @@ -35,5 +35,5 @@ export const deleteFileByName = ({ fileName }: { fileName: string }) => {
export const AuthByDesktopSession = (payload: { token: string }) =>
POST<AppSession>('/api/auth/desktop', payload);

export const FeishuNotification = (payload: WorkOrderEditForm) =>
export const FeishuNotification = (payload: FeishuNotificationParams) =>
POST('/api/platform/feishu', payload);
12 changes: 9 additions & 3 deletions frontend/providers/workorder/src/pages/api/platform/feishu.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { verifyAccessToken } from '@/services/backend/auth';
import { jsonRes } from '@/services/backend/response';
import { ApiResp } from '@/services/kubernet';
import { WorkOrderEditForm } from '@/types/workorder';
import { WorkOrderType } from '@/types/workorder';
import type { NextApiRequest, NextApiResponse } from 'next';

export type FeishuNotificationParams = {
type: WorkOrderType;
description: string;
orderId: string;
};

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
const userForm = req.body as WorkOrderEditForm;
const userForm = req.body as FeishuNotificationParams;
const { userId } = await verifyAccessToken(req);
const feishuUrl = process.env.ADMIN_FEISHU_URL;
const feishuCallBackUrl = process.env.ADMIN_FEISHU_CALLBACK_URL;
Expand All @@ -30,7 +36,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
},
type: 'primary',
multi_url: {
url: feishuCallBackUrl,
url: feishuCallBackUrl + `?orderId=${userForm.orderId}`,
android_url: '',
ios_url: '',
pc_url: ''
Expand Down
22 changes: 22 additions & 0 deletions frontend/providers/workorder/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useRouter } from 'next/router';
import { useEffect } from 'react';

export default function Index() {
const router = useRouter();

useEffect(() => {
if (router?.query?.orderId) {
const orderId = router?.query?.orderId;
router.push({
pathname: '/workorder/detail',
query: {
orderId: orderId
}
});
} else {
router.push('/workorders');
}
}, [router]);

return <div></div>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export default function EditOrder() {
orderId: res.orderId,
content: data.description
});
await FeishuNotification(data);
await FeishuNotification({
type: data.type,
description: data.description,
orderId: res.orderId
});
toast({
status: 'success',
title: 'success'
Expand Down

0 comments on commit 66f4c72

Please sign in to comment.