From ba94ceae1315174798ae1967ef62268c6d16cd5b Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期一, 06 十月 2025 22:07:06 +0800 Subject: [PATCH] feat: 评审与活动相关改动 - backend(GraphQL): Activity schema 增加 updateActivityState(id, state);实现 resolver/service 仅更新 state=2 作为逻辑删除 - backend(GraphQL): region.graphqls 新增 Query leafRegions - backend(GraphQL): player.graphqls 的 projectReviewApplications 增加可选参数 regionId - backend(Service): listProjectReviewApplications 绑定 regionId 参数,修复 QueryParameterException - frontend(web): 新增 api/activity.js 的 updateActivityState 并接入 activity-list 删除逻辑 - frontend(web): review-list.vue 权限仅校验登录,移除角色限制;查询参数修正为 name/regionId - frontend(web): 删除未引用的 ActivityList.vue - frontend(web): projectReviewNew.js GraphQL 查询增加 name 参数 --- web/src/api/employee.ts | 100 +++++++++---------------------------------------- 1 files changed, 19 insertions(+), 81 deletions(-) diff --git a/web/src/api/employee.ts b/web/src/api/employee.ts index dd55bc7..6cb318e 100644 --- a/web/src/api/employee.ts +++ b/web/src/api/employee.ts @@ -1,5 +1,7 @@ // 鍛樺伐绠$悊API +import { API_CONFIG, graphqlRequest } from '@/config/api' + // 鍛樺伐鐩稿叧鐨� GraphQL 鏌ヨ鍜屽彉鏇� export const EMPLOYEE_QUERIES = { // 鑾峰彇鎵�鏈夊憳宸� @@ -17,7 +19,7 @@ } `, - // 鏍规嵁濮撳悕鎼滅储鍛樺伐 + // 鎼滅储鍛樺伐 SEARCH_EMPLOYEES: ` query SearchEmployees($name: String) { employeesByName(name: $name) { @@ -94,92 +96,41 @@ // API 鍑芥暟 export const employeeApi = { - // 鑾峰彇鎵�鏈夊憳宸� + // 鑾峰彇鍛樺伐鍒楄〃 async getEmployees(): Promise<Employee[]> { try { - const response = await fetch('http://localhost:8080/api/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: EMPLOYEE_QUERIES.GET_EMPLOYEES - }) - }) - const result = await response.json() - if (result.errors) { - throw new Error(result.errors[0].message) - } - return result.data?.employees || [] + const result = await graphqlRequest(EMPLOYEE_QUERIES.GET_EMPLOYEES) + return result?.data?.employees || [] } catch (error: any) { throw new Error(error.message || '鑾峰彇鍛樺伐鍒楄〃澶辫触') } }, - // 鏍规嵁鍚嶇О鎼滅储鍛樺伐 - async searchEmployees(name?: string): Promise<Employee[]> { + // 鎼滅储鍛樺伐 + async searchEmployees(name: string): Promise<Employee[]> { try { - const response = await fetch('http://localhost:8080/api/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: EMPLOYEE_QUERIES.SEARCH_EMPLOYEES, - variables: { name } - }) - }) - const result = await response.json() - if (result.errors) { - throw new Error(result.errors[0].message) - } - return result.data?.employeesByName || [] + const result = await graphqlRequest(EMPLOYEE_QUERIES.SEARCH_EMPLOYEES, { name }) + return result?.data?.employeesByName || [] } catch (error: any) { throw new Error(error.message || '鎼滅储鍛樺伐澶辫触') } }, - // 鑾峰彇鍛樺伐璇︽儏 + // 鏍规嵁ID鑾峰彇鍛樺伐璇︽儏 async getEmployee(id: string): Promise<Employee | null> { try { - const response = await fetch('http://localhost:8080/api/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: EMPLOYEE_QUERIES.GET_EMPLOYEE, - variables: { id } - }) - }) - const result = await response.json() - if (result.errors) { - throw new Error(result.errors[0].message) - } - return result.data?.employee || null + const result = await graphqlRequest(EMPLOYEE_QUERIES.GET_EMPLOYEE, { id }) + return result?.data?.employee || null } catch (error: any) { throw new Error(error.message || '鑾峰彇鍛樺伐璇︽儏澶辫触') } }, - // 淇濆瓨鍛樺伐 - async saveEmployee(input: EmployeeInput): Promise<Employee> { + // 淇濆瓨鍛樺伐锛堟柊澧炴垨鏇存柊锛� + async saveEmployee(employee: EmployeeInput): Promise<Employee> { try { - const response = await fetch('http://localhost:8080/api/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: EMPLOYEE_MUTATIONS.SAVE_EMPLOYEE, - variables: { input } - }) - }) - const result = await response.json() - if (result.errors) { - throw new Error(result.errors[0].message) - } - return result.data?.saveEmployee + const result = await graphqlRequest(EMPLOYEE_MUTATIONS.SAVE_EMPLOYEE, { input: employee }) + return result?.data?.saveEmployee } catch (error: any) { throw new Error(error.message || '淇濆瓨鍛樺伐澶辫触') } @@ -188,21 +139,8 @@ // 鍒犻櫎鍛樺伐 async deleteEmployee(id: string): Promise<boolean> { try { - const response = await fetch('http://localhost:8080/api/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: EMPLOYEE_MUTATIONS.DELETE_EMPLOYEE, - variables: { id } - }) - }) - const result = await response.json() - if (result.errors) { - throw new Error(result.errors[0].message) - } - return result.data?.deleteEmployee || false + const result = await graphqlRequest(EMPLOYEE_MUTATIONS.DELETE_EMPLOYEE, { id }) + return result?.data?.deleteEmployee || false } catch (error: any) { throw new Error(error.message || '鍒犻櫎鍛樺伐澶辫触') } -- Gitblit v1.8.0