From 262c99c6c02bd224d09098c54d5e3d83635c9e68 Mon Sep 17 00:00:00 2001 From: VanellopeAsher <135439116+VanellopeAsher@users.noreply.github.com> Date: Sun, 10 Mar 2024 19:06:27 +0800 Subject: [PATCH] Honor Application : student id -> uuid (#1642) * honor application page: modify student id->uuid * edit package.json --------- Co-authored-by: zrt22 <15600161168@163.com> --- src/app/InfoSite/HonorApplicationPage.tsx | 89 ++++++++++++----------- src/generated/graphql.tsx | 12 +-- src/graphql/info/info_honor.graphql | 30 ++++---- 3 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/app/InfoSite/HonorApplicationPage.tsx b/src/app/InfoSite/HonorApplicationPage.tsx index 1710f6069..a2af1c994 100644 --- a/src/app/InfoSite/HonorApplicationPage.tsx +++ b/src/app/InfoSite/HonorApplicationPage.tsx @@ -104,7 +104,7 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { refetch: refetchApplications, } = graphql.useGetHonorApplicationsQuery({ variables: { - _id: user?.uuid!, + uuid: user?.uuid!, _gte: info.honor.start_A, }, skip: user?.role === "counselor", @@ -154,7 +154,7 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { if (editingApplication) { await updateApplication({ variables: { - id: editingApplication.id, + uuid: editingApplication.id, honor: values.honor, statement: values.statement, attachment_url: values.attachment_url, @@ -163,7 +163,7 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { } else { await addApplication({ variables: { - student_id: user?.uuid!, + student_uuid: user?.uuid!, honor: values.honor, statement: values.statement, attachment_url: values.attachment_url, @@ -187,13 +187,13 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { } }, [deleteApplicationError]); - const handleApplicationDelete = async (id: string) => { + const handleApplicationDelete = async (uuid: string) => { confirm({ title: "确定要删除此申请吗?", icon: , content: "此操作不可恢复。", onOk: async () => { - await deleteApplication({ variables: { id } }); + await deleteApplication({ variables: { uuid } }); await refetchApplications(); }, }); @@ -322,7 +322,7 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { ) => { await updateApplicationStatus({ variables: { - id: item.id, + uuid: item.id, status: checked ? "approved" : "rejected", }, }); @@ -342,19 +342,19 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { title: "学号", dataIndex: ["student", "id"], key: "student_id", - ...getColumnSearchProps(["student", "id"], "学号"), + ...getColumnSearchProps(["student_byuuid", "id"], "学号"), }, { title: "姓名", dataIndex: ["student", "name"], key: "name", - ...getColumnSearchProps(["student", "name"], "姓名"), + ...getColumnSearchProps(["student_byuuid", "name"], "姓名"), }, { title: "班级", dataIndex: ["student", "class"], key: "class", - ...getColumnSearchProps(["student", "class"], "班级"), + ...getColumnSearchProps(["student_byuuid", "class"], "班级"), }, { title: "荣誉类型", @@ -421,14 +421,14 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { (application) => application.honor === exportHonor && exportClasses.some((_class) => - application.student.class?.includes(_class), + application.student_byuuid.class?.includes(_class), ), ) .map((i) => [ i.id, - i.student.id, - i.student.name, - i.student.class, + i.student_byuuid?.uuid, + i.student_byuuid?.realname, + i.student_byuuid?.class, exportHonor, getStatusText(i.status), i.statement, @@ -471,9 +471,9 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { const applications = applicationsForCounselors!.honor_application.map( (i) => [ i.id, - i.student.id, - i.student.name, - i.student.class, + i.student_byuuid?.uuid, + i.student_byuuid?.realname, + i.student_byuuid?.class, i.honor, getStatusText(i.status), i.statement, @@ -558,7 +558,7 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { await Promise.all( applications.map(async (application) => { try { - const id = application[0]; + const uuid = application[0]; const honor = application[4].toString().trim(); const status = application[5].toString().trim(); @@ -571,7 +571,7 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { updateApplicationStatus({ variables: { - id, + uuid, status: getStatusValue(status), }, }); @@ -812,33 +812,34 @@ const HonorApplicationPage: React.FC = ({ mode, user }) => { columns={honorColumnsForCounselor} rowKey="id" expandable={{ - expandedRowRender: record => ( - - - - {record.statement} - - - - {record.attachment_url && isUrl(record.attachment_url) ? ( - ( + + + - {record.attachment_url} - - ) : ( - record.attachment_url || "无" - )} - - - )}} + {record.statement} + + + + {record.attachment_url && isUrl(record.attachment_url) ? ( + + {record.attachment_url} + + ) : ( + record.attachment_url || "无" + )} + + + ), + }} /> } | null }; export type GetHonorApplicationsQueryVariables = Exact<{ - _id: Scalars['String']['input']; + uuid: Scalars['String']['input']; _gte: Scalars['timestamptz']['input']; }>; @@ -10903,10 +10903,10 @@ export type GetHonorApplicationsForCounselorsQueryVariables = Exact<{ }>; -export type GetHonorApplicationsForCounselorsQuery = { __typename?: 'query_root', honor_application: Array<{ __typename?: 'honor_application', id: any, honor: string, statement: string, attachment_url?: string | null, status: string, created_at: any, updated_at: any, student: { __typename?: 'user', id?: any | null, name?: string | null, class?: string | null } }> }; +export type GetHonorApplicationsForCounselorsQuery = { __typename?: 'query_root', honor_application: Array<{ __typename?: 'honor_application', id: any, honor: string, statement: string, attachment_url?: string | null, status: string, created_at: any, updated_at: any, student_byuuid: { __typename?: 'user', uuid?: any | null, realname?: string | null, class?: string | null } }> }; export type AddHonorApplicationMutationVariables = Exact<{ - student_id: Scalars['String']['input']; + student_uuid: Scalars['String']['input']; honor: Scalars['String']['input']; statement: Scalars['String']['input']; attachment_url?: InputMaybe; @@ -10916,7 +10916,7 @@ export type AddHonorApplicationMutationVariables = Exact<{ export type AddHonorApplicationMutation = { __typename?: 'mutation_root', insert_honor_application?: { __typename?: 'honor_application_mutation_response', returning: Array<{ __typename?: 'honor_application', id: any }> } | null }; export type UpdateHonorApplicationMutationVariables = Exact<{ - id: Scalars['uuid']['input']; + uuid: Scalars['uuid']['input']; honor: Scalars['String']['input']; statement: Scalars['String']['input']; attachment_url?: InputMaybe; @@ -10926,14 +10926,14 @@ export type UpdateHonorApplicationMutationVariables = Exact<{ export type UpdateHonorApplicationMutation = { __typename?: 'mutation_root', update_honor_application?: { __typename?: 'honor_application_mutation_response', returning: Array<{ __typename?: 'honor_application', id: any }> } | null }; export type DeleteHonorApplicationMutationVariables = Exact<{ - id: Scalars['uuid']['input']; + uuid: Scalars['uuid']['input']; }>; export type DeleteHonorApplicationMutation = { __typename?: 'mutation_root', delete_honor_application?: { __typename?: 'honor_application_mutation_response', returning: Array<{ __typename?: 'honor_application', id: any }> } | null }; export type UpdateHonorApplicationStatusMutationVariables = Exact<{ - id: Scalars['uuid']['input']; + uuid: Scalars['uuid']['input']; status: Scalars['String']['input']; }>; diff --git a/src/graphql/info/info_honor.graphql b/src/graphql/info/info_honor.graphql index f729005ba..5197b64b3 100644 --- a/src/graphql/info/info_honor.graphql +++ b/src/graphql/info/info_honor.graphql @@ -1,7 +1,7 @@ -query GetHonorApplications($_id: String!, $_gte: timestamptz!) { +query GetHonorApplications($uuid: uuid!, $_gte: timestamptz!) { honor_application( where: { - student_id: { _eq: $_id } + student_uuid: { _eq: $uuid } updated_at: { _gte: $_gte } created_at: { _gte: $_gte } } @@ -27,9 +27,9 @@ query GetHonorApplicationsForCounselors($_gte: timestamptz!) { statement attachment_url status - student { - id - name + student_byuuid { + uuid + realname class } created_at @@ -38,14 +38,14 @@ query GetHonorApplicationsForCounselors($_gte: timestamptz!) { } mutation AddHonorApplication( - $student_id: String! + $student_uuid: uuid! $honor: String! $statement: String! $attachment_url: String ) { insert_honor_application( objects: { - student_id: $student_id + student_uuid: $uuid honor: $honor statement: $statement attachment_url: $attachment_url @@ -58,13 +58,13 @@ mutation AddHonorApplication( } mutation UpdateHonorApplication( - $id: uuid! + $student_uuid: uuid! $honor: String! $statement: String! $attachment_url: String ) { update_honor_application( - where: { id: { _eq: $id } } + where: { student_uuid: { _eq: $uuid } } _set: { honor: $honor statement: $statement @@ -77,21 +77,21 @@ mutation UpdateHonorApplication( } } -mutation DeleteHonorApplication($id: uuid!) { - delete_honor_application(where: { id: { _eq: $id } }) { +mutation DeleteHonorApplication($uuid: uuid!) { + delete_honor_application(where: { student_uuid: { _eq: $uuid } }) { returning { - id + uuid } } } -mutation UpdateHonorApplicationStatus($id: uuid!, $status: String!) { +mutation UpdateHonorApplicationStatus($uuid: uuid!, $status: String!) { update_honor_application( - where: { id: { _eq: $id } } + where: { student_uuid: { _eq: $uuid } } _set: { status: $status } ) { returning { - id + uuid status } }